Classes | Macros | Typedefs | Enumerations | Functions
hal_uart.h File Reference

Header file containing functions prototypes of UART HAL library. More...

`#include "ll_uart.h"`
`#include "hal_def.h"`
`#include "hal_dma.h"`

Go to the source code of this file.

## Classes
struct | _uart_init
| UART init structure definition. More...
struct | _uart_handle
| UART handle Structure definition. More...
struct | _hal_uart_callback
| HAL_UART Callback function definition. More...

## Macros
#define | UART_TXFIFO_SIZE 16U
#define | UART_RXFIFO_SIZE 16U
#define | HAL_UART_ERROR_NONE (0x00000000U)
#define | HAL_UART_ERROR_PE LL_UART_LSR_PE
#define | HAL_UART_ERROR_FE LL_UART_LSR_FE
#define | HAL_UART_ERROR_OE LL_UART_LSR_OE
#define | HAL_UART_ERROR_BI LL_UART_LSR_BI
#define | HAL_UART_ERROR_DMA (0x00000100U)
#define | HAL_UART_ERROR_BUSY (0x00000200U)
#define | HAL_UART_ERROR_INVALID_PARAM (0x00000400U)
#define | UART_DATABITS_5 LL_UART_DATABITS_5B
#define | UART_DATABITS_6 LL_UART_DATABITS_6B
#define | UART_DATABITS_7 LL_UART_DATABITS_7B
#define | UART_DATABITS_8 LL_UART_DATABITS_8B
#define | UART_STOPBITS_1 LL_UART_STOPBITS_1
#define | UART_STOPBITS_1_5 LL_UART_STOPBITS_1_5
#define | UART_STOPBITS_2 LL_UART_STOPBITS_2
#define | UART_PARITY_NONE LL_UART_PARITY_NONE
#define | UART_PARITY_ODD LL_UART_PARITY_ODD
#define | UART_PARITY_EVEN LL_UART_PARITY_EVEN
#define | UART_PARITY_SP0 LL_UART_PARITY_SP0
#define | UART_PARITY_SP1 LL_UART_PARITY_SP1
#define | UART_HWCONTROL_NONE LL_UART_HWCONTROL_NONE
#define | UART_HWCONTROL_RTS_CTS LL_UART_HWCONTROL_RTS_CTS
#define | UART_RECEIVER_TIMEOUT_DISABLE (0x00000000U)
#define | UART_RECEIVER_TIMEOUT_ENABLE (0x00000001U)
#define | UART_IT_MS LL_UART_IER_MS
#define | UART_IT_RLS LL_UART_IER_RLS
#define | UART_IT_THRE LL_UART_IER_THRE
#define | UART_IT_RDA LL_UART_IER_RDA
#define | UART_RXDATA_FLUSH_REQUEST UART_SRR_RFR
#define | UART_TXDATA_FLUSH_REQUEST UART_SRR_XFR
#define | UART_TXRXDATA_FLUSH_REQUEST (UART_SRR_XFR | UART_SRR_RFR)
#define | UART_IT_MASK (0x008FU)
#define | UART_LINE_ERROR_MASK (LL_UART_LSR_PE | LL_UART_LSR_OE | LL_UART_LSR_FE | LL_UART_LSR_BI)
#define | UART_RETENTION_LENGTH ((uint32_t)8)
#define | HAL_UART_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000)
#define | __HAL_UART_RESET_HANDLE_STATE(__HANDLE__)
| Reset UART handle states. More...
#define | __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__)
| Enable the specified UART interrupt. More...
#define | __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__)
| Disable the specified UART interrupt. More...
#define | __HAL_UART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->p_instance->SRR = (__REQ__))
| Flush the UART FIFO and treat FIFO as empty. More...
#define | IS_UART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 921600U)
| Check if UART Baudrate is valid. More...
#define | IS_UART_STOPBITS(__STOPBITS__)
| Check if UART frame number of stop bits is valid. More...
#define | IS_UART_DATABITS(__DATABITS__)
| Check if UART frame number of data bits is valid. More...
#define | IS_UART_PARITY(__PARITY__)
| Check if UART frame parity is valid. More...
#define | IS_UART_HARDWARE_FLOW_CONTROL(__CONTROL__)
| Check if UART hardware flow control is valid. More...
#define | UART_DEFAULT_CONFIG
| Default configuartion for initializing structure. More...

## Typedefs
typedef struct _uart_init | uart_init_t
| UART init structure definition. More...
typedef struct _uart_handle | uart_handle_t
| UART handle Structure definition. More...
typedef struct _hal_uart_callback | hal_uart_callback_t
| HAL_UART Callback function definition. More...

## Enumerations
enum | hal_uart_state_t { HAL_UART_STATE_RESET = 0x00U, HAL_UART_STATE_READY = 0x10U, HAL_UART_STATE_BUSY = 0x14U, HAL_UART_STATE_BUSY_TX = 0x11U, HAL_UART_STATE_BUSY_RX = 0x12U, HAL_UART_STATE_BUSY_TXRX = 0x13U, HAL_UART_STATE_TIMEOUT = 0x30U, HAL_UART_STATE_ERROR = 0x70U }
| HAL UART State enumerations definition. More...

