FreeRTOS: Common I/O
AWS IoT Common I/O library
Return to main page ↑
iot_uart.h
Go to the documentation of this file.
1 /*
2  * FreeRTOS Common IO V1.0.0
3  * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://aws.amazon.com/freertos
23  * http://www.FreeRTOS.org
24  */
25 
30 #ifndef _IOT_UART_H_
31 #define _IOT_UART_H_
32 
33 /* Standard includes. */
34 #include <stddef.h>
35 #include <stdint.h>
36 
45 #define IOT_UART_BAUD_RATE_DEFAULT ( 115200 )
46 
50 #define IOT_UART_SUCCESS ( 0 )
51 #define IOT_UART_INVALID_VALUE ( 1 )
52 #define IOT_UART_WRITE_FAILED ( 2 )
53 #define IOT_UART_READ_FAILED ( 3 )
54 #define IOT_UART_BUSY ( 4 )
55 #define IOT_UART_NOTHING_TO_CANCEL ( 5 )
56 #define IOT_UART_FUNCTION_NOT_SUPPORTED ( 6 )
61 typedef enum
62 {
67 
71 typedef enum
72 {
77 
81 typedef enum
82 {
86 
96 typedef void ( * IotUARTCallback_t )( IotUARTOperationStatus_t xStatus,
97  void * pvUserContext );
98 
99 
103 struct IotUARTDescriptor_t;
104 
110 typedef struct IotUARTDescriptor_t * IotUARTHandle_t;
111 
115 typedef enum
116 {
117  eUartSetConfig,
122 
129 typedef struct
130 {
131  uint32_t ulBaudrate;
134  uint8_t ucWordlength;
135  uint8_t ucFlowControl;
137 
187 IotUARTHandle_t iot_uart_open( int32_t lUartInstance );
188 
204 void iot_uart_set_callback( IotUARTHandle_t const pxUartPeripheral,
205  IotUARTCallback_t xCallback,
206  void * pvUserContext );
207 
235 int32_t iot_uart_read_sync( IotUARTHandle_t const pxUartPeripheral,
236  uint8_t * const pvBuffer,
237  size_t xBytes );
238 
262 int32_t iot_uart_write_sync( IotUARTHandle_t const pxUartPeripheral,
263  uint8_t * const pvBuffer,
264  size_t xBytes );
265 
293 int32_t iot_uart_read_async( IotUARTHandle_t const pxUartPeripheral,
294  uint8_t * const pvBuffer,
295  size_t xBytes );
296 
324 int32_t iot_uart_write_async( IotUARTHandle_t const pxUartPeripheral,
325  uint8_t * const pvBuffer,
326  size_t xBytes );
327 
369 int32_t iot_uart_ioctl( IotUARTHandle_t const pxUartPeripheral,
370  IotUARTIoctlRequest_t xUartRequest,
371  void * const pvBuffer );
372 
389 int32_t iot_uart_cancel( IotUARTHandle_t const pxUartPeripheral );
390 
403 int32_t iot_uart_close( IotUARTHandle_t const pxUartPeripheral );
404 
405 
409 /* end of group IOT_UART */
410 #endif /* _IOT_UART_H_ */
Definition: iot_uart.h:84
int32_t iot_uart_read_async(IotUARTHandle_t const pxUartPeripheral, uint8_t *const pvBuffer, size_t xBytes)
Starts receiving the data from UART asynchronously.
Definition: iot_uart.h:75
Definition: iot_uart.h:65
uint8_t ucWordlength
Definition: iot_uart.h:134
IotUARTParity_t
UART parity mode.
Definition: iot_uart.h:71
Definition: iot_uart.h:73
struct IotUARTDescriptor_t * IotUARTHandle_t
IotUARTHandle_t is the handle type returned by calling iot_uart_open(). This is initialized in open a...
Definition: iot_uart.h:110
Definition: iot_uart.h:118
void(* IotUARTCallback_t)(IotUARTOperationStatus_t xStatus, void *pvUserContext)
The callback function for completion of UART operation.
Definition: iot_uart.h:96
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...
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.
uint32_t ulBaudrate
Definition: iot_uart.h:131
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.
int32_t iot_uart_ioctl(IotUARTHandle_t const pxUartPeripheral, IotUARTIoctlRequest_t xUartRequest, void *const pvBuffer)
Configures the UART port with user configuration.
IotUARTStopBits_t
UART stop bits.
Definition: iot_uart.h:81
IotUARTHandle_t iot_uart_open(int32_t lUartInstance)
Initializes the UART peripheral of the board.
IotUARTOperationStatus_t
UART read/write operation status values.
Definition: iot_uart.h:61
int32_t iot_uart_read_sync(IotUARTHandle_t const pxUartPeripheral, uint8_t *const pvBuffer, size_t xBytes)
Starts receiving the data from UART synchronously.
Definition: iot_uart.h:120
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.
IotUARTIoctlRequest_t
Ioctl requests for UART HAL.
Definition: iot_uart.h:115
IotUARTParity_t xParity
Definition: iot_uart.h:132
uint8_t ucFlowControl
Definition: iot_uart.h:135
Definition: iot_uart.h:83
#define IOT_UART_READ_FAILED
Definition: iot_uart.h:53
Configuration parameters for the UART.
Definition: iot_uart.h:129
Definition: iot_uart.h:74
Definition: iot_uart.h:119
#define IOT_UART_SUCCESS
Error codes returned by every function module in UART HAL.
Definition: iot_uart.h:50
IotUARTStopBits_t xStopbits
Definition: iot_uart.h:133
Definition: iot_uart.h:63
int32_t iot_uart_close(IotUARTHandle_t const pxUartPeripheral)
Stops the operation and de-initializes the UART peripheral.
Definition: iot_uart.h:64
#define IOT_UART_WRITE_FAILED
Definition: iot_uart.h:52