gr55xx_hal_uart.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file gr55xx_hal_uart.h
5  * @author BLE Driver Team
6  * @brief Header file containing functions prototypes of UART HAL library.
7  *
8  ****************************************************************************************
9  * @attention
10  #####Copyright (c) 2019 GOODIX
11  All rights reserved.
12 
13  Redistribution and use in source and binary forms, with or without
14  modification, are permitted provided that the following conditions are met:
15  * Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17  * Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20  * Neither the name of GOODIX nor the names of its contributors may be used
21  to endorse or promote products derived from this software without
22  specific prior written permission.
23 
24  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  POSSIBILITY OF SUCH DAMAGE.
35  ****************************************************************************************
36  */
37 
38 /** @addtogroup PERIPHERAL Peripheral Driver
39  * @{
40  */
41 
42 /** @addtogroup HAL_DRIVER HAL Driver
43  * @{
44  */
45 
46 /** @defgroup HAL_UART UART
47  * @brief UART HAL module driver.
48  * @{
49  */
50 
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_HAL_UART_H__
53 #define __GR55xx_HAL_UART_H__
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx_ll_uart.h"
61 #include "gr55xx_hal_def.h"
62 
63 /* Exported types ------------------------------------------------------------*/
64 /** @addtogroup HAL_UART_ENUMERATIONS Enumerations
65  * @{
66  */
67 
68 /** @defgroup HAL_UART_state HAL UART state
69  * @{
70  */
71 
72 /**
73  * @brief HAL UART State enumerations definition
74  * @note HAL UART State value is a combination of 2 different substates: gState and RxState.
75  */
76 typedef enum
77 {
78  HAL_UART_STATE_RESET = 0x00U, /**< Peripheral is not initialized.
79  Value is allowed for gState and RxState */
80 
81  HAL_UART_STATE_READY = 0x10U, /**< Peripheral initialized and ready for use.
82  Value is allowed for gState and RxState */
83 
84  HAL_UART_STATE_BUSY = 0x14U, /**< An internal process is ongoing.
85  Value is allowed for gState only */
86 
87  HAL_UART_STATE_BUSY_TX = 0x11U, /**< Data Transmission process is ongoing.
88  Value is allowed for gState only */
89 
90  HAL_UART_STATE_BUSY_RX = 0x12U, /**< Data Reception process is ongoing.
91  Value is allowed for RxState only */
92 
93  HAL_UART_STATE_BUSY_TXRX = 0x13U, /**< Data Transmission and Reception process is ongoing.
94  Value is allowed for gState only */
95 
96  HAL_UART_STATE_TIMEOUT = 0x30U, /**< Timeout state.
97  Value is allowed for gState only */
98 
99  HAL_UART_STATE_ERROR = 0x70U /**< Error.
100  Value is allowed for gState only */
101 
103 
104 /** @} */
105 
106 /** @} */
107 
108 /** @addtogroup HAL_UART_STRUCTURES Structures
109  * @{
110  */
111 
112 /** @defgroup UART_Configuration UART Configuration
113  * @{
114  */
115 
116 /**
117  * @brief UART init structure definition
118  */
119 typedef struct _uart_init
120 {
121  uint32_t baud_rate; /**< This member configures the UART communication baud rate. */
122 
123  uint32_t data_bits; /**< Specifies the number of data bits transmitted or received in a frame.
124  This parameter can be a value of @ref UART_Data_Bits. */
125 
126  uint32_t stop_bits; /**< Specifies the number of stop bits transmitted.
127  This parameter can be a value of @ref UART_Stop_Bits. */
128 
129  uint32_t parity; /**< Specifies the parity mode.
130  This parameter can be a value of @ref UART_Parity. */
131 
132  uint32_t hw_flow_ctrl; /**< Specifies whether the hardware flow control mode is enabled or disabled.
133  This parameter can be a value of @ref UART_Hardware_Flow_Control. */
134 
135  uint32_t rx_timeout_mode; /**< Specifies whether the receive timeout mode is enabled or disabled.
136  When rx_timeout_mode is enabled, character timeout interrupt will disable
137  current receive process after the data in RxFIFO is received, and call
138  hal_uart_rx_cplt_callback(). Note that the rx_timeout_mode only works
139  in interrupt mode.
140  This parameter can be a value of @ref UART_Receiver_TimeOut. */
141 
143 /** @} */
144 
145 /** @defgroup UART_handle UART handle
146  * @{
147  */
148 
149 /**
150  * @brief UART handle Structure definition
151  */
152 typedef struct _uart_handle
153 {
154  uart_regs_t *p_instance; /**< UART registers base address */
155 
156  uart_init_t init; /**< UART communication parameters */
157 
158  uint8_t *p_tx_buffer; /**< Pointer to UART Tx transfer Buffer */
159 
160  uint16_t tx_xfer_size; /**< UART Tx Transfer size */
161 
162  __IO uint16_t tx_xfer_count; /**< UART Tx Transfer Counter */
163 
164  uint8_t *p_rx_buffer; /**< Pointer to UART Rx transfer Buffer */
165 
166  uint16_t rx_xfer_size; /**< UART Rx Transfer size */
167 
168  __IO uint16_t rx_xfer_count; /**< UART Rx Transfer Counter */
169 
170  dma_handle_t *p_dmatx; /**< UART Tx DMA Handle parameters */
171 
172  dma_handle_t *p_dmarx; /**< UART Rx DMA Handle parameters */
173 
174  functional_state_t dma_tx_mode; /**< UART Tx DMA mode state */
175 
176  functional_state_t dma_rx_mode; /**< UART Rx DMA mode state */
177 
178  hal_lock_t lock; /**< Locking object */
179 
180  __IO hal_uart_state_t tx_state; /**< UART state information related to Tx operations.
181  This parameter can be a value of @ref hal_uart_state_t */
182 
183  __IO hal_uart_state_t rx_state; /**< UART state information related to Rx operations.
184  This parameter can be a value of @ref hal_uart_state_t */
185 
186  __IO uint32_t error_code; /**< UART Error code */
187 
188  uint32_t retention[8]; /**< UART important register information. */
190 /** @} */
191 
192 /** @} */
193 
194 /** @addtogroup HAL_UART_CALLBACK_STRUCTURES Callback Structures
195  * @{
196  */
197 
198 /** @defgroup HAL_UART_Callback Callback
199  * @{
200  */
201 
202 /**
203  * @brief HAL_UART Callback function definition
204  */
205 
206 typedef struct _hal_uart_callback
207 {
208  void (*uart_msp_init)(uart_handle_t *p_uart); /**< UART init MSP callback */
209  void (*uart_msp_deinit)(uart_handle_t *p_uart); /**< UART de-init MSP callback */
210  void (*uart_tx_cplt_callback)(uart_handle_t *p_uart); /**< UART tx transfer completed callback */
211  void (*uart_rx_cplt_callback)(uart_handle_t *p_uart); /**< UART rx transfer completed callback */
212  void (*uart_error_callback)(uart_handle_t *p_uart); /**< UART error callback */
213  void (*uart_abort_cplt_callback)(uart_handle_t *p_uart); /**< UART abort completed callback */
214  void (*uart_abort_tx_cplt_callback)(uart_handle_t *p_uart); /**< UART abort tansmit complete callback */
215  void (*uart_abort_rx_cplt_callback)(uart_handle_t *p_uart); /**< UART abort receive complete callback */
217 
218 /** @} */
219 
220 /** @} */
221 
222 /**
223  * @defgroup HAL_UART_MACRO Defines
224  * @{
225  */
226 
227 /* Exported constants --------------------------------------------------------*/
228 /** @defgroup UART_Exported_Constants UART Exported Constants
229  * @{
230  */
231 
232 /** @defgroup UART_Error_Code UART Error Code
233  * @{
234  */
235 #define HAL_UART_ERROR_NONE (0x00000000U) /**< No error */
236 #define HAL_UART_ERROR_PE LL_UART_LSR_PE /**< Parity error */
237 #define HAL_UART_ERROR_FE LL_UART_LSR_FE /**< frame error */
238 #define HAL_UART_ERROR_OE LL_UART_LSR_OE /**< Overrun error */
239 #define HAL_UART_ERROR_BI LL_UART_LSR_BI /**< Break dection error */
240 #define HAL_UART_ERROR_DMA (0x00000100U) /**< DMA transfer error */
241 #define HAL_UART_ERROR_BUSY (0x00000200U) /**< Busy Error */
242 /** @} */
243 
244 /** @defgroup UART_Data_Bits UART Number of Data Bits
245  * @{
246  */
247 #define UART_DATABITS_5 LL_UART_DATABITS_5B /**< UART frame with 5 data bits */
248 #define UART_DATABITS_6 LL_UART_DATABITS_6B /**< UART frame with 6 data bits */
249 #define UART_DATABITS_7 LL_UART_DATABITS_7B /**< UART frame with 7 data bits */
250 #define UART_DATABITS_8 LL_UART_DATABITS_8B /**< UART frame with 8 data bits */
251 /** @} */
252 
253 /** @defgroup UART_Stop_Bits UART Number of Stop Bits
254  * @{
255  */
256 #define UART_STOPBITS_1 LL_UART_STOPBITS_1 /**< UART frame with 1 stop bit */
257 #define UART_STOPBITS_1_5 LL_UART_STOPBITS_1_5 /**< UART frame with 1.5 stop bits */
258 #define UART_STOPBITS_2 LL_UART_STOPBITS_2 /**< UART frame with 2 stop bits */
259 /** @} */
260 
261 /** @defgroup UART_Parity UART Parity
262  * @{
263  */
264 #define UART_PARITY_NONE LL_UART_PARITY_NONE /**< No parity */
265 #define UART_PARITY_ODD LL_UART_PARITY_ODD /**< Odd parity */
266 #define UART_PARITY_EVEN LL_UART_PARITY_EVEN /**< Even parity */
267 #define UART_PARITY_SP0 LL_UART_PARITY_SP0 /**< Stick Parity 0 */
268 #define UART_PARITY_SP1 LL_UART_PARITY_SP1 /**< Stick Parity 1 */
269 /** @} */
270 
271 /** @defgroup UART_Hardware_Flow_Control UART Hardware Flow Control
272  * @{
273  */
274 #define UART_HWCONTROL_NONE LL_UART_HWCONTROL_NONE /**< No hardware control */
275 #define UART_HWCONTROL_RTS_CTS LL_UART_HWCONTROL_RTS_CTS /**< Auto RTS and CTS hardware flow control */
276 /** @} */
277 
278 /** @defgroup UART_Receiver_TimeOut UART Receiver TimeOut
279  * @{
280  */
281 #define UART_RECEIVER_TIMEOUT_DISABLE (0x00000000U) /**< UART receiver timeout disable */
282 #define UART_RECEIVER_TIMEOUT_ENABLE (0x00000001U) /**< UART receiver timeout enable */
283 /** @} */
284 
285 /** @defgroup UART_Interrupt_definition UART Interrupt_definition
286  * @{
287  */
288 #define UART_IT_MS LL_UART_IER_MS /**< Enable Modem Status Interrupt */
289 #define UART_IT_RLS LL_UART_IER_RLS /**< Enable Receiver Line Status Interrupt */
290 #define UART_IT_THRE LL_UART_IER_THRE /**< Enable Transmit Holding Register Empty Interrupt */
291 #define UART_IT_RDA LL_UART_IER_RDA /**< Enable Received Data Available Interrupt and Character Timeout Interrupt */
292 /** @} */
293 
294 /** @defgroup UART_Request_Parameters UART Request Parameters
295  * @{
296  */
297 #define UART_RXDATA_FLUSH_REQUEST UART_SRR_RFR /**< RX FIFO flush Request */
298 #define UART_TXDATA_FLUSH_REQUEST UART_SRR_XFR /**< TX FIFO flush Request */
299 #define UART_TXRXDATA_FLUSH_REQUEST (UART_SRR_XFR | UART_SRR_RFR) /**< TX FIFO and RX FIFO flush Request */
300 /** @} */
301 
302 /** @defgroup UART_Interrupt_Mask UART Interrupt Flag Mask
303  * @{
304  */
305 #define UART_IT_MASK (0x008FU) /**< UART interruptions flags mask */
306 /** @} */
307 
308 /** @defgroup UART_Line_Error_Mask UART Line Error Flag Mask
309  * @{
310  */
311 #define UART_LINE_ERROR_MASK (LL_UART_LSR_PE | LL_UART_LSR_OE | LL_UART_LSR_FE | LL_UART_LSR_BI) /**< UART interruptions flags mask */
312 /** @} */
313 
314 /** @defgroup UART_Retention_Length UART Retention Register Length
315  * @{
316  */
317 #define UART_RETENTION_LENGTH ((uint32_t)8) /**< the number of retention registers */
318 /** @} */
319 
320 /** @defgroup UART_Timeout_definition UART Timeout_definition
321  * @{
322  */
323 #define HAL_UART_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000) /**< 5s */
324 /** @} */
325 
326 /** @} */
327 
328 /* Exported macro ------------------------------------------------------------*/
329 /** @defgroup UART_Exported_Macros UART Exported Macros
330  * @{
331  */
332 
333 /** @brief Reset UART handle states.
334  * @param __HANDLE__ UART handle.
335  * @retval None
336  */
337 #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) \
338  do{ \
339  (__HANDLE__)->g_state = HAL_UART_STATE_RESET; \
340  (__HANDLE__)->rx_state = HAL_UART_STATE_RESET; \
341  } while(0U)
342 
343 /** @brief Enable the specified UART interrupt.
344  * @param __HANDLE__ Specifies the UART Handle.
345  * @param __INTERRUPT__ Specifies the UART interrupt source to enable.
346  * This parameter can be one of the following values:
347  * @arg @ref UART_IT_RDA
348  * @arg @ref UART_IT_THRE
349  * @arg @ref UART_IT_RLS
350  * @arg @ref UART_IT_MS
351  * @retval None
352  */
353 #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) \
354  do { \
355  GLOBAL_EXCEPTION_DISABLE(); \
356  ll_uart_enable_it((__HANDLE__)->p_instance, (__INTERRUPT__)); \
357  GLOBAL_EXCEPTION_ENABLE(); \
358  } while(0U)
359 
360 /** @brief Disable the specified UART interrupt.
361  * @param __HANDLE__ Specifies the UART Handle.
362  * @param __INTERRUPT__ Specifies the UART interrupt source to disable.
363  * This parameter can be one of the following values:
364  * @arg @ref UART_IT_RDA
365  * @arg @ref UART_IT_THRE
366  * @arg @ref UART_IT_RLS
367  * @arg @ref UART_IT_MS
368  * @retval None
369  */
370 #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) \
371  do { \
372  GLOBAL_EXCEPTION_DISABLE(); \
373  ll_uart_disable_it((__HANDLE__)->p_instance, (__INTERRUPT__)); \
374  GLOBAL_EXCEPTION_ENABLE(); \
375  } while(0)
376 
377 /** @brief Flush the UART FIFO and treat FIFO as empty.
378  * @param __HANDLE__ Specifies the UART Handle.
379  * @param __REQ__ Specifies the request flag to set
380  * This parameter can be one of the following values:
381  * @arg @ref UART_RXDATA_FLUSH_REQUEST RX FIFO flush Request
382  * @arg @ref UART_TXDATA_FLUSH_REQUEST TX FIFO flush Request
383  * @arg @ref UART_TXRXDATA_FLUSH_REQUEST TX FIFO and RX FIFO flush
384  * @retval None
385  */
386 #define __HAL_UART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->p_instance->SRR = (__REQ__))
387 
388 /** @} */
389 
390 /* Private macros ------------------------------------------------------------*/
391 /** @defgroup UART_Private_Macro UART Private Macros
392  * @{
393  */
394 
395 /** @brief Check if UART Baudrate is valid.
396  * @param __BAUDRATE__ UART Baudrate.
397  * @retval SET (__BAUDRATE__ is valid) or RESET (__BAUDRATE__ is invalid)
398  */
399 #define IS_UART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 921600U)
400 
401 /**
402  * @brief Check if UART frame number of stop bits is valid.
403  * @param __STOPBITS__ UART frame number of stop bits.
404  * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid)
405  */
406 #define IS_UART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == UART_STOPBITS_1) || \
407  ((__STOPBITS__) == UART_STOPBITS_1_5) || \
408  ((__STOPBITS__) == UART_STOPBITS_2))
409 
410 /**
411  * @brief Check if UART frame number of data bits is valid.
412  * @param __DATABITS__ UART frame number of data bits.
413  * @retval SET (__DATABITS__ is valid) or RESET (__DATABITS__ is invalid)
414  */
415 #define IS_UART_DATABITS(__DATABITS__) (((__DATABITS__) == UART_DATABITS_5) || \
416  ((__DATABITS__) == UART_DATABITS_6) || \
417  ((__DATABITS__) == UART_DATABITS_7) || \
418  ((__DATABITS__) == UART_DATABITS_8))
419 
420 /**
421  * @brief Check if UART frame parity is valid.
422  * @param __PARITY__ UART frame parity.
423  * @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid)
424  */
425 #define IS_UART_PARITY(__PARITY__) (((__PARITY__) == UART_PARITY_NONE) || \
426  ((__PARITY__) == UART_PARITY_EVEN) || \
427  ((__PARITY__) == UART_PARITY_ODD) || \
428  ((__PARITY__) == UART_PARITY_SP0) || \
429  ((__PARITY__) == UART_PARITY_SP1))
430 
431 /**
432  * @brief Check if UART hardware flow control is valid.
433  * @param __CONTROL__ UART hardware flow control.
434  * @retval SET (__CONTROL__ is valid) or RESET (__CONTROL__ is invalid)
435  */
436 #define IS_UART_HARDWARE_FLOW_CONTROL(__CONTROL__)\
437  (((__CONTROL__) == UART_HWCONTROL_NONE) || \
438  ((__CONTROL__) == UART_HWCONTROL_RTS_CTS)
439 /** @} */
440 
441 /**
442  * @brief Default configuartion for initializing structure
443  */
444 #define UART_DEFAULT_CONFIG \
445 { \
446  .baud_rate = 9600, \
447  .data_bits = UART_DATABITS_8, \
448  .stop_bits = UART_STOPBITS_1, \
449  .parity = UART_PARITY_NONE, \
450  .hw_flow_ctrl = UART_HWCONTROL_NONE, \
451  .rx_timeout_mode = UART_RECEIVER_TIMEOUT_DISABLE, \
452 }
453 
454 /** @} */
455 
456 /* Exported functions --------------------------------------------------------*/
457 /** @addtogroup HAL_UART_DRIVER_FUNCTIONS Functions
458  * @{
459  */
460 
461 /** @addtogroup UART_Exported_Functions_Group1 Initialization and de-initialization functions
462  * @brief Initialization and de-initialization functions
463  *
464  * @verbatim
465 ===============================================================================
466  ##### Initialization and de-initialization functions #####
467  ===============================================================================
468  [..]
469  This subsection provides a set of functions allowing to initialize the UARTx.
470  (+) For the asynchronous mode the parameters below can be configured:
471  (++) Baud Rate
472  (++) Data Bit
473  (++) Stop Bit
474  (++) Parity
475  (++) Hardware flow control
476  [..]
477  The hal_uart_init() API follow the UART asynchronous configuration procedures.
478 
479 @endverbatim
480  * @{
481  */
482 
483 /**
484  ****************************************************************************************
485  * @brief Initialize the UART according to the specified
486  * parameters in the uart_init_t and initialize the associated handle.
487  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
488  * information for the specified UART module.
489  * @retval ::HAL_OK: Operation is OK.
490  * @retval ::HAL_ERROR: Parameter error or operation not supported.
491  * @retval ::HAL_BUSY: Driver is busy.
492  * @retval ::HAL_TIMEOUT: Timeout occurred.
493  ****************************************************************************************
494  */
496 
497 /**
498  ****************************************************************************************
499  * @brief De-initialize the UART peripheral.
500  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
501  * information for the specified UART module.
502  * @retval ::HAL_OK: Operation is OK.
503  * @retval ::HAL_ERROR: Parameter error or operation not supported.
504  * @retval ::HAL_BUSY: Driver is busy.
505  * @retval ::HAL_TIMEOUT: Timeout occurred.
506  ****************************************************************************************
507  */
509 
510 /**
511  ****************************************************************************************
512  * @brief Initialize the UART MSP.
513  * @note This function should not be modified. When the callback is needed,
514  the hal_uart_msp_init can be implemented in the user file.
515  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
516  * information for the specified UART module.
517  ****************************************************************************************
518  */
520 
521 /**
522  ****************************************************************************************
523  * @brief De-initialize the UART MSP.
524  * @note This function should not be modified. When the callback is needed,
525  the hal_uart_msp_deinit can be implemented in the user file.
526  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
527  * information for the specified UART module.
528  ****************************************************************************************
529  */
531 
532 /** @} */
533 
534 /** @addtogroup UART_Exported_Functions_Group2 IO operation functions
535  * @brief UART Transmit/Receive functions
536  *
537 @verbatim
538  ===============================================================================
539  ##### IO operation functions #####
540  ===============================================================================
541  This subsection provides a set of functions allowing to manage the UART asynchronous
542  and Half duplex data transfers.
543 
544  (#) There are two mode of transfer:
545  (++) Blocking mode: The communication is performed in polling mode.
546  The HAL status of all data processing is returned by the same function
547  after finishing transfer.
548  (++) Non-Blocking mode: The communication is performed using Interrupts
549  or DMA, These API's return the HAL status.
550  The end of the data processing will be indicated through the
551  dedicated UART IRQ when using Interrupt mode or the DMA IRQ when
552  using DMA mode.
553  The hal_uart_tx_cplt_callback(), hal_uart_rx_cplt_callback() user callbacks
554  will be executed respectively at the end of the transmit or Receive process
555  The hal_uart_error_callback() user callback will be executed when a
556  communication error is detected
557 
558  (#) Blocking mode API's are :
559  (++) hal_uart_transmit()
560  (++) hal_uart_receive()
561 
562  (#) Non-Blocking mode API's with Interrupt are :
563  (++) hal_uart_transmit_it()
564  (++) hal_uart_receive_it()
565  (++) hal_uart_irq_handler()
566 
567  (#) Non-Blocking mode API's with DMA are :
568  (++) hal_uart_transmit_dma()
569  (++) hal_uart_receive_dma()
570  (++) hal_uart_dma_pause()
571  (++) hal_uart_dma_resume()
572  (++) hal_uart_dma_stop()
573 
574  (#) A set of Transfer Complete Callbacks are provided in Non_Blocking mode:
575  (++) hal_uart_tx_cplt_callback()
576  (++) hal_uart_rx_cplt_callback()
577  (++) hal_uart_error_callback()
578 
579  (#) Non-Blocking mode transfers could be aborted using Abort API's :
580  (++) hal_uart_abort()
581  (++) hal_uart_abort_transmit()
582  (++) hal_uart_abort_receive()
583  (++) hal_uart_abort_it()
584  (++) hal_uart_abort_transmit_it()
585  (++) hal_uart_abort_receive_it()
586 
587  (#) For Abort services based on interrupts (hal_uart_abort_xxx_it), a set
588  of Abort Complete Callbacks are provided:
589  (++) hal_uart_abort_cplt_callback()
590  (++) hal_uart_abort_tx_cplt_callback()
591  (++) hal_uart_abort_rx_cplt_callback()
592 
593  (#) In Non-Blocking mode transfers, possible errors are split into 2 categories.
594  Errors are handled as follows :
595  (++) Error is considered as Recoverable and non blocking. Transfer could go till end, but error severity is
596  to be evaluated by user : this concerns Frame Error, Parity Error or Noise Error in Interrupt mode reception .
597  Received character is then retrieved and stored in Rx buffer, Error code is set to allow user to identify error type,
598  and hal_uart_error_callback() user callback is executed. Transfer is kept ongoing on UART side.
599  If user wants to abort it, Abort services should be called by user.
600  (++) Error is considered as Blocking : Transfer could not be completed properly and is aborted.
601  This concerns Overrun Error In Interrupt mode reception and all errors in DMA mode.
602  Error code is set to allow user to identify error type, and hal_uart_error_callback() user callback is executed.
603 
604  -@- In the Half duplex communication, it is forbidden to run the transmit
605  and receive process in parallel, the UART state hal_uart_state_busy_tx_rx can't be useful.
606 
607 @endverbatim
608  * @{
609  */
610 
611 /**
612  ****************************************************************************************
613  * @brief Send an amount of data in blocking mode.
614  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
615  * information for the specified UART module.
616  * @param[in] p_data: Pointer to data buffer.
617  * @param[in] size: Amount of data to be sent.
618  * @param[in] timeout: Timeout duration.
619  * @retval ::HAL_OK: Operation is OK.
620  * @retval ::HAL_ERROR: Parameter error or operation not supported.
621  * @retval ::HAL_BUSY: Driver is busy.
622  * @retval ::HAL_TIMEOUT: Timeout occurred.
623  ****************************************************************************************
624  */
625 hal_status_t hal_uart_transmit(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size, uint32_t timeout);
626 
627 /**
628  ****************************************************************************************
629  * @brief Receive an amount of data in blocking mode.
630  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
631  * information for the specified UART module.
632  * @param[out] p_data: Pointer to data buffer.
633  * @param[in] size: Amount of data to be received.
634  * @param[in] timeout: Timeout duration.
635  * @retval ::HAL_OK: Operation is OK.
636  * @retval ::HAL_ERROR: Parameter error or operation not supported.
637  * @retval ::HAL_BUSY: Driver is busy.
638  * @retval ::HAL_TIMEOUT: Timeout occurred.
639  ****************************************************************************************
640  */
641 hal_status_t hal_uart_receive(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size, uint32_t timeout);
642 
643 /**
644  ****************************************************************************************
645  * @brief Send an amount of data in interrupt mode.
646  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
647  * information for the specified UART module.
648  * @param[in] p_data: Pointer to data buffer.
649  * @param[in] size: Amount of data to be sent.
650  * @retval ::HAL_OK: Operation is OK.
651  * @retval ::HAL_ERROR: Parameter error or operation not supported.
652  * @retval ::HAL_BUSY: Driver is busy.
653  * @retval ::HAL_TIMEOUT: Timeout occurred.
654  ****************************************************************************************
655  */
656 hal_status_t hal_uart_transmit_it(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size);
657 
658 /**
659  ****************************************************************************************
660  * @brief Receive an amount of data in interrupt mode.
661  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
662  * information for the specified UART module.
663  * @param[out] p_data: Pointer to data buffer.
664  * @param[in] size: Amount of data to be received.
665  * @retval ::HAL_OK: Operation is OK.
666  * @retval ::HAL_ERROR: Parameter error or operation not supported.
667  * @retval ::HAL_BUSY: Driver is busy.
668  * @retval ::HAL_TIMEOUT: Timeout occurred.
669  ****************************************************************************************
670  */
671 hal_status_t hal_uart_receive_it(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size);
672 
673 /**
674  ****************************************************************************************
675  * @brief Send an amount of data in DMA mode.
676  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
677  * information for the specified UART module.
678  * @param[in] p_data: Pointer to data buffer.
679  * @param[in] size: Amount of data to be sent, ranging between 0 ~ 4095.
680  * @note This function starts a DMA transfer in interrupt mode meaning that
681  * DMA half transfer complete, DMA transfer complete and DMA transfer
682  * error interrupts are enabled
683  * @retval ::HAL_OK: Operation is OK.
684  * @retval ::HAL_ERROR: Parameter error or operation not supported.
685  * @retval ::HAL_BUSY: Driver is busy.
686  * @retval ::HAL_TIMEOUT: Timeout occurred.
687  ****************************************************************************************
688  */
689 hal_status_t hal_uart_transmit_dma(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size);
690 
691 /**
692  ****************************************************************************************
693  * @brief Receive an amount of data in DMA mode.
694  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
695  * information for the specified UART module.
696  * @param[out] p_data: Pointer to data buffer.
697  * @param[in] size: Amount of data to be received, ranging between 0 and 4095.
698  * @note When the UART parity is enabled (PCE = 1), the received data contain
699  * the parity bit (MSB position).
700  * @note This function starts a DMA transfer in interrupt mode meaning that
701  * DMA half transfer complete, DMA transfer complete and DMA transfer
702  * error interrupts are enabled
703  * @retval ::HAL_OK: Operation is OK.
704  * @retval ::HAL_ERROR: Parameter error or operation not supported.
705  * @retval ::HAL_BUSY: Driver is busy.
706  * @retval ::HAL_TIMEOUT: Timeout occurred.
707  ****************************************************************************************
708  */
709 hal_status_t hal_uart_receive_dma(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size);
710 
711 /**
712  ****************************************************************************************
713  * @brief Pause the DMA Transfer.
714  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
715  * information for the specified UART module.
716  * @retval ::HAL_OK: Operation is OK.
717  * @retval ::HAL_ERROR: Parameter error or operation not supported.
718  * @retval ::HAL_BUSY: Driver is busy.
719  * @retval ::HAL_TIMEOUT: Timeout occurred.
720  ****************************************************************************************
721  */
723 
724 /**
725  ****************************************************************************************
726  * @brief Resume the DMA Transfer.
727  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
728  * information for the specified UART module.
729  * @retval ::HAL_OK: Operation is OK.
730  * @retval ::HAL_ERROR: Parameter error or operation not supported.
731  * @retval ::HAL_BUSY: Driver is busy.
732  * @retval ::HAL_TIMEOUT: Timeout occurred.
733  ****************************************************************************************
734  */
736 
737 /**
738  ****************************************************************************************
739  * @brief Stop the DMA Transfer.
740  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
741  * information for the specified UART module.
742  * @retval ::HAL_OK: Operation is OK.
743  * @retval ::HAL_ERROR: Parameter error or operation not supported.
744  * @retval ::HAL_BUSY: Driver is busy.
745  * @retval ::HAL_TIMEOUT: Timeout occurred.
746  ****************************************************************************************
747  */
749 
750 /**
751  ****************************************************************************************
752  * @brief Abort ongoing transfers (blocking mode).
753  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
754  * information for the specified UART module.
755  * @note This procedure could be used for aborting any ongoing transfer started in Interrupt or DMA mode.
756  * This procedure performs following operations :
757  * - Disable UART Interrupts (Tx and Rx)
758  * - Disable the DMA transfer in the peripheral register (if enabled)
759  * - Abort DMA transfer by calling hal_dma_abort (in case of transfer in DMA mode)
760  * - Set handle State to READY
761  * @note This procedure is executed in blocking mode: when exiting function, Abort is considered as completed.
762  * @retval ::HAL_OK: Operation is OK.
763  * @retval ::HAL_ERROR: Parameter error or operation not supported.
764  * @retval ::HAL_BUSY: Driver is busy.
765  * @retval ::HAL_TIMEOUT: Timeout occurred.
766  ****************************************************************************************
767  */
769 
770 /**
771  ****************************************************************************************
772  * @brief Abort ongoing Transmit transfer (blocking mode).
773  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
774  * information for the specified UART module.
775  * @note This procedure could be used for aborting any ongoing Tx transfer started in Interrupt or DMA mode.
776  * This procedure performs following operations :
777  * - Disable UART Interrupts (Tx)
778  * - Disable the DMA transfer in the peripheral register (if enabled)
779  * - Abort DMA transfer by calling hal_dma_abort (in case of transfer in DMA mode)
780  * - Set handle State to READY
781  * @note This procedure is executed in blocking mode: when exiting function, Abort is considered as completed.
782  * @retval ::HAL_OK: Operation is OK.
783  * @retval ::HAL_ERROR: Parameter error or operation not supported.
784  * @retval ::HAL_BUSY: Driver is busy.
785  * @retval ::HAL_TIMEOUT: Timeout occurred.
786  ****************************************************************************************
787  */
789 
790 /**
791  ****************************************************************************************
792  * @brief Abort ongoing Receive transfer (blocking mode).
793  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
794  * information for the specified UART module.
795  * @note This procedure could be used for aborting any ongoing Rx transfer started in Interrupt or DMA mode.
796  * This procedure performs following operations :
797  * - Disable UART Interrupts (Rx)
798  * - Disable the DMA transfer in the peripheral register (if enabled)
799  * - Abort DMA transfer by calling hal_dma_abort (in case of transfer in DMA mode)
800  * - Set handle State to READY
801  * @note This procedure is executed in blocking mode: when exiting function, Abort is considered as completed.
802  * @retval ::HAL_OK: Operation is OK.
803  * @retval ::HAL_ERROR: Parameter error or operation not supported.
804  * @retval ::HAL_BUSY: Driver is busy.
805  * @retval ::HAL_TIMEOUT: Timeout occurred.
806  ****************************************************************************************
807  */
809 
810 /**
811  ****************************************************************************************
812  * @brief Abort ongoing transfers (Interrupt mode).
813  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
814  * information for the specified UART module.
815  * @note This procedure could be used for aborting any ongoing transfer started in Interrupt or DMA mode.
816  * This procedure performs following operations :
817  * - Disable UART Interrupts (Tx and Rx)
818  * - Disable the DMA transfer in the peripheral register (if enabled)
819  * - Abort DMA transfer by calling hal_dma_abort_it (in case of transfer in DMA mode)
820  * - Set handle State to READY
821  * - At abort completion, call user abort complete callback
822  * @note This procedure is executed in Interrupt mode, meaning that abort procedure could be
823  * considered as completed only when user abort complete callback is executed (not when exiting function).
824  * @retval ::HAL_OK: Operation is OK.
825  * @retval ::HAL_ERROR: Parameter error or operation not supported.
826  * @retval ::HAL_BUSY: Driver is busy.
827  * @retval ::HAL_TIMEOUT: Timeout occurred.
828  ****************************************************************************************
829  */
831 
832 /**
833  ****************************************************************************************
834  * @brief Abort ongoing Transmit transfer (Interrupt mode).
835  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
836  * information for the specified UART module.
837  * @note This procedure could be used for aborting any ongoing Tx transfer started in Interrupt or DMA mode.
838  * This procedure performs following operations :
839  * - Disable UART Interrupts (Tx)
840  * - Disable the DMA transfer in the peripheral register (if enabled)
841  * - Abort DMA transfer by calling hal_dma_abort_it (in case of transfer in DMA mode)
842  * - Set handle State to READY
843  * - At abort completion, call user abort complete callback
844  * @note This procedure is executed in Interrupt mode, meaning that abort procedure could be
845  * considered as completed only when user abort complete callback is executed (not when exiting function).
846  * @retval ::HAL_OK: Operation is OK.
847  * @retval ::HAL_ERROR: Parameter error or operation not supported.
848  * @retval ::HAL_BUSY: Driver is busy.
849  * @retval ::HAL_TIMEOUT: Timeout occurred.
850  ****************************************************************************************
851  */
853 
854 /**
855  ****************************************************************************************
856  * @brief Abort ongoing Receive transfer (Interrupt mode).
857  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
858  * information for the specified UART module.
859  * @note This procedure could be used for aborting any ongoing Rx transfer started in Interrupt or DMA mode.
860  * This procedure performs following operations :
861  * - Disable UART Interrupts (Rx)
862  * - Disable the DMA transfer in the peripheral register (if enabled)
863  * - Abort DMA transfer by calling hal_dma_abort_it (in case of transfer in DMA mode)
864  * - Set handle State to READY
865  * - At abort completion, call user abort complete callback
866  * @note This procedure is executed in Interrupt mode, meaning that abort procedure could be
867  * considered as completed only when user abort complete callback is executed (not when exiting function).
868  * @retval ::HAL_OK: Operation is OK.
869  * @retval ::HAL_ERROR: Parameter error or operation not supported.
870  * @retval ::HAL_BUSY: Driver is busy.
871  * @retval ::HAL_TIMEOUT: Timeout occurred.
872  ****************************************************************************************
873  */
875 
876 /** @} */
877 
878 /** @addtogroup UART_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
879  * @brief IRQ Handler and Callbacks functions
880  * @{
881  */
882 
883 /**
884  ****************************************************************************************
885  * @brief Handle UART interrupt request.
886  * @param[in] p_uart: Pointer to a UART handle which contains the configuration information
887  * for the specified UART module.
888  ****************************************************************************************
889  */
891 
892 /**
893  ****************************************************************************************
894  * @brief Tx Transfer completed callback.
895  * @note This function should not be modified. When the callback is needed,
896  * the hal_uart_tx_cplt_callback can be implemented in the user file.
897  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
898  * information for the specified UART module.
899  ****************************************************************************************
900  */
902 
903 /**
904  ****************************************************************************************
905  * @brief Rx Transfer completed callback.
906  * @note This function should not be modified. When the callback is needed,
907  * the hal_uart_rx_cplt_callback can be implemented in the user file.
908  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
909  * information for the specified UART module.
910  ****************************************************************************************
911  */
913 
914 /**
915  ****************************************************************************************
916  * @brief UART error callback.
917  * @note This function should not be modified. When the callback is needed,
918  * the hal_uart_error_callback can be implemented in the user file.
919  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
920  * information for the specified UART module.
921  ****************************************************************************************
922  */
924 
925 /**
926  ****************************************************************************************
927  * @brief UART Abort Complete callback.
928  * @note This function should not be modified. When the callback is needed,
929  * the hal_uart_abort_cplt_callback can be implemented in the user file.
930  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
931  * information for the specified UART module.
932  ****************************************************************************************
933  */
935 
936 /**
937  ****************************************************************************************
938  * @brief UART Abort Tansmit Complete callback.
939  * @note This function should not be modified. When the callback is needed,
940  * the hal_uart_abort_tx_cplt_callback can be implemented in the user file.
941  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
942  * information for the specified UART module.
943  ****************************************************************************************
944  */
946 
947 /**
948  ****************************************************************************************
949  * @brief UART Abort Receive Complete callback.
950  * @note This function should not be modified. When the callback is needed,
951  * the hal_uart_abort_rx_cplt_callback can be implemented in the user file.
952  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
953  * information for the specified UART module.
954  ****************************************************************************************
955  */
957 
958 /** @} */
959 
960 
961 /** @addtogroup UART_Exported_Functions_Group3 Peripheral Control and State functions
962  * @brief UART Peripheral State functions
963  *
964 @verbatim
965  ==============================================================================
966  ##### Peripheral Control and State functions #####
967  ==============================================================================
968  [..]
969  This subsection provides functions allowing to :
970  (+) Return the UART handle state.
971  (+) Return the UART handle error code
972 
973 @endverbatim
974  * @{
975  */
976 
977 /**
978  ****************************************************************************************
979  * @brief Return the UART handle state.
980  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
981  * information for the specified UART module.
982  * @retval ::HAL_UART_STATE_RESET: Peripheral is not initialized.
983  * @retval ::HAL_UART_STATE_READY: Peripheral initialized and ready for use.
984  * @retval ::HAL_UART_STATE_BUSY: An internal process is ongoing.
985  * @retval ::HAL_UART_STATE_BUSY_TX: Data Transmission process is ongoing.
986  * @retval ::HAL_UART_STATE_BUSY_RX: Data Reception process is ongoing.
987  * @retval ::HAL_UART_STATE_TIMEOUT: Timeout state.
988  * @retval ::HAL_UART_STATE_ERROR: Error.
989  ****************************************************************************************
990  */
992 
993 /**
994  ****************************************************************************************
995  * @brief Return the UART handle error code.
996  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
997  * information for the specified UART module.
998  * @return UART Error Code
999  ****************************************************************************************
1000  */
1002 
1003 /**
1004  ****************************************************************************************
1005  * @brief Suspend some registers related to UART configuration before sleep.
1006  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
1007  * information for the specified UART module.
1008  * @retval ::HAL_OK: Operation is OK.
1009  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1010  * @retval ::HAL_BUSY: Driver is busy.
1011  * @retval ::HAL_TIMEOUT: Timeout occurred.
1012  ****************************************************************************************
1013  */
1015 
1016 /**
1017  ****************************************************************************************
1018  * @brief Restore some registers related to UART configuration after sleep.
1019  * This function must be used in conjunction with the hal_uart_suspend_reg().
1020  * @param[in] p_uart: Pointer to a UART handle which contains the configuration
1021  * information for the specified UART module.
1022  * @retval ::HAL_OK: Operation is OK.
1023  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1024  * @retval ::HAL_BUSY: Driver is busy.
1025  * @retval ::HAL_TIMEOUT: Timeout occurred.
1026  ****************************************************************************************
1027  */
1029 
1030 
1031 /** @} */
1032 
1033 /** @} */
1034 
1035 #ifdef __cplusplus
1036 }
1037 #endif
1038 
1039 #endif /* __GR55xx_HAL_UART_H__ */
1040 
1041 /** @} */
1042 
1043 /** @} */
1044 
1045 /** @} */
hal_uart_irq_handler
void hal_uart_irq_handler(uart_handle_t *p_uart)
Handle UART interrupt request.
_hal_uart_callback::uart_abort_rx_cplt_callback
void(* uart_abort_rx_cplt_callback)(uart_handle_t *p_uart)
UART abort receive complete callback
Definition: gr55xx_hal_uart.h:215
_hal_uart_callback::uart_msp_deinit
void(* uart_msp_deinit)(uart_handle_t *p_uart)
UART de-init MSP callback
Definition: gr55xx_hal_uart.h:209
_uart_handle::tx_state
__IO hal_uart_state_t tx_state
UART state information related to Tx operations.
Definition: gr55xx_hal_uart.h:180
hal_uart_abort_rx_cplt_callback
void hal_uart_abort_rx_cplt_callback(uart_handle_t *p_uart)
UART Abort Receive Complete callback.
_uart_handle::rx_state
__IO hal_uart_state_t rx_state
UART state information related to Rx operations.
Definition: gr55xx_hal_uart.h:183
_uart_handle::p_dmatx
dma_handle_t * p_dmatx
UART Tx DMA Handle parameters
Definition: gr55xx_hal_uart.h:170
hal_lock_t
hal_lock_t
HAL Lock structures definition.
Definition: gr55xx_hal_def.h:81
_uart_handle::rx_xfer_size
uint16_t rx_xfer_size
UART Rx Transfer size
Definition: gr55xx_hal_uart.h:166
hal_uart_get_error
uint32_t hal_uart_get_error(uart_handle_t *p_uart)
Return the UART handle error code.
_uart_init::baud_rate
uint32_t baud_rate
This member configures the UART communication baud rate.
Definition: gr55xx_hal_uart.h:121
_uart_handle::init
uart_init_t init
UART communication parameters
Definition: gr55xx_hal_uart.h:156
hal_uart_transmit_dma
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.
hal_uart_dma_resume
hal_status_t hal_uart_dma_resume(uart_handle_t *p_uart)
Resume the DMA Transfer.
uart_init_t
struct _uart_init uart_init_t
UART init structure definition.
hal_uart_transmit
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.
hal_uart_deinit
hal_status_t hal_uart_deinit(uart_handle_t *p_uart)
De-initialize the UART peripheral.
HAL_UART_STATE_BUSY_TX
@ HAL_UART_STATE_BUSY_TX
Data Transmission process is ongoing.
Definition: gr55xx_hal_uart.h:87
hal_uart_state_t
hal_uart_state_t
HAL UART State enumerations definition.
Definition: gr55xx_hal_uart.h:77
_uart_handle::dma_rx_mode
functional_state_t dma_rx_mode
UART Rx DMA mode state
Definition: gr55xx_hal_uart.h:176
hal_uart_abort_receive
hal_status_t hal_uart_abort_receive(uart_handle_t *p_uart)
Abort ongoing Receive transfer (blocking mode).
hal_uart_abort_receive_it
hal_status_t hal_uart_abort_receive_it(uart_handle_t *p_uart)
Abort ongoing Receive transfer (Interrupt mode).
hal_uart_abort_it
hal_status_t hal_uart_abort_it(uart_handle_t *p_uart)
Abort ongoing transfers (Interrupt mode).
hal_uart_msp_init
void hal_uart_msp_init(uart_handle_t *p_uart)
Initialize the UART MSP.
HAL_UART_STATE_BUSY_RX
@ HAL_UART_STATE_BUSY_RX
Data Reception process is ongoing.
Definition: gr55xx_hal_uart.h:90
_uart_handle
UART handle Structure definition.
Definition: gr55xx_hal_uart.h:153
_uart_init::stop_bits
uint32_t stop_bits
Specifies the number of stop bits transmitted.
Definition: gr55xx_hal_uart.h:126
_uart_handle::p_dmarx
dma_handle_t * p_dmarx
UART Rx DMA Handle parameters
Definition: gr55xx_hal_uart.h:172
_uart_init
UART init structure definition.
Definition: gr55xx_hal_uart.h:120
_uart_handle::lock
hal_lock_t lock
Locking object
Definition: gr55xx_hal_uart.h:178
_uart_init::rx_timeout_mode
uint32_t rx_timeout_mode
Specifies whether the receive timeout mode is enabled or disabled.
Definition: gr55xx_hal_uart.h:135
hal_uart_error_callback
void hal_uart_error_callback(uart_handle_t *p_uart)
UART error callback.
_hal_uart_callback
HAL_UART Callback function definition.
Definition: gr55xx_hal_uart.h:207
hal_uart_callback_t
struct _hal_uart_callback hal_uart_callback_t
HAL_UART Callback function definition.
_uart_handle::tx_xfer_size
uint16_t tx_xfer_size
UART Tx Transfer size
Definition: gr55xx_hal_uart.h:160
hal_uart_abort_transmit
hal_status_t hal_uart_abort_transmit(uart_handle_t *p_uart)
Abort ongoing Transmit transfer (blocking mode).
uart_handle_t
struct _uart_handle uart_handle_t
UART handle Structure definition.
_hal_uart_callback::uart_error_callback
void(* uart_error_callback)(uart_handle_t *p_uart)
UART error callback
Definition: gr55xx_hal_uart.h:212
HAL_UART_STATE_ERROR
@ HAL_UART_STATE_ERROR
Error.
Definition: gr55xx_hal_uart.h:99
HAL_UART_STATE_BUSY
@ HAL_UART_STATE_BUSY
An internal process is ongoing.
Definition: gr55xx_hal_uart.h:84
_uart_init::parity
uint32_t parity
Specifies the parity mode.
Definition: gr55xx_hal_uart.h:129
hal_uart_resume_reg
hal_status_t hal_uart_resume_reg(uart_handle_t *p_uart)
Restore some registers related to UART configuration after sleep.
_uart_handle::tx_xfer_count
__IO uint16_t tx_xfer_count
UART Tx Transfer Counter
Definition: gr55xx_hal_uart.h:162
_uart_handle::p_rx_buffer
uint8_t * p_rx_buffer
Pointer to UART Rx transfer Buffer.
Definition: gr55xx_hal_uart.h:164
hal_uart_suspend_reg
hal_status_t hal_uart_suspend_reg(uart_handle_t *p_uart)
Suspend some registers related to UART configuration before sleep.
HAL_UART_STATE_TIMEOUT
@ HAL_UART_STATE_TIMEOUT
Timeout state.
Definition: gr55xx_hal_uart.h:96
hal_uart_init
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 assoc...
HAL_UART_STATE_READY
@ HAL_UART_STATE_READY
Peripheral initialized and ready for use.
Definition: gr55xx_hal_uart.h:81
hal_uart_msp_deinit
void hal_uart_msp_deinit(uart_handle_t *p_uart)
De-initialize the UART MSP.
hal_uart_dma_stop
hal_status_t hal_uart_dma_stop(uart_handle_t *p_uart)
Stop the DMA Transfer.
_hal_uart_callback::uart_abort_cplt_callback
void(* uart_abort_cplt_callback)(uart_handle_t *p_uart)
UART abort completed callback
Definition: gr55xx_hal_uart.h:213
gr55xx_ll_uart.h
Header file containing functions prototypes of UART LL library.
hal_uart_tx_cplt_callback
void hal_uart_tx_cplt_callback(uart_handle_t *p_uart)
Tx Transfer completed callback.
_hal_uart_callback::uart_rx_cplt_callback
void(* uart_rx_cplt_callback)(uart_handle_t *p_uart)
UART rx transfer completed callback
Definition: gr55xx_hal_uart.h:211
_uart_init::hw_flow_ctrl
uint32_t hw_flow_ctrl
Specifies whether the hardware flow control mode is enabled or disabled.
Definition: gr55xx_hal_uart.h:132
HAL_UART_STATE_RESET
@ HAL_UART_STATE_RESET
Peripheral is not initialized.
Definition: gr55xx_hal_uart.h:78
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_hal_def.h:70
hal_uart_transmit_it
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.
_uart_handle::retention
uint32_t retention[8]
UART important register information.
Definition: gr55xx_hal_uart.h:188
hal_uart_abort
hal_status_t hal_uart_abort(uart_handle_t *p_uart)
Abort ongoing transfers (blocking mode).
HAL_UART_STATE_BUSY_TXRX
@ HAL_UART_STATE_BUSY_TXRX
Data Transmission and Reception process is ongoing.
Definition: gr55xx_hal_uart.h:93
_uart_init::data_bits
uint32_t data_bits
Specifies the number of data bits transmitted or received in a frame.
Definition: gr55xx_hal_uart.h:123
hal_uart_abort_transmit_it
hal_status_t hal_uart_abort_transmit_it(uart_handle_t *p_uart)
Abort ongoing Transmit transfer (Interrupt mode).
_hal_uart_callback::uart_abort_tx_cplt_callback
void(* uart_abort_tx_cplt_callback)(uart_handle_t *p_uart)
UART abort tansmit complete callback
Definition: gr55xx_hal_uart.h:214
_uart_handle::p_tx_buffer
uint8_t * p_tx_buffer
Pointer to UART Tx transfer Buffer.
Definition: gr55xx_hal_uart.h:158
hal_uart_abort_cplt_callback
void hal_uart_abort_cplt_callback(uart_handle_t *p_uart)
UART Abort Complete callback.
_uart_handle::p_instance
uart_regs_t * p_instance
UART registers base address
Definition: gr55xx_hal_uart.h:154
hal_uart_receive_it
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.
_uart_handle::error_code
__IO uint32_t error_code
UART Error code
Definition: gr55xx_hal_uart.h:186
hal_uart_receive
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.
_hal_uart_callback::uart_tx_cplt_callback
void(* uart_tx_cplt_callback)(uart_handle_t *p_uart)
UART tx transfer completed callback
Definition: gr55xx_hal_uart.h:210
_uart_handle::rx_xfer_count
__IO uint16_t rx_xfer_count
UART Rx Transfer Counter
Definition: gr55xx_hal_uart.h:168
_hal_uart_callback::uart_msp_init
void(* uart_msp_init)(uart_handle_t *p_uart)
UART init MSP callback
Definition: gr55xx_hal_uart.h:208
hal_uart_dma_pause
hal_status_t hal_uart_dma_pause(uart_handle_t *p_uart)
Pause the DMA Transfer.
hal_uart_receive_dma
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.
_dma_handle
DMA handle Structure definition.
Definition: gr55xx_hal_dma.h:179
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
_uart_handle::dma_tx_mode
functional_state_t dma_tx_mode
UART Tx DMA mode state
Definition: gr55xx_hal_uart.h:174
hal_uart_rx_cplt_callback
void hal_uart_rx_cplt_callback(uart_handle_t *p_uart)
Rx Transfer completed callback.
hal_uart_abort_tx_cplt_callback
void hal_uart_abort_tx_cplt_callback(uart_handle_t *p_uart)
UART Abort Tansmit Complete callback.
hal_uart_get_state
hal_uart_state_t hal_uart_get_state(uart_handle_t *p_uart)
Return the UART handle state.