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