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
102 } hal_uart_state_t;
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
142 } uart_init_t;
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. */
189 } uart_handle_t;
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 */
216 } hal_uart_callback_t;
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_Fifo_Size UART Fifo Size
233 * @{
234 */
235 #define UART_TXFIFO_SIZE 128 /**< UART tx fifo size */
236 #define UART_RXFIFO_SIZE 128 /**< UART rx fifo size */
237 /** @} */
238
239 /** @defgroup UART_Error_Code UART Error Code
240 * @{
241 */
242 #define HAL_UART_ERROR_NONE (0x00000000U) /**< No error */
243 #define HAL_UART_ERROR_PE LL_UART_LSR_PE /**< Parity error */
244 #define HAL_UART_ERROR_FE LL_UART_LSR_FE /**< frame error */
245 #define HAL_UART_ERROR_OE LL_UART_LSR_OE /**< Overrun error */
246 #define HAL_UART_ERROR_BI LL_UART_LSR_BI /**< Break dection error */
247 #define HAL_UART_ERROR_DMA (0x00000100U) /**< DMA transfer error */
248 #define HAL_UART_ERROR_BUSY (0x00000200U) /**< Busy Error */
249 #define HAL_UART_ERROR_INVALID_PARAM (0x00000400U) /**< Invalid parameter error */
250 /** @} */
251
252 /** @defgroup UART_Data_Bits UART Number of Data Bits
253 * @{
254 */
255 #define UART_DATABITS_5 LL_UART_DATABITS_5B /**< UART frame with 5 data bits */
256 #define UART_DATABITS_6 LL_UART_DATABITS_6B /**< UART frame with 6 data bits */
257 #define UART_DATABITS_7 LL_UART_DATABITS_7B /**< UART frame with 7 data bits */
258 #define UART_DATABITS_8 LL_UART_DATABITS_8B /**< UART frame with 8 data bits */
259 /** @} */
260
261 /** @defgroup UART_Stop_Bits UART Number of Stop Bits
262 * @{
263 */
264 #define UART_STOPBITS_1 LL_UART_STOPBITS_1 /**< UART frame with 1 stop bit */
265 #define UART_STOPBITS_1_5 LL_UART_STOPBITS_1_5 /**< UART frame with 1.5 stop bits */
266 #define UART_STOPBITS_2 LL_UART_STOPBITS_2 /**< UART frame with 2 stop bits */
267 /** @} */
268
269 /** @defgroup UART_Parity UART Parity
270 * @{
271 */
272 #define UART_PARITY_NONE LL_UART_PARITY_NONE /**< No parity */
273 #define UART_PARITY_ODD LL_UART_PARITY_ODD /**< Odd parity */
274 #define UART_PARITY_EVEN LL_UART_PARITY_EVEN /**< Even parity */
275 #define UART_PARITY_SP0 LL_UART_PARITY_SP0 /**< Stick Parity 0 */
276 #define UART_PARITY_SP1 LL_UART_PARITY_SP1 /**< Stick Parity 1 */
277 /** @} */
278
279 /** @defgroup UART_Hardware_Flow_Control UART Hardware Flow Control
280 * @{
281 */
282 #define UART_HWCONTROL_NONE LL_UART_HWCONTROL_NONE /**< No hardware control */
283 #define UART_HWCONTROL_RTS_CTS LL_UART_HWCONTROL_RTS_CTS /**< Auto RTS and CTS hardware flow control */
284 /** @} */
285
286 /** @defgroup UART_Receiver_TimeOut UART Receiver TimeOut
287 * @{
288 */
289 #define UART_RECEIVER_TIMEOUT_DISABLE (0x00000000U) /**< UART receiver timeout disable */
290 #define UART_RECEIVER_TIMEOUT_ENABLE (0x00000001U) /**< UART receiver timeout enable */
291 /** @} */
292
293 /** @defgroup UART_Interrupt_definition UART Interrupt_definition
294 * @{
295 */
296 #define UART_IT_MS LL_UART_IER_MS /**< Enable Modem Status Interrupt */
297 #define UART_IT_RLS LL_UART_IER_RLS /**< Enable Receiver Line Status Interrupt */
298 #define UART_IT_THRE LL_UART_IER_THRE /**< Enable Transmit Holding Register Empty Interrupt */
299 #define UART_IT_RDA LL_UART_IER_RDA /**< Enable Received Data Available Interrupt and Character Timeout Interrupt */
300 /** @} */
301
302 /** @defgroup UART_Request_Parameters UART Request Parameters
303 * @{
304 */
305 #define UART_RXDATA_FLUSH_REQUEST UART_SRR_RFR /**< RX FIFO flush Request */
306 #define UART_TXDATA_FLUSH_REQUEST UART_SRR_XFR /**< TX FIFO flush Request */
307 #define UART_TXRXDATA_FLUSH_REQUEST (UART_SRR_XFR | UART_SRR_RFR) /**< TX FIFO and RX FIFO flush Request */
308 /** @} */
309
310 /** @defgroup UART_Interrupt_Mask UART Interrupt Flag Mask
311 * @{
312 */
313 #define UART_IT_MASK (0x008FU) /**< UART interruptions flags mask */
314 /** @} */
315
316 /** @defgroup UART_Line_Error_Mask UART Line Error Flag Mask
317 * @{
318 */
319 #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 */
320 /** @} */
321
322 /** @defgroup UART_Retention_Length UART Retention Register Length
323 * @{
324 */
325 #define UART_RETENTION_LENGTH ((uint32_t)8) /**< the number of retention registers */
326 /** @} */
327
328 /** @defgroup UART_Timeout_definition UART Timeout_definition
329 * @{
330 */
331 #define HAL_UART_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000) /**< 5s */
332 /** @} */
333
334 /** @} */
335
336 /* Exported macro ------------------------------------------------------------*/
337 /** @defgroup UART_Exported_Macros UART Exported Macros
338 * @{
339 */
340
341 /** @brief Reset UART handle states.
342 * @param __HANDLE__ UART handle.
343 * @retval None
344 */
345 #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) \
346 do{ \
347 (__HANDLE__)->g_state = HAL_UART_STATE_RESET; \
348 (__HANDLE__)->rx_state = HAL_UART_STATE_RESET; \
349 } while(0U)
350
351 /** @brief Enable the specified UART interrupt.
352 * @param __HANDLE__ Specifies the UART Handle.
353 * @param __INTERRUPT__ Specifies the UART interrupt source to enable.
354 * This parameter can be one of the following values:
355 * @arg @ref UART_IT_RDA
356 * @arg @ref UART_IT_THRE
357 * @arg @ref UART_IT_RLS
358 * @arg @ref UART_IT_MS
359 * @retval None
360 */
361 #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) \
362 do { \
363 GLOBAL_EXCEPTION_DISABLE(); \
364 ll_uart_enable_it((__HANDLE__)->p_instance, (__INTERRUPT__)); \
365 GLOBAL_EXCEPTION_ENABLE(); \
366 } while(0U)
367
368 /** @brief Disable the specified UART interrupt.
369 * @param __HANDLE__ Specifies the UART Handle.
370 * @param __INTERRUPT__ Specifies the UART interrupt source to disable.
371 * This parameter can be one of the following values:
372 * @arg @ref UART_IT_RDA
373 * @arg @ref UART_IT_THRE
374 * @arg @ref UART_IT_RLS
375 * @arg @ref UART_IT_MS
376 * @retval None
377 */
378 #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) \
379 do { \
380 GLOBAL_EXCEPTION_DISABLE(); \
381 ll_uart_disable_it((__HANDLE__)->p_instance, (__INTERRUPT__)); \
382 GLOBAL_EXCEPTION_ENABLE(); \
383 } while(0)
384
385 /** @brief Flush the UART FIFO and treat FIFO as empty.
386 * @param __HANDLE__ Specifies the UART Handle.
387 * @param __REQ__ Specifies the request flag to set
388 * This parameter can be one of the following values:
389 * @arg @ref UART_RXDATA_FLUSH_REQUEST RX FIFO flush Request
390 * @arg @ref UART_TXDATA_FLUSH_REQUEST TX FIFO flush Request
391 * @arg @ref UART_TXRXDATA_FLUSH_REQUEST TX FIFO and RX FIFO flush
392 * @retval None
393 */
394 #define __HAL_UART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->p_instance->SRR = (__REQ__))
395
396 /** @} */
397
398 /* Private macros ------------------------------------------------------------*/
399 /** @defgroup UART_Private_Macro UART Private Macros
400 * @{
401 */
402
403 /** @brief Check if UART Baudrate is valid.
404 * @param __BAUDRATE__ UART Baudrate.
405 * @retval SET (__BAUDRATE__ is valid) or RESET (__BAUDRATE__ is invalid)
406 */
407 #define IS_UART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 921600U)
408
409 /**
410 * @brief Check if UART frame number of stop bits is valid.
411 * @param __STOPBITS__ UART frame number of stop bits.
412 * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid)
413 */
414 #define IS_UART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == UART_STOPBITS_1) || \
415 ((__STOPBITS__) == UART_STOPBITS_1_5) || \
416 ((__STOPBITS__) == UART_STOPBITS_2))
417
418 /**
419 * @brief Check if UART frame number of data bits is valid.
420 * @param __DATABITS__ UART frame number of data bits.
421 * @retval SET (__DATABITS__ is valid) or RESET (__DATABITS__ is invalid)
422 */
423 #define IS_UART_DATABITS(__DATABITS__) (((__DATABITS__) == UART_DATABITS_5) || \
424 ((__DATABITS__) == UART_DATABITS_6) || \
425 ((__DATABITS__) == UART_DATABITS_7) || \
426 ((__DATABITS__) == UART_DATABITS_8))
427
428 /**
429 * @brief Check if UART frame parity is valid.
430 * @param __PARITY__ UART frame parity.
431 * @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid)
432 */
433 #define IS_UART_PARITY(__PARITY__) (((__PARITY__) == UART_PARITY_NONE) || \
434 ((__PARITY__) == UART_PARITY_EVEN) || \
435 ((__PARITY__) == UART_PARITY_ODD) || \
436 ((__PARITY__) == UART_PARITY_SP0) || \
437 ((__PARITY__) == UART_PARITY_SP1))
438
439 /**
440 * @brief Check if UART hardware flow control is valid.
441 * @param __CONTROL__ UART hardware flow control.
442 * @retval SET (__CONTROL__ is valid) or RESET (__CONTROL__ is invalid)
443 */
444 #define IS_UART_HARDWARE_FLOW_CONTROL(__CONTROL__)\
445 (((__CONTROL__) == UART_HWCONTROL_NONE) || \
446 ((__CONTROL__) == UART_HWCONTROL_RTS_CTS)
447 /** @} */
448
449 /**
450 * @brief Default configuartion for initializing structure
451 */
452 #define UART_DEFAULT_CONFIG \
453 { \
454 .baud_rate = 9600, \
455 .data_bits = UART_DATABITS_8, \
456 .stop_bits = UART_STOPBITS_1, \
457 .parity = UART_PARITY_NONE, \
458 .hw_flow_ctrl = UART_HWCONTROL_NONE, \
459 .rx_timeout_mode = UART_RECEIVER_TIMEOUT_DISABLE, \
460 }
461
462 /** @} */
463
464 /* Exported functions --------------------------------------------------------*/
465 /** @addtogroup HAL_UART_DRIVER_FUNCTIONS Functions
466 * @{
467 */
468
469 /** @addtogroup UART_Exported_Functions_Group1 Initialization and de-initialization functions
470 * @brief Initialization and de-initialization functions
471 *
472 * @verbatim
473 ===============================================================================
474 ##### Initialization and de-initialization functions #####
475 ===============================================================================
476 [..]
477 This subsection provides a set of functions allowing to initialize the UARTx.
478 (+) For the asynchronous mode the parameters below can be configured:
479 (++) Baud Rate
480 (++) Data Bit
481 (++) Stop Bit
482 (++) Parity
483 (++) Hardware flow control
484 [..]
485 The hal_uart_init() API follow the UART asynchronous configuration procedures.
486
487 @endverbatim
488 * @{
489 */
490
491 /**
492 ****************************************************************************************
493 * @brief Initialize the UART according to the specified
494 * parameters in the uart_init_t and initialize the associated handle.
495 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
496 * information for the specified UART module.
497 * @retval ::HAL_OK: Operation is OK.
498 * @retval ::HAL_ERROR: Parameter error or operation not supported.
499 * @retval ::HAL_BUSY: Driver is busy.
500 * @retval ::HAL_TIMEOUT: Timeout occurred.
501 ****************************************************************************************
502 */
503 hal_status_t hal_uart_init(uart_handle_t *p_uart);
504
505 /**
506 ****************************************************************************************
507 * @brief De-initialize the UART peripheral.
508 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
509 * information for the specified UART module.
510 * @retval ::HAL_OK: Operation is OK.
511 * @retval ::HAL_ERROR: Parameter error or operation not supported.
512 * @retval ::HAL_BUSY: Driver is busy.
513 * @retval ::HAL_TIMEOUT: Timeout occurred.
514 ****************************************************************************************
515 */
516 hal_status_t hal_uart_deinit (uart_handle_t *p_uart);
517
518 /**
519 ****************************************************************************************
520 * @brief Initialize the UART MSP.
521 * @note This function should not be modified. When the callback is needed,
522 the hal_uart_msp_init can be implemented in the user file.
523 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
524 * information for the specified UART module.
525 ****************************************************************************************
526 */
527 void hal_uart_msp_init(uart_handle_t *p_uart);
528
529 /**
530 ****************************************************************************************
531 * @brief De-initialize the UART MSP.
532 * @note This function should not be modified. When the callback is needed,
533 the hal_uart_msp_deinit can be implemented in the user file.
534 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
535 * information for the specified UART module.
536 ****************************************************************************************
537 */
538 void hal_uart_msp_deinit(uart_handle_t *p_uart);
539
540 /** @} */
541
542 /** @addtogroup UART_Exported_Functions_Group2 IO operation functions
543 * @brief UART Transmit/Receive functions
544 *
545 @verbatim
546 ===============================================================================
547 ##### IO operation functions #####
548 ===============================================================================
549 This subsection provides a set of functions allowing to manage the UART asynchronous
550 and Half duplex data transfers.
551
552 (#) There are two mode of transfer:
553 (++) Blocking mode: The communication is performed in polling mode.
554 The HAL status of all data processing is returned by the same function
555 after finishing transfer.
556 (++) Non-Blocking mode: The communication is performed using Interrupts
557 or DMA, These API's return the HAL status.
558 The end of the data processing will be indicated through the
559 dedicated UART IRQ when using Interrupt mode or the DMA IRQ when
560 using DMA mode.
561 The hal_uart_tx_cplt_callback(), hal_uart_rx_cplt_callback() user callbacks
562 will be executed respectively at the end of the transmit or Receive process
563 The hal_uart_error_callback() user callback will be executed when a
564 communication error is detected
565
566 (#) Blocking mode API's are :
567 (++) hal_uart_transmit()
568 (++) hal_uart_receive()
569
570 (#) Non-Blocking mode API's with Interrupt are :
571 (++) hal_uart_transmit_it()
572 (++) hal_uart_receive_it()
573 (++) hal_uart_irq_handler()
574
575 (#) Non-Blocking mode API's with DMA are :
576 (++) hal_uart_transmit_dma()
577 (++) hal_uart_receive_dma()
578 (++) hal_uart_dma_pause()
579 (++) hal_uart_dma_resume()
580 (++) hal_uart_dma_stop()
581
582 (#) A set of Transfer Complete Callbacks are provided in Non_Blocking mode:
583 (++) hal_uart_tx_cplt_callback()
584 (++) hal_uart_rx_cplt_callback()
585 (++) hal_uart_error_callback()
586
587 (#) Non-Blocking mode transfers could be aborted using Abort API's :
588 (++) hal_uart_abort()
589 (++) hal_uart_abort_transmit()
590 (++) hal_uart_abort_receive()
591 (++) hal_uart_abort_it()
592 (++) hal_uart_abort_transmit_it()
593 (++) hal_uart_abort_receive_it()
594
595 (#) For Abort services based on interrupts (hal_uart_abort_xxx_it), a set
596 of Abort Complete Callbacks are provided:
597 (++) hal_uart_abort_cplt_callback()
598 (++) hal_uart_abort_tx_cplt_callback()
599 (++) hal_uart_abort_rx_cplt_callback()
600
601 (#) In Non-Blocking mode transfers, possible errors are split into 2 categories.
602 Errors are handled as follows :
603 (++) Error is considered as Recoverable and non blocking. Transfer could go till end, but error severity is
604 to be evaluated by user : this concerns Frame Error, Parity Error or Noise Error in Interrupt mode reception .
605 Received character is then retrieved and stored in Rx buffer, Error code is set to allow user to identify error type,
606 and hal_uart_error_callback() user callback is executed. Transfer is kept ongoing on UART side.
607 If user wants to abort it, Abort services should be called by user.
608 (++) Error is considered as Blocking : Transfer could not be completed properly and is aborted.
609 This concerns Overrun Error In Interrupt mode reception and all errors in DMA mode.
610 Error code is set to allow user to identify error type, and hal_uart_error_callback() user callback is executed.
611
612 -@- In the Half duplex communication, it is forbidden to run the transmit
613 and receive process in parallel, the UART state hal_uart_state_busy_tx_rx can't be useful.
614
615 @endverbatim
616 * @{
617 */
618
619 /**
620 ****************************************************************************************
621 * @brief Send an amount of data in blocking mode.
622 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
623 * information for the specified UART module.
624 * @param[in] p_data: Pointer to data buffer.
625 * @param[in] size: Amount of data to be sent.
626 * @param[in] timeout: Timeout duration.
627 * @retval ::HAL_OK: Operation is OK.
628 * @retval ::HAL_ERROR: Parameter error or operation not supported.
629 * @retval ::HAL_BUSY: Driver is busy.
630 * @retval ::HAL_TIMEOUT: Timeout occurred.
631 ****************************************************************************************
632 */
633 hal_status_t hal_uart_transmit(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size, uint32_t timeout);
634
635 /**
636 ****************************************************************************************
637 * @brief Receive an amount of data in blocking mode.
638 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
639 * information for the specified UART module.
640 * @param[out] p_data: Pointer to data buffer.
641 * @param[in] size: Amount of data to be received.
642 * @param[in] timeout: Timeout duration.
643 * @retval ::HAL_OK: Operation is OK.
644 * @retval ::HAL_ERROR: Parameter error or operation not supported.
645 * @retval ::HAL_BUSY: Driver is busy.
646 * @retval ::HAL_TIMEOUT: Timeout occurred.
647 ****************************************************************************************
648 */
649 hal_status_t hal_uart_receive(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size, uint32_t timeout);
650
651 /**
652 ****************************************************************************************
653 * @brief Send an amount of data in interrupt mode.
654 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
655 * information for the specified UART module.
656 * @param[in] p_data: Pointer to data buffer.
657 * @param[in] size: Amount of data to be sent.
658 * @retval ::HAL_OK: Operation is OK.
659 * @retval ::HAL_ERROR: Parameter error or operation not supported.
660 * @retval ::HAL_BUSY: Driver is busy.
661 * @retval ::HAL_TIMEOUT: Timeout occurred.
662 ****************************************************************************************
663 */
664 hal_status_t hal_uart_transmit_it(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size);
665
666 /**
667 ****************************************************************************************
668 * @brief Receive an amount of data in interrupt mode.
669 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
670 * information for the specified UART module.
671 * @param[out] p_data: Pointer to data buffer.
672 * @param[in] size: Amount of data to be received.
673 * @retval ::HAL_OK: Operation is OK.
674 * @retval ::HAL_ERROR: Parameter error or operation not supported.
675 * @retval ::HAL_BUSY: Driver is busy.
676 * @retval ::HAL_TIMEOUT: Timeout occurred.
677 ****************************************************************************************
678 */
679 hal_status_t hal_uart_receive_it(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size);
680
681 /**
682 ****************************************************************************************
683 * @brief Send an amount of data in DMA mode.
684 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
685 * information for the specified UART module.
686 * @param[in] p_data: Pointer to data buffer.
687 * @param[in] size: Amount of data to be sent, ranging between 0 ~ 4095.
688 * @note This function starts a DMA transfer in interrupt mode meaning that
689 * DMA half transfer complete, DMA transfer complete and DMA transfer
690 * error interrupts are enabled
691 * @retval ::HAL_OK: Operation is OK.
692 * @retval ::HAL_ERROR: Parameter error or operation not supported.
693 * @retval ::HAL_BUSY: Driver is busy.
694 * @retval ::HAL_TIMEOUT: Timeout occurred.
695 ****************************************************************************************
696 */
697 hal_status_t hal_uart_transmit_dma(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size);
698
699
700 /**
701 ****************************************************************************************
702 * @brief Send an amount of data in DMA mode.
703 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
704 * information for the specified UART module.
705 * @param[in] p_data: Pointer to data buffer.
706 * @param[in] size: Amount of data to be sent, ranging between 0 ~ 4095.
707 * @param[in] sg_llp_config: The config of source and destination's SG and LLP.
708 * @note This function starts a DMA transfer in interrupt mode meaning that
709 * DMA half transfer complete, DMA transfer complete and DMA transfer
710 * error interrupts are enabled
711 * @retval ::HAL_OK: Operation is OK.
712 * @retval ::HAL_ERROR: Parameter error or operation not supported.
713 * @retval ::HAL_BUSY: Driver is busy.
714 * @retval ::HAL_TIMEOUT: Timeout occurred.
715 ****************************************************************************************
716 */
717 hal_status_t hal_uart_transmit_dma_sg_llp(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size, dma_sg_llp_config_t *sg_llp_config);
718
719
720 /**
721 ****************************************************************************************
722 * @brief Receive an amount of data in DMA mode.
723 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
724 * information for the specified UART module.
725 * @param[out] p_data: Pointer to data buffer.
726 * @param[in] size: Amount of data to be received, ranging between 0 and 4095.
727 * @note When the UART parity is enabled (PCE = 1), the received data contain
728 * the parity bit (MSB position).
729 * @note This function starts a DMA transfer in interrupt mode meaning that
730 * DMA half transfer complete, DMA transfer complete and DMA transfer
731 * error interrupts are enabled
732 * @retval ::HAL_OK: Operation is OK.
733 * @retval ::HAL_ERROR: Parameter error or operation not supported.
734 * @retval ::HAL_BUSY: Driver is busy.
735 * @retval ::HAL_TIMEOUT: Timeout occurred.
736 ****************************************************************************************
737 */
738 hal_status_t hal_uart_receive_dma(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size);
739
740
741 /**
742 ****************************************************************************************
743 * @brief Receive an amount of data in DMA mode.
744 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
745 * information for the specified UART module.
746 * @param[out] p_data: Pointer to data buffer.
747 * @param[in] size: Amount of data to be received, ranging between 0 and 4095.
748 * @param[in] sg_llp_config: The config of source and destination's SG and LLP.
749 * @note When the UART parity is enabled (PCE = 1), the received data contain
750 * the parity bit (MSB position).
751 * @note This function starts a DMA transfer in interrupt mode meaning that
752 * DMA half transfer complete, DMA transfer complete and DMA transfer
753 * error interrupts are enabled
754 * @retval ::HAL_OK: Operation is OK.
755 * @retval ::HAL_ERROR: Parameter error or operation not supported.
756 * @retval ::HAL_BUSY: Driver is busy.
757 * @retval ::HAL_TIMEOUT: Timeout occurred.
758 ****************************************************************************************
759 */
760 hal_status_t hal_uart_receive_dma_sg_llp(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size, dma_sg_llp_config_t *sg_llp_config);
761
762
763 /**
764 ****************************************************************************************
765 * @brief Pause the DMA Transfer.
766 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
767 * information for the specified UART module.
768 * @retval ::HAL_OK: Operation is OK.
769 * @retval ::HAL_ERROR: Parameter error or operation not supported.
770 * @retval ::HAL_BUSY: Driver is busy.
771 * @retval ::HAL_TIMEOUT: Timeout occurred.
772 ****************************************************************************************
773 */
774 hal_status_t hal_uart_dma_pause(uart_handle_t *p_uart);
775
776 /**
777 ****************************************************************************************
778 * @brief Resume the DMA Transfer.
779 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
780 * information for the specified UART module.
781 * @retval ::HAL_OK: Operation is OK.
782 * @retval ::HAL_ERROR: Parameter error or operation not supported.
783 * @retval ::HAL_BUSY: Driver is busy.
784 * @retval ::HAL_TIMEOUT: Timeout occurred.
785 ****************************************************************************************
786 */
787 hal_status_t hal_uart_dma_resume(uart_handle_t *p_uart);
788
789 /**
790 ****************************************************************************************
791 * @brief Stop the DMA Transfer.
792 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
793 * information for the specified UART module.
794 * @retval ::HAL_OK: Operation is OK.
795 * @retval ::HAL_ERROR: Parameter error or operation not supported.
796 * @retval ::HAL_BUSY: Driver is busy.
797 * @retval ::HAL_TIMEOUT: Timeout occurred.
798 ****************************************************************************************
799 */
800 hal_status_t hal_uart_dma_stop(uart_handle_t *p_uart);
801
802 /**
803 ****************************************************************************************
804 * @brief Abort ongoing transfers (blocking mode).
805 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
806 * information for the specified UART module.
807 * @note This procedure could be used for aborting any ongoing transfer started in Interrupt or DMA mode.
808 * This procedure performs following operations :
809 * - Disable UART Interrupts (Tx and Rx)
810 * - Disable the DMA transfer in the peripheral register (if enabled)
811 * - Abort DMA transfer by calling hal_dma_abort (in case of transfer in DMA mode)
812 * - Set handle State to READY
813 * @note This procedure is executed in blocking mode: when exiting function, Abort is considered as completed.
814 * @retval ::HAL_OK: Operation is OK.
815 * @retval ::HAL_ERROR: Parameter error or operation not supported.
816 * @retval ::HAL_BUSY: Driver is busy.
817 * @retval ::HAL_TIMEOUT: Timeout occurred.
818 ****************************************************************************************
819 */
820 hal_status_t hal_uart_abort(uart_handle_t *p_uart);
821
822 /**
823 ****************************************************************************************
824 * @brief Abort ongoing Transmit transfer (blocking mode).
825 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
826 * information for the specified UART module.
827 * @note This procedure could be used for aborting any ongoing Tx transfer started in Interrupt or DMA mode.
828 * This procedure performs following operations :
829 * - Disable UART Interrupts (Tx)
830 * - Disable the DMA transfer in the peripheral register (if enabled)
831 * - Abort DMA transfer by calling hal_dma_abort (in case of transfer in DMA mode)
832 * - Set handle State to READY
833 * @note This procedure is executed in blocking mode: when exiting function, Abort is considered as completed.
834 * @retval ::HAL_OK: Operation is OK.
835 * @retval ::HAL_ERROR: Parameter error or operation not supported.
836 * @retval ::HAL_BUSY: Driver is busy.
837 * @retval ::HAL_TIMEOUT: Timeout occurred.
838 ****************************************************************************************
839 */
840 hal_status_t hal_uart_abort_transmit(uart_handle_t *p_uart);
841
842 /**
843 ****************************************************************************************
844 * @brief Abort ongoing Receive transfer (blocking mode).
845 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
846 * information for the specified UART module.
847 * @note This procedure could be used for aborting any ongoing Rx transfer started in Interrupt or DMA mode.
848 * This procedure performs following operations :
849 * - Disable UART Interrupts (Rx)
850 * - Disable the DMA transfer in the peripheral register (if enabled)
851 * - Abort DMA transfer by calling hal_dma_abort (in case of transfer in DMA mode)
852 * - Set handle State to READY
853 * @note This procedure is executed in blocking mode: when exiting function, Abort is considered as completed.
854 * @retval ::HAL_OK: Operation is OK.
855 * @retval ::HAL_ERROR: Parameter error or operation not supported.
856 * @retval ::HAL_BUSY: Driver is busy.
857 * @retval ::HAL_TIMEOUT: Timeout occurred.
858 ****************************************************************************************
859 */
860 hal_status_t hal_uart_abort_receive(uart_handle_t *p_uart);
861
862 /**
863 ****************************************************************************************
864 * @brief Abort ongoing transfers (Interrupt mode).
865 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
866 * information for the specified UART module.
867 * @note This procedure could be used for aborting any ongoing transfer started in Interrupt or DMA mode.
868 * This procedure performs following operations :
869 * - Disable UART Interrupts (Tx and Rx)
870 * - Disable the DMA transfer in the peripheral register (if enabled)
871 * - Abort DMA transfer by calling hal_dma_abort_it (in case of transfer in DMA mode)
872 * - Set handle State to READY
873 * - At abort completion, call user abort complete callback
874 * @note This procedure is executed in Interrupt mode, meaning that abort procedure could be
875 * considered as completed only when user abort complete callback is executed (not when exiting function).
876 * @retval ::HAL_OK: Operation is OK.
877 * @retval ::HAL_ERROR: Parameter error or operation not supported.
878 * @retval ::HAL_BUSY: Driver is busy.
879 * @retval ::HAL_TIMEOUT: Timeout occurred.
880 ****************************************************************************************
881 */
882 hal_status_t hal_uart_abort_it(uart_handle_t *p_uart);
883
884 /**
885 ****************************************************************************************
886 * @brief Abort ongoing Transmit transfer (Interrupt mode).
887 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
888 * information for the specified UART module.
889 * @note This procedure could be used for aborting any ongoing Tx transfer started in Interrupt or DMA mode.
890 * This procedure performs following operations :
891 * - Disable UART Interrupts (Tx)
892 * - Disable the DMA transfer in the peripheral register (if enabled)
893 * - Abort DMA transfer by calling hal_dma_abort_it (in case of transfer in DMA mode)
894 * - Set handle State to READY
895 * - At abort completion, call user abort complete callback
896 * @note This procedure is executed in Interrupt mode, meaning that abort procedure could be
897 * considered as completed only when user abort complete callback is executed (not when exiting function).
898 * @retval ::HAL_OK: Operation is OK.
899 * @retval ::HAL_ERROR: Parameter error or operation not supported.
900 * @retval ::HAL_BUSY: Driver is busy.
901 * @retval ::HAL_TIMEOUT: Timeout occurred.
902 ****************************************************************************************
903 */
904 hal_status_t hal_uart_abort_transmit_it(uart_handle_t *p_uart);
905
906 /**
907 ****************************************************************************************
908 * @brief Abort ongoing Receive transfer (Interrupt mode).
909 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
910 * information for the specified UART module.
911 * @note This procedure could be used for aborting any ongoing Rx transfer started in Interrupt or DMA mode.
912 * This procedure performs following operations :
913 * - Disable UART Interrupts (Rx)
914 * - Disable the DMA transfer in the peripheral register (if enabled)
915 * - Abort DMA transfer by calling hal_dma_abort_it (in case of transfer in DMA mode)
916 * - Set handle State to READY
917 * - At abort completion, call user abort complete callback
918 * @note This procedure is executed in Interrupt mode, meaning that abort procedure could be
919 * considered as completed only when user abort complete callback is executed (not when exiting function).
920 * @retval ::HAL_OK: Operation is OK.
921 * @retval ::HAL_ERROR: Parameter error or operation not supported.
922 * @retval ::HAL_BUSY: Driver is busy.
923 * @retval ::HAL_TIMEOUT: Timeout occurred.
924 ****************************************************************************************
925 */
926 hal_status_t hal_uart_abort_receive_it(uart_handle_t *p_uart);
927
928 /** @} */
929
930 /** @addtogroup UART_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
931 * @brief IRQ Handler and Callbacks functions
932 * @{
933 */
934
935 /**
936 ****************************************************************************************
937 * @brief Handle UART interrupt request.
938 * @param[in] p_uart: Pointer to a UART handle which contains the configuration information
939 * for the specified UART module.
940 ****************************************************************************************
941 */
942 void hal_uart_irq_handler(uart_handle_t *p_uart);
943
944 /**
945 ****************************************************************************************
946 * @brief Tx Transfer completed callback.
947 * @note This function should not be modified. When the callback is needed,
948 * the hal_uart_tx_cplt_callback can be implemented in the user file.
949 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
950 * information for the specified UART module.
951 ****************************************************************************************
952 */
953 void hal_uart_tx_cplt_callback(uart_handle_t *p_uart);
954
955 /**
956 ****************************************************************************************
957 * @brief Rx Transfer completed callback.
958 * @note This function should not be modified. When the callback is needed,
959 * the hal_uart_rx_cplt_callback can be implemented in the user file.
960 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
961 * information for the specified UART module.
962 ****************************************************************************************
963 */
964 void hal_uart_rx_cplt_callback(uart_handle_t *p_uart);
965
966 /**
967 ****************************************************************************************
968 * @brief UART error callback.
969 * @note This function should not be modified. When the callback is needed,
970 * the hal_uart_error_callback can be implemented in the user file.
971 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
972 * information for the specified UART module.
973 ****************************************************************************************
974 */
975 void hal_uart_error_callback(uart_handle_t *p_uart);
976
977 /**
978 ****************************************************************************************
979 * @brief UART Abort Complete callback.
980 * @note This function should not be modified. When the callback is needed,
981 * the hal_uart_abort_cplt_callback can be implemented in the user file.
982 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
983 * information for the specified UART module.
984 ****************************************************************************************
985 */
986 void hal_uart_abort_cplt_callback (uart_handle_t *p_uart);
987
988 /**
989 ****************************************************************************************
990 * @brief UART Abort Tansmit Complete callback.
991 * @note This function should not be modified. When the callback is needed,
992 * the hal_uart_abort_tx_cplt_callback can be implemented in the user file.
993 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
994 * information for the specified UART module.
995 ****************************************************************************************
996 */
997 void hal_uart_abort_tx_cplt_callback (uart_handle_t *p_uart);
998
999 /**
1000 ****************************************************************************************
1001 * @brief UART Abort Receive Complete callback.
1002 * @note This function should not be modified. When the callback is needed,
1003 * the hal_uart_abort_rx_cplt_callback can be implemented in the user file.
1004 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
1005 * information for the specified UART module.
1006 ****************************************************************************************
1007 */
1008 void hal_uart_abort_rx_cplt_callback (uart_handle_t *p_uart);
1009
1010 /** @} */
1011
1012
1013 /** @addtogroup UART_Exported_Functions_Group3 Peripheral Control and State functions
1014 * @brief UART Peripheral State functions
1015 *
1016 @verbatim
1017 ==============================================================================
1018 ##### Peripheral Control and State functions #####
1019 ==============================================================================
1020 [..]
1021 This subsection provides functions allowing to :
1022 (+) Return the UART handle state.
1023 (+) Return the UART handle error code
1024
1025 @endverbatim
1026 * @{
1027 */
1028
1029 /**
1030 ****************************************************************************************
1031 * @brief Return the UART handle state.
1032 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
1033 * information for the specified UART module.
1034 * @retval ::HAL_UART_STATE_RESET: Peripheral is not initialized.
1035 * @retval ::HAL_UART_STATE_READY: Peripheral initialized and ready for use.
1036 * @retval ::HAL_UART_STATE_BUSY: An internal process is ongoing.
1037 * @retval ::HAL_UART_STATE_BUSY_TX: Data Transmission process is ongoing.
1038 * @retval ::HAL_UART_STATE_BUSY_RX: Data Reception process is ongoing.
1039 * @retval ::HAL_UART_STATE_TIMEOUT: Timeout state.
1040 * @retval ::HAL_UART_STATE_ERROR: Error.
1041 ****************************************************************************************
1042 */
1043 hal_uart_state_t hal_uart_get_state(uart_handle_t *p_uart);
1044
1045 /**
1046 ****************************************************************************************
1047 * @brief Return the UART handle error code.
1048 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
1049 * information for the specified UART module.
1050 * @return UART Error Code
1051 ****************************************************************************************
1052 */
1053 uint32_t hal_uart_get_error(uart_handle_t *p_uart);
1054
1055 /**
1056 ****************************************************************************************
1057 * @brief Suspend some registers related to UART configuration before sleep.
1058 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
1059 * information for the specified UART module.
1060 * @retval ::HAL_OK: Operation is OK.
1061 * @retval ::HAL_ERROR: Parameter error or operation not supported.
1062 * @retval ::HAL_BUSY: Driver is busy.
1063 * @retval ::HAL_TIMEOUT: Timeout occurred.
1064 ****************************************************************************************
1065 */
1066 hal_status_t hal_uart_suspend_reg(uart_handle_t *p_uart);
1067
1068 /**
1069 ****************************************************************************************
1070 * @brief Restore some registers related to UART configuration after sleep.
1071 * This function must be used in conjunction with the hal_uart_suspend_reg().
1072 * @param[in] p_uart: Pointer to a UART handle which contains the configuration
1073 * information for the specified UART module.
1074 * @retval ::HAL_OK: Operation is OK.
1075 * @retval ::HAL_ERROR: Parameter error or operation not supported.
1076 * @retval ::HAL_BUSY: Driver is busy.
1077 * @retval ::HAL_TIMEOUT: Timeout occurred.
1078 ****************************************************************************************
1079 */
1080 hal_status_t hal_uart_resume_reg(uart_handle_t *p_uart);
1081
1082
1083 /** @} */
1084
1085 /** @} */
1086
1087 #ifdef __cplusplus
1088 }
1089 #endif
1090
1091 #endif /* __GR55xx_HAL_UART_H__ */
1092
1093 /** @} */
1094
1095 /** @} */
1096
1097 /** @} */
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
hal_uart_transmit_dma_sg_llp
hal_status_t hal_uart_transmit_dma_sg_llp(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size, dma_sg_llp_config_t *sg_llp_config)
Send an amount of data in DMA mode.
_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).
dma_sg_llp_config
LL DMA sg and llp config definition.
Definition: gr55xx_hal_dma.h:219
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_receive_dma_sg_llp
hal_status_t hal_uart_receive_dma_sg_llp(uart_handle_t *p_uart, uint8_t *p_data, uint16_t size, dma_sg_llp_config_t *sg_llp_config)
Receive an amount of data in DMA 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:277
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.