FreeRTOS:
Common I/O
AWS IoT Common I/O library
|
Return to main page ↑ |
Data Structures | |
struct | IotUARTConfig_t |
Configuration parameters for the UART. More... | |
Macros | |
#define | IOT_UART_BAUD_RATE_DEFAULT ( 115200 ) |
The default baud rate for a given UART port. | |
#define | IOT_UART_SUCCESS ( 0 ) |
Error codes returned by every function module in UART HAL. More... | |
#define | IOT_UART_INVALID_VALUE ( 1 ) |
#define | IOT_UART_WRITE_FAILED ( 2 ) |
#define | IOT_UART_READ_FAILED ( 3 ) |
#define | IOT_UART_BUSY ( 4 ) |
#define | IOT_UART_NOTHING_TO_CANCEL ( 5 ) |
#define | IOT_UART_FUNCTION_NOT_SUPPORTED ( 6 ) |
Typedefs | |
typedef void(* | IotUARTCallback_t) (IotUARTOperationStatus_t xStatus, void *pvUserContext) |
The callback function for completion of UART operation. More... | |
typedef struct IotUARTDescriptor_t * | IotUARTHandle_t |
IotUARTHandle_t is the handle type returned by calling iot_uart_open(). This is initialized in open and returned to caller. The caller must pass this pointer to the rest of APIs. | |
Enumerations | |
enum | IotUARTOperationStatus_t { eUartCompleted = IOT_UART_SUCCESS, eUartLastWriteFailed = IOT_UART_WRITE_FAILED, eUartLastReadFailed = IOT_UART_READ_FAILED } |
UART read/write operation status values. More... | |
enum | IotUARTParity_t { eUartParityNone, eUartParityOdd, eUartParityEven } |
UART parity mode. More... | |
enum | IotUARTStopBits_t { eUartStopBitsOne, eUartStopBitsTwo } |
UART stop bits. More... | |
enum | IotUARTIoctlRequest_t { eUartSetConfig, eUartGetConfig, eGetTxNoOfbytes, eGetRxNoOfbytes } |
Ioctl requests for UART HAL. More... | |
Functions | |
IotUARTHandle_t | iot_uart_open (int32_t lUartInstance) |
Initializes the UART peripheral of the board. More... | |
void | iot_uart_set_callback (IotUARTHandle_t const pxUartPeripheral, IotUARTCallback_t xCallback, void *pvUserContext) |
Sets the application callback to be called on completion of an operation. More... | |
int32_t | iot_uart_read_sync (IotUARTHandle_t const pxUartPeripheral, uint8_t *const pvBuffer, size_t xBytes) |
Starts receiving the data from UART synchronously. More... | |
int32_t | iot_uart_write_sync (IotUARTHandle_t const pxUartPeripheral, uint8_t *const pvBuffer, size_t xBytes) |
Starts the transmission of data from UART synchronously. More... | |
int32_t | iot_uart_read_async (IotUARTHandle_t const pxUartPeripheral, uint8_t *const pvBuffer, size_t xBytes) |
Starts receiving the data from UART asynchronously. More... | |
int32_t | iot_uart_write_async (IotUARTHandle_t const pxUartPeripheral, uint8_t *const pvBuffer, size_t xBytes) |
Starts the transmission of data from UART asynchronously. More... | |
int32_t | iot_uart_ioctl (IotUARTHandle_t const pxUartPeripheral, IotUARTIoctlRequest_t xUartRequest, void *const pvBuffer) |
Configures the UART port with user configuration. More... | |
int32_t | iot_uart_cancel (IotUARTHandle_t const pxUartPeripheral) |
Aborts the operation on the UART port if any underlying driver allows cancellation of the operation. More... | |
int32_t | iot_uart_close (IotUARTHandle_t const pxUartPeripheral) |
Stops the operation and de-initializes the UART peripheral. More... | |
#define IOT_UART_SUCCESS ( 0 ) |
Error codes returned by every function module in UART HAL.
UART operation completed successfully.
#define IOT_UART_INVALID_VALUE ( 1 ) |
At least one parameter is invalid.
#define IOT_UART_WRITE_FAILED ( 2 ) |
UART driver returns error when performing write operation.
#define IOT_UART_READ_FAILED ( 3 ) |
UART driver returns error when performing read operation.
#define IOT_UART_BUSY ( 4 ) |
UART bus is busy at current time.
#define IOT_UART_NOTHING_TO_CANCEL ( 5 ) |
No ongoing operation when cancel is performed.
#define IOT_UART_FUNCTION_NOT_SUPPORTED ( 6 ) |
UART operation is not supported.
typedef void( * IotUARTCallback_t) (IotUARTOperationStatus_t xStatus, void *pvUserContext) |
The callback function for completion of UART operation.
[out] | xStatus | UART asynchronous operation status. |
[in] | pvUserContext | User Context passed when setting the callback. This is not used or modified by the driver. The context is provided by the caller when setting the callback, and is passed back to the caller in the callback. |
enum IotUARTParity_t |
enum IotUARTStopBits_t |
IotUARTHandle_t iot_uart_open | ( | int32_t | lUartInstance | ) |
Initializes the UART peripheral of the board.
The application should call this function to initialize the desired UART port.
[in] | lUartInstance | The instance of the UART port to initialize. |
Example
void iot_uart_set_callback | ( | IotUARTHandle_t const | pxUartPeripheral, |
IotUARTCallback_t | xCallback, | ||
void * | pvUserContext | ||
) |
Sets the application callback to be called on completion of an operation.
The callback is guaranteed to be invoked when the current asynchronous operation completes, either successful or failed. This simply provides a notification mechanism to user's application. It has no impact if the callback is not set.
[in] | pxUartPeripheral | The peripheral handle returned in the open() call. |
[in] | xCallback | The callback function to be called on completion of transaction (This can be NULL). |
[in] | pvUserContext | The user context to be passed back when callback is called (This can be NULL). |
int32_t iot_uart_read_sync | ( | IotUARTHandle_t const | pxUartPeripheral, |
uint8_t *const | pvBuffer, | ||
size_t | xBytes | ||
) |
Starts receiving the data from UART synchronously.
This function attempts to read certain number of bytes from transmitter device to a pre-allocated buffer, in synchronous way. Partial read might happen, e.g. no more data is available. And the number of bytes that have been actually read can be obtained by calling iot_uart_ioctl.
[in] | pxUartPeripheral | The peripheral handle returned in the open() call. |
[out] | pvBuffer | The buffer to store the received data. |
[in] | xBytes | The number of bytes to read. |
int32_t iot_uart_write_sync | ( | IotUARTHandle_t const | pxUartPeripheral, |
uint8_t *const | pvBuffer, | ||
size_t | xBytes | ||
) |
Starts the transmission of data from UART synchronously.
This function attempts to write certain number of bytes from a pre-allocated buffer to a receiver device, in synchronous way. Partial write might happen, e.g. receiver device unable to receive more data. And the number of bytes that have been actually written can be obtained by calling iot_uart_ioctl.
[in] | pxUartPeripheral | The peripheral handle returned in the open() call. |
[in] | pvBuffer | The buffer with data to transmit. |
[in] | xBytes | The number of bytes to send. |
int32_t iot_uart_read_async | ( | IotUARTHandle_t const | pxUartPeripheral, |
uint8_t *const | pvBuffer, | ||
size_t | xBytes | ||
) |
Starts receiving the data from UART asynchronously.
This function attempts to read certain number of bytes from a pre-allocated buffer, in asynchronous way. It returns immediately when the operation is started and the status can be check by calling iot_uart_ioctl. Once the operation completes, successful or not, the user callback will be invoked.
Partial read might happen. And the number of bytes that have been actually read can be obtained by calling iot_uart_ioctl.
[in] | pxUartPeripheral | The peripheral handle returned in the open() call. |
[out] | pvBuffer | The buffer to store the received data. |
[in] | xBytes | The number of bytes to read. |
int32_t iot_uart_write_async | ( | IotUARTHandle_t const | pxUartPeripheral, |
uint8_t *const | pvBuffer, | ||
size_t | xBytes | ||
) |
Starts the transmission of data from UART asynchronously.
This function attempts to write certain number of bytes from a pre-allocated buffer to a receiver device, in asynchronous way. It returns immediately when the operation is started and the status can be check by calling iot_uart_ioctl. Once the operation completes, successful or not, the user callback will be invoked.
Partial write might happen. And the number of bytes that have been actually written can be obtained by calling iot_uart_ioctl.
[in] | pxUartPeripheral | The peripheral handle returned in the open() call. |
[in] | pvBuffer | The buffer with data to transmit. |
[in] | xBytes | The number of bytes to send. |
int32_t iot_uart_ioctl | ( | IotUARTHandle_t const | pxUartPeripheral, |
IotUARTIoctlRequest_t | xUartRequest, | ||
void *const | pvBuffer | ||
) |
Configures the UART port with user configuration.
[in] | pxUartPeripheral | The peripheral handle returned in the open() call. |
[in] | xUartRequest | The configuration request. Should be one of the values from IotUARTIoctlRequest_t. |
[in,out] | pvBuffer | The configuration values for the UART port. |
int32_t iot_uart_cancel | ( | IotUARTHandle_t const | pxUartPeripheral | ) |
Aborts the operation on the UART port if any underlying driver allows cancellation of the operation.
The application should call this function to stop the ongoing operation.
[in] | pxUartPeripheral | The peripheral handle returned in the open() call. |
int32_t iot_uart_close | ( | IotUARTHandle_t const | pxUartPeripheral | ) |
Stops the operation and de-initializes the UART peripheral.
[in] | pxUartPeripheral | The peripheral handle returned in the open() call. |