Universal Asynchronous Receiver & Transmitter.
More...
|
enum | uart_result_t {
UART_RESULT_OK
,
UART_RESULT_INVALID
,
UART_RESULT_UNSUPPORTED
,
UART_RESULT_OVERRUN_ERROR
,
UART_RESULT_UNDERRUN_ERROR
,
UART_RESULT_FRAMING_ERROR
,
UART_RESULT_PARITY_ERROR
,
UART_RESULT_TIMEOUT
,
UART_RESULT_IDLE
,
UART_RESULT_BUSY
,
UART_RESULT_ERR
,
TOTAL_UART_RESULT
} |
|
enum | uart_status_t {
UART_STATUS_UNKNOWN
,
UART_STATUS_OK
,
UART_STATUS_BUSY
,
UART_STATUS_STOP
,
UART_STATUS_SENDING
,
UART_STATUS_RECEIVING
,
UART_STATUS_ERR
,
TOTAL_UART_STATUS
} |
|
enum | uart_mode_t {
UART_MODE_ASYNCHRONOUS
,
UART_MODE_SYNCHRONOUS
,
TOTAL_UART_MODE
} |
|
enum | uart_baudrate_t {
UART_BAUDRATE_9600 = 9600U
,
UART_BAUDRATE_19200 = 19200U
,
UART_BAUDRATE_38400 = 38400U
,
UART_BAUDRATE_57600 = 57600U
,
UART_BAUDRATE_115200 = 115200U
,
UART_BAUDRATE_576000 = 576000U
,
UART_BAUDRATE_921600 = 921600U
,
TOTAL_UART_BAUDRATE
} |
|
enum | uart_baudrate_type_t {
UART_BAUDRATE_TYPE_MANUAL
,
UART_BAUDRATE_TYPE_AUTO
,
TOTAL_UART_BAUDRATE_TYPE
} |
|
enum | uart_data_bits_t {
UART_DATA_BITS_8
,
UART_DATA_BITS_9
,
TOTAL_UART_DATA_BITS
} |
|
enum | uart_stop_bits_t {
UART_STOP_BITS_1
,
UART_STOP_BITS_2
,
TOTAL_UART_STOP_BITS
} |
|
enum | uart_parity_t {
UART_PARITY_EVEN
,
UART_PARITY_ODD
,
UART_PARITY_NONE
,
TOTAL_UART_PARITY
} |
|
Universal Asynchronous Receiver & Transmitter.
◆ uart_baudrate_t
#include <uart/public_inc/hal_uart.h>
Enumerator |
---|
UART_BAUDRATE_9600 | |
UART_BAUDRATE_19200 | |
UART_BAUDRATE_38400 | |
UART_BAUDRATE_57600 | |
UART_BAUDRATE_115200 | |
UART_BAUDRATE_576000 | |
UART_BAUDRATE_921600 | |
TOTAL_UART_BAUDRATE | |
◆ uart_baudrate_type_t
◆ uart_data_bits_t
◆ uart_mode_t
◆ uart_parity_t
◆ uart_result_t
#include <uart/public_inc/hal_uart.h>
Enumerator |
---|
UART_RESULT_OK | No error.
|
UART_RESULT_INVALID | Operation invalid.
|
UART_RESULT_UNSUPPORTED | Operation not supported.
|
UART_RESULT_OVERRUN_ERROR | Overrun occurred.
|
UART_RESULT_UNDERRUN_ERROR | Underrun occured.
|
UART_RESULT_FRAMING_ERROR | Message framing error.
|
UART_RESULT_PARITY_ERROR | Message paritiy error.
|
UART_RESULT_TIMEOUT | Operation timeout.
|
UART_RESULT_IDLE | Bus idle.
|
UART_RESULT_BUSY | Bus busy.
|
UART_RESULT_ERR | Error occurred.
|
TOTAL_UART_RESULT | |
◆ uart_status_t
#include <uart/public_inc/hal_uart.h>
Enumerator |
---|
UART_STATUS_UNKNOWN | Unknown bus status.
|
UART_STATUS_OK | No error.
|
UART_STATUS_BUSY | Bus busy.
|
UART_STATUS_STOP | Channel stopped.
|
UART_STATUS_SENDING | Channel sending.
|
UART_STATUS_RECEIVING | Channel receiving.
|
UART_STATUS_ERR | Error occurred.
|
TOTAL_UART_STATUS | |
◆ uart_stop_bits_t
◆ hal_uart_get_status()
#include <uart/public_inc/hal_uart.h>
Get UART bus status.
uart_bus_status_t hal_uart_get_status(uart_handle_t *handle)
Get UART bus status.
Definition hal_uart.h:123
- Parameters
-
[in,out] | handle | UART handler |
- Returns
- UART channel bus status
◆ hal_uart_init()
#include <uart/public_inc/hal_uart.h>
Configure UART channel with specific attributes.
.tx_pin = 11U,
.cts_pin = 12U,
.rts_pin = 13U,
.baudrate = 115200U,
.low_power_enable = false,
.flow_control_enable = true
};
uart_result_t hal_uart_init(uart_handle_t *handle, const uart_channel_attr_t attr)
Configure UART channel with specific attributes.
uart_result_t
Definition hal_uart.h:39
@ UART_BAUDRATE_TYPE_MANUAL
Definition hal_uart.h:91
@ UART_PARITY_NONE
Definition hal_uart.h:117
@ UART_STOP_BITS_1
Definition hal_uart.h:107
@ UART_MODE_ASYNCHRONOUS
Definition hal_uart.h:70
Definition hal_uart.h:130
gpio_pin_t rx_pin
Definition hal_uart.h:131
Definition hal_uart.h:147
uint8_t channel
UART channel.
Definition hal_uart.h:148
- Parameters
-
[in,out] | handle | UART handler |
[in] | attr | UART channel attribute |
- Return values
-
UART_RESULT_OK | Success configure UART channel |
UART_RESULT_INVALID | Configuration attributes invalid |
UART_RESULT_UNSUPPORTED | Operation not supported |
UART_RESULT_ERR | Failed configure UART channel |
◆ hal_uart_mutex_give()
#include <uart/public_inc/hal_uart.h>
Release RTOS mutex for specified channel.
uart_result_t hal_uart_mutex_give(const uint8_t channel)
Release RTOS mutex for specified channel.
- Parameters
-
[in] | channel | UART channel's mutex to be released |
- Return values
-
UART_RESULT_OK | Success release mutex |
UART_RESULT_INVALID | Invalid channel |
UART_RESULT_UNSUPPORTED | Operation not supported |
UART_RESULT_ERR | Failed release mutex |
◆ hal_uart_mutex_take()
uart_result_t hal_uart_mutex_take |
( |
const uint8_t | channel, |
|
|
const uint32_t | timeout_ms ) |
#include <uart/public_inc/hal_uart.h>
Try acquire RTOS mutex for specified channel.
uart_result_t hal_uart_mutex_take(const uint8_t channel, const uint32_t timeout_ms)
Try acquire RTOS mutex for specified channel.
- Parameters
-
[in] | channel | UART channel's mutex to be locked |
[in] | timeout_ms | Mutex acquiring timeout in milliseconds |
- Return values
-
UART_RESULT_OK | Success acquire mutex |
UART_RESULT_INVALID | Invalid channel |
UART_RESULT_UNSUPPORTED | Operation not supported |
UART_RESULT_ERR | Failed acquire mutex |
◆ hal_uart_read()
#include <uart/public_inc/hal_uart.h>
Read data from UART channel.
uint8_t rx_buffer[3] = {0U};
rx_buffer,
sizeof( rx_buffer ) );
uart_result_t hal_uart_read(uart_handle_t *handle, uint8_t *rx_buffer, const size_t len)
Read data from UART channel.
- Parameters
-
[in,out] | handle | UART handler |
[in] | rx_buffer | Receiving buffer |
[in] | len | Buffer size |
- Return values
-
UART_RESULT_OK | Success read UART data |
UART_RESULT_OVERRUN_ERROR | UART overrun |
UART_RESULT_FRAMING_ERROR | UART frame error |
UART_RESULT_PARITY_ERROR | UART parity error |
UART_RESULT_ERR | Failed read UART data |
◆ hal_uart_stop()
#include <uart/public_inc/hal_uart.h>
Stop UART operation.
uart_result_t hal_uart_stop(uart_handle_t *handle)
Stop UART operation.
- Parameters
-
[in,out] | handle | UART handler |
- Return values
-
UART_RESULT_OK | Success stop UART operation |
UART_RESULT_UNSUPPORTED | Operation not supported |
UART_RESULT_ERR | Failed stop UART operation |
◆ hal_uart_write()
#include <uart/public_inc/hal_uart.h>
Write data to UART channel.
uint8_t tx_buffer[] = { 10U, 20U, 30U };
tx_buffer,
sizeof( tx_buffer ) );
uart_result_t hal_uart_write(uart_handle_t *handle, const uint8_t *tx_buffer, const size_t len)
Write data to UART channel.
- Parameters
-
[in,out] | handle | UART handler |
[in] | tx_buffer | Buffer to be transmitted |
[in] | len | Buffer size |
- Return values
-
UART_RESULT_OK | Success write UART data |
UART_RESULT_UNDERRUN_ERROR | UART underrun |
UART_RESULT_FRAMING_ERROR | UART frame error |
UART_RESULT_PARITY_ERROR | UART parity error |
UART_RESULT_ERR | Failed write UART data |