Common IO - basic v1.0.0
Common IO - basic v1.0.0 Library
 
Loading...
Searching...
No Matches
iot_uart.h
Go to the documentation of this file.
1/*
2 * Common IO - basic V1.0.0
3 * Copyright (C) 2020 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 )
61typedef enum
62{
68
72typedef enum
73{
78
82typedef enum
83{
87
97typedef void ( * IotUARTCallback_t )( IotUARTOperationStatus_t xStatus,
98 void * pvUserContext );
99
100
104struct IotUARTDescriptor;
105
111typedef struct IotUARTDescriptor * IotUARTHandle_t;
112
116typedef enum
117{
118 eUartSetConfig,
123
130typedef struct
131{
132 uint32_t ulBaudrate;
135 uint8_t ucWordlength;
138
188IotUARTHandle_t iot_uart_open( int32_t lUartInstance );
189
205void iot_uart_set_callback( IotUARTHandle_t const pxUartPeripheral,
206 IotUARTCallback_t xCallback,
207 void * pvUserContext );
208
236int32_t iot_uart_read_sync( IotUARTHandle_t const pxUartPeripheral,
237 uint8_t * const pvBuffer,
238 size_t xBytes );
239
263int32_t iot_uart_write_sync( IotUARTHandle_t const pxUartPeripheral,
264 uint8_t * const pvBuffer,
265 size_t xBytes );
266
294int32_t iot_uart_read_async( IotUARTHandle_t const pxUartPeripheral,
295 uint8_t * const pvBuffer,
296 size_t xBytes );
297
325int32_t iot_uart_write_async( IotUARTHandle_t const pxUartPeripheral,
326 uint8_t * const pvBuffer,
327 size_t xBytes );
328
370int32_t iot_uart_ioctl( IotUARTHandle_t const pxUartPeripheral,
371 IotUARTIoctlRequest_t xUartRequest,
372 void * const pvBuffer );
373
390int32_t iot_uart_cancel( IotUARTHandle_t const pxUartPeripheral );
391
404int32_t iot_uart_close( IotUARTHandle_t const pxUartPeripheral );
405
406
410/* end of group IOT_UART */
411#endif /* _IOT_UART_H_ */
void(* IotUARTCallback_t)(IotUARTOperationStatus_t xStatus, void *pvUserContext)
The callback function for completion of UART operation.
Definition: iot_uart.h:97
int32_t iot_uart_read_sync(IotUARTHandle_t const pxUartPeripheral, uint8_t *const pvBuffer, size_t xBytes)
Starts receiving the data from UART synchronously.
IotUARTOperationStatus_t
UART read/write operation status values.
Definition: iot_uart.h:62
IotUARTHandle_t iot_uart_open(int32_t lUartInstance)
Initializes the UART peripheral of the board.
int32_t iot_uart_read_async(IotUARTHandle_t const pxUartPeripheral, uint8_t *const pvBuffer, size_t xBytes)
Starts receiving the data from UART asynchronously.
IotUARTIoctlRequest_t
Ioctl requests for UART HAL.
Definition: iot_uart.h:117
IotUARTStopBits_t
UART stop bits.
Definition: iot_uart.h:83
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.
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.
IotUARTParity_t
UART parity mode.
Definition: iot_uart.h:73
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.
struct IotUARTDescriptor * IotUARTHandle_t
IotUARTHandle_t is the handle type returned by calling iot_uart_open(). This is initialized in open a...
Definition: iot_uart.h:111
int32_t iot_uart_close(IotUARTHandle_t const pxUartPeripheral)
Stops the operation and de-initializes the UART peripheral.
@ eUartLastReadFailed
Definition: iot_uart.h:66
@ eUartLastWriteFailed
Definition: iot_uart.h:65
@ eUartReadCompleted
Definition: iot_uart.h:64
@ eUartWriteCompleted
Definition: iot_uart.h:63
@ eGetRxNoOfbytes
Definition: iot_uart.h:121
@ eUartGetConfig
Definition: iot_uart.h:119
@ eGetTxNoOfbytes
Definition: iot_uart.h:120
@ eUartStopBitsTwo
Definition: iot_uart.h:85
@ eUartStopBitsOne
Definition: iot_uart.h:84
@ eUartParityEven
Definition: iot_uart.h:76
@ eUartParityNone
Definition: iot_uart.h:74
@ eUartParityOdd
Definition: iot_uart.h:75
Configuration parameters for the UART.
Definition: iot_uart.h:131
IotUARTStopBits_t xStopbits
Definition: iot_uart.h:134
uint32_t ulBaudrate
Definition: iot_uart.h:132
uint8_t ucWordlength
Definition: iot_uart.h:135
uint8_t ucFlowControl
Definition: iot_uart.h:136
IotUARTParity_t xParity
Definition: iot_uart.h:133