## Functions
hal_status_t | hal_uart_init (uart_handle_t *p_uart)
| Initialize the UART according to the specified parameters in the uart_init_t and initialize the associated handle. More...
hal_status_t | hal_uart_deinit (uart_handle_t *p_uart)
| De-initialize the UART peripheral. More...
void | hal_uart_msp_init (uart_handle_t *p_uart)
| Initialize the UART MSP. More...
void | hal_uart_msp_deinit (uart_handle_t *p_uart)
| De-initialize the UART MSP. More...
hal_status_t | hal_uart_transmit (uart_handle_t *p_uart, uint8_t *p_data, uint16_t size, uint32_t timeout)
| Send an amount of data in blocking mode. More...
hal_status_t | hal_uart_receive (uart_handle_t *p_uart, uint8_t *p_data, uint16_t size, uint32_t timeout)
| Receive an amount of data in blocking mode. More...
hal_status_t | hal_uart_transmit_it (uart_handle_t *p_uart, uint8_t *p_data, uint16_t size)
| Send an amount of data in interrupt mode. More...
hal_status_t | hal_uart_receive_it (uart_handle_t *p_uart, uint8_t *p_data, uint16_t size)
| Receive an amount of data in interrupt mode. More...
hal_status_t | hal_uart_transmit_dma (uart_handle_t *p_uart, uint8_t *p_data, uint16_t size)
| Send an amount of data in DMA mode. More...
hal_status_t | hal_uart_receive_dma (uart_handle_t *p_uart, uint8_t *p_data, uint16_t size)
| Receive an amount of data in DMA mode. More...
hal_status_t | hal_uart_dma_pause (uart_handle_t *p_uart)
| Pause the DMA Transfer. More...
hal_status_t | hal_uart_dma_resume (uart_handle_t *p_uart)
| Resume the DMA Transfer. More...
hal_status_t | hal_uart_dma_stop (uart_handle_t *p_uart)
| Stop the DMA Transfer. More...
hal_status_t | hal_uart_abort (uart_handle_t *p_uart)
| Abort ongoing transfers (blocking mode). More...
hal_status_t | hal_uart_abort_transmit (uart_handle_t *p_uart)
| Abort ongoing Transmit transfer (blocking mode). More...
hal_status_t | hal_uart_abort_receive (uart_handle_t *p_uart)
| Abort ongoing Receive transfer (blocking mode). More...
hal_status_t | hal_uart_abort_it (uart_handle_t *p_uart)
| Abort ongoing transfers (Interrupt mode). More...
hal_status_t | hal_uart_abort_transmit_it (uart_handle_t *p_uart)
| Abort ongoing Transmit transfer (Interrupt mode). More...
hal_status_t | hal_uart_abort_receive_it (uart_handle_t *p_uart)
| Abort ongoing Receive transfer (Interrupt mode). More...
void | hal_uart_irq_handler (uart_handle_t *p_uart)
| Handle UART interrupt request. More...
void | hal_uart_tx_cplt_callback (uart_handle_t *p_uart)
| Tx Transfer completed callback. More...
void | hal_uart_rx_cplt_callback (uart_handle_t *p_uart)
| Rx Transfer completed callback. More...
void | hal_uart_error_callback (uart_handle_t *p_uart)
| UART error callback. More...
void | hal_uart_abort_cplt_callback (uart_handle_t *p_uart)
| UART Abort Complete callback. More...
void | hal_uart_abort_tx_cplt_callback (uart_handle_t *p_uart)
| UART Abort Tansmit Complete callback. More...
void | hal_uart_abort_rx_cplt_callback (uart_handle_t *p_uart)
| UART Abort Receive Complete callback. More...
hal_uart_state_t | hal_uart_get_state (uart_handle_t *p_uart)
| Return the UART handle state. More...
uint32_t | hal_uart_get_error (uart_handle_t *p_uart)
| Return the UART handle error code. More...
void | hal_uart_suspend_reg (uart_handle_t *p_uart)
| Suspend some registers related to UART configuration before sleep. More...
void | hal_uart_resume_reg (uart_handle_t *p_uart)
| Restore some registers related to UART configuration after sleep. This function must be used in conjunction with the hal_uart_suspend_reg(). More...
hal_pm_status_t | hal_pm_uart_suspend (uart_handle_t *p_uart)
| Suspend the specified UART. More...
void | hal_pm_uart_resume (uart_handle_t *p_uart)
| Resume the specified UART. More...

## Detailed Description

Header file containing functions prototypes of UART HAL library.

Author
  BLE Driver Team

Attention
  #####Copyright (c) 2019 GOODIX All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of GOODIX nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file hal_uart.h.