PMSIS API
|
UART Universal Asynchronous Receiver Transmitter. More...
Data Structures | |
struct | pi_uart_conf |
UART device configuration structure. More... | |
Typedefs | |
typedef struct pi_cl_uart_req_s | pi_cl_uart_req_t |
UART cluster request structure. More... | |
Enumerations | |
enum | pi_uart_stop_bits |
Stop bits enum. More... | |
enum | pi_uart_parity_mode |
Parity mode enum. More... | |
enum | pi_uart_word_size |
Bit length of each word. More... | |
enum | pi_uart_ioctl_cmd |
UART ioctl commands. More... | |
Functions | |
void | pi_uart_conf_init (struct pi_uart_conf *conf) |
Initialize a UART configuration with default values. More... | |
int | pi_uart_open (struct pi_device *device) |
Open a UART device. More... | |
void | pi_uart_close (struct pi_device *device) |
Close an opened UART device. More... | |
int | pi_uart_ioctl (struct pi_device *device, uint32_t cmd, void *arg) |
Dynamically change device configuration. More... | |
int | pi_uart_write (struct pi_device *device, void *buffer, uint32_t size) |
Write data to an UART. More... | |
int | pi_uart_read (struct pi_device *device, void *buffer, uint32_t size) |
Read data from an UART. More... | |
int | pi_uart_write_byte (struct pi_device *device, uint8_t *byte) |
Write a byte to an UART. More... | |
int | pi_uart_read_byte (struct pi_device *device, uint8_t *byte) |
Read a byte from an UART. More... | |
int | pi_uart_write_async (struct pi_device *device, void *buffer, uint32_t size, pi_task_t *callback) |
Write data to an UART asynchronously. More... | |
int | pi_uart_read_async (struct pi_device *device, void *buffer, uint32_t size, pi_task_t *callback) |
Read data from an UART asynchronously. More... | |
int | pi_uart_write_timeout (struct pi_device *device, void *buffer, uint32_t size, uint32_t timeout_us) |
Write data to an UART synchronously, with timeout. More... | |
int | pi_uart_read_timeout (struct pi_device *device, void *buffer, uint32_t size, uint32_t timeout_us) |
Read data from an UART synchronously, with timeout. More... | |
int | pi_uart_write_byte_async (struct pi_device *device, uint8_t *byte, pi_task_t *callback) |
Write a byte to an UART asynchronously. More... | |
int | pi_cl_uart_write (pi_device_t *device, void *buffer, uint32_t size, pi_cl_uart_req_t *req) |
Write data to an UART from cluster side. More... | |
int | pi_cl_uart_write_byte (pi_device_t *device, uint8_t *byte, pi_cl_uart_req_t *req) |
Write a byte to an UART from cluster side. More... | |
static void | pi_cl_uart_write_wait (pi_cl_uart_req_t *req) |
Wait until the specified UART cluster write request has finished. More... | |
int | pi_cl_uart_read (pi_device_t *device, void *buffer, uint32_t size, pi_cl_uart_req_t *req) |
Read a byte from an UART from cluster side. More... | |
int | pi_cl_uart_read_byte (pi_device_t *device, uint8_t *byte, pi_cl_uart_req_t *req) |
Read a byte from an UART. More... | |
static void | pi_cl_uart_read_wait (pi_cl_uart_req_t *req) |
Wait until the specified UART cluster read request has finished. More... | |
This API provides support for transferring data between an external UART device and the processor running this driver.
typedef struct pi_cl_uart_req_s pi_cl_uart_req_t |
This structure is used by the runtime to manage a cluster remote copy with the UART. It must be instantiated once for each copy and must be kept alive until the copy is finished. It can be instantiated as a normal variable, for example as a global variable, a local one on the stack, or through a memory allocator.
enum pi_uart_ioctl_cmd |
UART ioctl commands to configure, enable device.
Enumerator | |||
---|---|---|---|
PI_UART_IOCTL_CONF_SETUP |
Setup UART device. Setup UART with given conf. The parameter for this command is a struct pi_uart_conf.
| ||
PI_UART_IOCTL_ABORT_RX |
Abort RX transfers. Disable RX channel, abort current RX transfert, and flush all pending transferts.
| ||
PI_UART_IOCTL_ABORT_TX |
Abort TX transfers. Disable TX channel, abort current TX transfert, and flush all pending transferts.
| ||
PI_UART_IOCTL_ENABLE_RX |
Enable reception. This command enables reception on UART device. | ||
PI_UART_IOCTL_ENABLE_TX |
Enable transmission. This command enables transmission on UART device. | ||
PI_UART_IOCTL_ENABLE_FLOW_CONTROL |
Enable flow control. This command enables flow control on UART device.
| ||
PI_UART_IOCTL_DISABLE_FLOW_CONTROL |
Disable flow control. This command disables flow control on UART device. | ||
PI_UART_IOCTL_FLUSH |
Flush UART TX. This command will wait until all pending buffers are flushed outside | ||
PI_UART_IOCTL_ATTACH_TIMEOUT_RX |
Attach UDMA timer. This command attaches a UDMA timer channel to UDMA reception channel.
| ||
PI_UART_IOCTL_DETACH_TIMEOUT_RX |
Detach UDMA timer. This command removes a UDMA timer channel attached to UDMA reception channel.
| ||
PI_UART_IOCTL_ATTACH_TIMEOUT_TX |
Attach UDMA timer. This command attaches a UDMA timer channel to UDMA transmission channel.
| ||
PI_UART_IOCTL_DETACH_TIMEOUT_TX |
Detach UDMA timer. This command removes a UDMA timer channel attached to UDMA transmission channel.
|
enum pi_uart_parity_mode |
enum pi_uart_stop_bits |
enum pi_uart_word_size |
int pi_cl_uart_read | ( | pi_device_t * | device, |
void * | buffer, | ||
uint32_t | size, | ||
pi_cl_uart_req_t * | req | ||
) |
This function implements the same feature as pi_uart_read_byte but can be called from cluster side in order to expose the feature on the cluster. A pointer to a request structure must be provided so that the runtime can properly do the remote call.
device | Pointer to device descriptor of the UART device. |
buffer | Pointer to data buffer. |
size | Size of data to copy in bytes. |
req | Request structure used for termination. |
0 | If operation is successfull. |
ERRNO | An error code otherwise. |
int pi_cl_uart_read_byte | ( | pi_device_t * | device, |
uint8_t * | byte, | ||
pi_cl_uart_req_t * | req | ||
) |
This reads a byte from the specified UART. The caller is blocked until the transfer is finished.
device | Pointer to device descriptor of the UART device. |
byte | Pointer to data buffer. |
req | Request structure used for termination. |
0 | If operation is successfull. |
ERRNO | An error code otherwise. |
|
inlinestatic |
This blocks the calling core until the specified cluster remote copy is finished.
req | Request structure used for termination. |
int pi_cl_uart_write | ( | pi_device_t * | device, |
void * | buffer, | ||
uint32_t | size, | ||
pi_cl_uart_req_t * | req | ||
) |
This function implements the same feature as pi_uart_write but can be called from cluster side in order to expose the feature on the cluster. A pointer to a request structure must be provided so that the runtime can properly do the remote call.
device | Pointer to device descriptor of the UART device. |
buffer | Pointer to data buffer. |
size | Size of data to copy in bytes. |
req | Request structure used for termination. |
0 | If operation is successfull. |
ERRNO | An error code otherwise. |
int pi_cl_uart_write_byte | ( | pi_device_t * | device, |
uint8_t * | byte, | ||
pi_cl_uart_req_t * | req | ||
) |
This function implements the same feature as pi_uart_write_byte but can be called from cluster side in order to expose the feature on the cluster. A pointer to a request structure must be provided so that the runtime can properly do the remote call.
device | Pointer to device descriptor of the UART device. |
byte | Pointer to data buffer. |
req | Request structure used for termination. |
0 | If operation is successfull. |
ERRNO | An error code otherwise. |
|
inlinestatic |
This blocks the calling core until the specified cluster remote copy is finished.
req | Request structure used for termination. |
void pi_uart_close | ( | struct pi_device * | device | ) |
This function can be called to close an opened UART device once it is not needed anymore, in order to free all allocated resources. Once this function is called, the device is not accessible anymore and must be opened again before being used.
device | Pointer to device structure of the device to close. |
void pi_uart_conf_init | ( | struct pi_uart_conf * | conf | ) |
This function can be called to get default values for all parameters before setting some of them. The structure containing the configuration must be kept alive until the uart device is opened.
conf | Pointer to the UART configuration. |
int pi_uart_ioctl | ( | struct pi_device * | device, |
uint32_t | cmd, | ||
void * | arg | ||
) |
This function allows to send different commands to UART device. The commands are listed above, cf. enum pi_uart_ioctl_cmd.
device | Pointer to device descriptor of the UART device. |
cmd | Ioctl command. |
arg | Ioctl command args. |
-1 | If wrong ioctl command. |
Value | Otherwise return value depending on ioctl command. |
int pi_uart_open | ( | struct pi_device * | device | ) |
This function must be called before the UART device can be used. It will do all the needed configuration to make it usable and initialize the handle used to refer to this opened device when calling other functions.
device | Pointer to device structure of the device to open. |
0 | If the operation is successfull. |
ERRNO | An error code otherwise. |
int pi_uart_read | ( | struct pi_device * | device, |
void * | buffer, | ||
uint32_t | size | ||
) |
This reads data from the specified UART. The caller is blocked until the transfer is finished. Depending on the chip, there may be some restrictions on the memory which can be used. Check the chip-specific documentation for more details.
device | Pointer to device descriptor of the UART device. |
buffer | Pointer to data buffer. |
size | Size of data to copy in bytes. |
0 | If operation is successfull. |
ERRNO | An error code otherwise. |
int pi_uart_read_async | ( | struct pi_device * | device, |
void * | buffer, | ||
uint32_t | size, | ||
pi_task_t * | callback | ||
) |
This reads data from the specified UART asynchronously. A task must be specified in order to specify how the caller should be notified when the transfer is finished. Depending on the chip, there may be some restrictions on the memory which can be used. Check the chip-specific documentation for more details.
device | Pointer to device descriptor of the UART device. |
buffer | Pointer to data buffer. |
size | Size of data to copy in bytes. |
callback | Event task used to notify the end of transfer. See the documentation of pi_task_t for more details. |
0 | If operation is successfull. |
ERRNO | An error code otherwise. |
int pi_uart_read_byte | ( | struct pi_device * | device, |
uint8_t * | byte | ||
) |
This reads a byte from the specified UART. The caller is blocked until the transfer is finished.
device | Pointer to device descriptor of the UART device. |
byte | Pointer to data buffer. |
0 | If operation is successfull. |
ERRNO | An error code otherwise. |
int pi_uart_read_timeout | ( | struct pi_device * | device, |
void * | buffer, | ||
uint32_t | size, | ||
uint32_t | timeout_us | ||
) |
This function is the same as pi_uart_read(), with timeout feat enabled. This timeout value is used to abort/cancel a transfer when timeout is reached.
device | Pointer to device descriptor of the UART device. |
buffer | Pointer to data buffer. |
size | Size of data to copy in bytes. |
timeout_us | Timeout value in us. |
0 | If operation is successfull. |
ERRNO | An error code otherwise. |
int pi_uart_write | ( | struct pi_device * | device, |
void * | buffer, | ||
uint32_t | size | ||
) |
This writes data to the specified UART. The caller is blocked until the transfer is finished. Depending on the chip, there may be some restrictions on the memory which can be used. Check the chip-specific documentation for more details.
device | Pointer to device descriptor of the UART device. |
buffer | Pointer to data buffer. |
size | Size of data to copy in bytes. |
0 | If operation is successfull. |
ERRNO | An error code otherwise. |
int pi_uart_write_async | ( | struct pi_device * | device, |
void * | buffer, | ||
uint32_t | size, | ||
pi_task_t * | callback | ||
) |
This writes data to the specified UART asynchronously. A task must be specified in order to specify how the caller should be notified when the transfer is finished. Depending on the chip, there may be some restrictions on the memory which can be used. Check the chip-specific documentation for more details.
device | Pointer to device descriptor of the UART device. |
buffer | Pointer to data buffer. |
size | Size of data to copy in bytes. |
callback | Event task used to notify the end of transfer. See the documentation of pi_task_t for more details. |
0 | If operation is successfull. |
ERRNO | An error code otherwise. |
int pi_uart_write_byte | ( | struct pi_device * | device, |
uint8_t * | byte | ||
) |
This writes a byte to the specified UART. The caller is blocked until the transfer is finished.
device | Pointer to device descriptor of the UART device. |
byte | Pointer to data buffer. |
0 | If operation is successfull. |
ERRNO | An error code otherwise. |
int pi_uart_write_byte_async | ( | struct pi_device * | device, |
uint8_t * | byte, | ||
pi_task_t * | callback | ||
) |
This writes a byte to the specified UART asynchronously. A task must be specified in order to specify how the caller should be notified when the transfer is finished.
device | Pointer to device descriptor of the UART device. |
byte | Pointer to data buffer. |
callback | Event task used to notify the end of transfer. See the documentation of pi_task_t for more details. |
0 | If operation is successfull. |
ERRNO | An error code otherwise. |
int pi_uart_write_timeout | ( | struct pi_device * | device, |
void * | buffer, | ||
uint32_t | size, | ||
uint32_t | timeout_us | ||
) |
This function is the same as pi_uart_write(), with timeout feat enabled. This timeout value is used to abort/cancel a transfer when timeout is reached.
device | Pointer to device descriptor of the UART device. |
buffer | Pointer to data buffer. |
size | Size of data to copy in bytes. |
timeout_us | Timeout value in us. |
0 | If operation is successfull. |
ERRNO | An error code otherwise. |