GCC Code Coverage Report


Directory: src/drv/
File: src/drv/usart/src/usart_driver.c
Date: 2024-01-25 15:03:18
Exec Total Coverage
Lines: 0 219 0.0%
Branches: 0 148 0.0%

Line Branch Exec Source
1 /********************************************************************************************************//**
2 * @file usart_driver.c
3 *
4 * @brief File containing the APIs for configuring the USART peripheral.
5 *
6 * Public Functions:
7 * - void USART_Init(USART_Handle_t* pUSART_Handle)
8 * - void USART_DeInit(USART_RegDef_t* pUSARTx)
9 * - void USART_PerClkCtrl(USART_RegDef_t* pUSARTx, uint8_t en_or_di)
10 * - void USART_SendData(USART_Handle_t* pUSART_Handle, uint8_t* pTxBuffer, uint32_t len)
11 * - void USART_ReceiveData(USART_Handle_t* pUSART_Handle, uint8_t* pRxBuffer, uint32_t len)
12 * - uint8_t USART_SendDataIT(USART_Handle_t* pUSART_Handle, uint8_t* pTxBuffer, uint32_t len)
13 * - uint8_t USART_ReceiveDataIT(USART_Handle_t* pUSART_Handle, uint8_t* pRxBuffer, uint32_t len)
14 * - void USART_SetBaudRate(USART_RegDef_t* pUSARTx, uint32_t baudrate)
15 * - void USART_IRQHandling(USART_Handle_t* pUSART_Handle)
16 * - void USART_Enable(USART_RegDef_t* pUSARTx, uint8_t en_or_di)
17 * - uint8_t USART_GetFlagStatus(USART_RegDef_t* pUSARTx, uint32_t flagname)
18 * - void USART_ClearFlag(USART_RegDef_t* pUSARTx, uint16_t status_flagname)
19 * - void USART_ApplicationEventCallback(USART_Handle_t* pUSART_Handle, uint8_t app_event)
20 *
21 * @note
22 * For further information about functions refer to the corresponding header file.
23 */
24
25 #include <stdint.h>
26 #include <stddef.h>
27 #include "usart_driver.h"
28 #include "rcc_driver.h"
29
30 /***********************************************************************************************************/
31 /* Public API Definitions */
32 /***********************************************************************************************************/
33
34 void USART_Init(USART_Handle_t* pUSART_Handle){
35
36 uint32_t temp = 0;
37
38 /* Enable the peripheral clock */
39 USART_PerClkCtrl(pUSART_Handle->pUSARTx, ENABLE);
40
41 /* Enable USART TX and RX engines */
42 if(pUSART_Handle->USART_Config.USART_Mode == USART_MODE_ONLY_RX){
43 /* Enable receiver bit field */
44 temp |= (1 << USART_CR1_RE);
45 }
46 else if(pUSART_Handle->USART_Config.USART_Mode == USART_MODE_ONLY_TX){
47 /* Enable transmitter bit field */
48 temp |= (1 << USART_CR1_TE);
49 }
50 else if(pUSART_Handle->USART_Config.USART_Mode == USART_MODE_TXRX){
51 /* Enable both transmitter and receiver bit field */
52 temp |= ((1 << USART_CR1_TE) | (1 << USART_CR1_RE));
53 }
54 else{
55 /* do nothing */
56 }
57
58 /* Configure the word length */
59 temp |= pUSART_Handle->USART_Config.USART_WordLength << USART_CR1_M;
60
61 /* Configure parity control bit field */
62 if(pUSART_Handle->USART_Config.USART_ParityControl == USART_PARITY_EN_EVEN){
63 /* Enable parity control */
64 /* EVEN parity set by default, so no need to implement */
65 temp |= (1 << USART_CR1_PCE);
66 }
67 else if(pUSART_Handle->USART_Config.USART_ParityControl == USART_PARITY_EN_ODD){
68 /* Enable parity control */
69 temp |= (1 << USART_CR1_PCE);
70
71 /* Enable ODD parity */
72 temp |= (1 << USART_CR1_PS);
73 }
74 else{
75 /* do nothing */
76 }
77
78 /* Program CR1 register */
79 pUSART_Handle->pUSARTx->CR1 = temp;
80
81 temp = 0;
82
83 /* Configure stop bits */
84 temp |= pUSART_Handle->USART_Config.USART_NoOfStopBits << USART_CR2_STOP;
85
86 /* Program CR2 register */
87 pUSART_Handle->pUSARTx->CR2 = temp;
88
89 temp = 0;
90
91 /* Configure flow control */
92 if(pUSART_Handle->USART_Config.USART_HWFlowControl == USART_HW_FLOW_CTRL_CTS){
93 /* Enable CTS flow control */
94 temp |= (1 << USART_CR3_CTSE);
95 }
96 else if(pUSART_Handle->USART_Config.USART_HWFlowControl == USART_HW_FLOW_CTRL_RTS){
97 /* Enable RTS flow control */
98 temp |= (1 << USART_CR3_RTSE);
99 }
100 else if(pUSART_Handle->USART_Config.USART_HWFlowControl == USART_HW_FLOW_CTRL_CTS_RTS){
101 /*Enable CTS and RTS flow control */
102 temp |= (1 << USART_CR3_CTSE);
103 temp |= (1 << USART_CR3_RTSE);
104 }
105 else{
106 /* do nothing */
107 }
108
109 /* Program CR3 register */
110 pUSART_Handle->pUSARTx->CR3 = temp;
111
112 /* Configure baud rate */
113 USART_SetBaudRate(pUSART_Handle->pUSARTx, pUSART_Handle->USART_Config.USART_Baud);
114 }
115
116 void USART_DeInit(USART_RegDef_t* pUSARTx){
117
118 if(pUSARTx == USART1){
119 USART1_REG_RESET();
120 }
121 else if(pUSARTx == USART2){
122 USART2_REG_RESET();
123 }
124 else if(pUSARTx == USART3){
125 USART3_REG_RESET();
126 }
127 else if(pUSARTx == UART4){
128 UART4_REG_RESET();
129 }
130 else if(pUSARTx == UART5){
131 UART5_REG_RESET();
132 }
133 else if(pUSARTx == USART6){
134 USART6_REG_RESET();
135 }
136 else{
137 /* do nothing */
138 }
139 }
140
141 void USART_PerClkCtrl(USART_RegDef_t* pUSARTx, uint8_t en_or_di){
142
143 if(en_or_di == ENABLE){
144 if(pUSARTx == USART1){
145 USART1_PCLK_EN();
146 }
147 else if(pUSARTx == USART2){
148 USART2_PCLK_EN();
149 }
150 else if(pUSARTx == USART3){
151 USART3_PCLK_EN();
152 }
153 else if(pUSARTx == UART4){
154 UART4_PCLK_EN();
155 }
156 else if(pUSARTx == UART5){
157 UART5_PCLK_EN();
158 }
159 else if(pUSARTx == USART6){
160 USART6_PCLK_EN();
161 }
162 else{
163 /* do nothing */
164 }
165 }
166 else{
167 if(pUSARTx == USART1){
168 USART1_PCLK_DI();
169 }
170 else if(pUSARTx == USART2){
171 USART2_PCLK_DI();
172 }
173 else if(pUSARTx == USART3){
174 USART3_PCLK_DI();
175 }
176 else if(pUSARTx == UART4){
177 UART4_PCLK_DI();
178 }
179 else if(pUSARTx == UART5){
180 UART5_PCLK_DI();
181 }
182 else if(pUSARTx == USART6){
183 USART6_PCLK_DI();
184 }
185 else{
186 /* do nothing */
187 }
188 }
189 }
190
191 void USART_SendData(USART_Handle_t* pUSART_Handle, uint8_t* pTxBuffer, uint32_t len){
192
193 uint32_t i;
194 uint16_t* pdata;
195
196 /* Loop for transmitting len bytes */
197 for(i = 0; i < len; i++){
198 /* Wait until TXE flag is set in SR */
199 while(!USART_GetFlagStatus(pUSART_Handle->pUSARTx, USART_FLAG_TXE));
200
201 /* Check USART word length for 9 bits or 8 bits in a frame */
202 if(pUSART_Handle->USART_Config.USART_WordLength == USART_WORDLEN_9BITS){
203 /* If 9 bits load the DR with 2 bytes masking the bits other than first 9 bits */
204 pdata = (uint16_t*)pTxBuffer;
205 pUSART_Handle->pUSARTx->DR = (*pdata & (uint16_t)0x1FF);
206
207 /* Check for USART parity control */
208 if(pUSART_Handle->USART_Config.USART_ParityControl == USART_PARITY_DISABLE){
209 /* 9 bits of user data will be sent */
210 pTxBuffer++;
211 pTxBuffer++;
212 }
213 else{
214 /* 8 bits of user data will be sent */
215 /* 9th bit will be replaced by parity bit by hardware */
216 pTxBuffer++;
217 }
218 }
219 else{
220 /* 8 bits data transfer */
221 pUSART_Handle->pUSARTx->DR = (*pTxBuffer & (uint8_t)0xFF);
222
223 /* Increment buffer adddress */
224 pTxBuffer++;
225 }
226 }
227
228 /* Wait until TC flag is set in SR */
229 while(!USART_GetFlagStatus(pUSART_Handle->pUSARTx, USART_FLAG_TC));
230 }
231
232 void USART_ReceiveData(USART_Handle_t* pUSART_Handle, uint8_t* pRxBuffer, uint32_t len){
233
234 uint32_t i;
235
236 for(i = 0; i < len; i++){
237 /* Wait until RXNE flag is set in SR */
238 while(!USART_GetFlagStatus(pUSART_Handle->pUSARTx, USART_FLAG_RXNE));
239
240 /* Check USART word length for 9 bits or 8 bits in a frame */
241 if(pUSART_Handle->USART_Config.USART_WordLength == USART_WORDLEN_9BITS){
242 /* Reception of 9 bits data frame */
243 /* Check for USART parity control */
244 if(pUSART_Handle->USART_Config.USART_ParityControl == USART_PARITY_DISABLE){
245 /* 9 bits are user data */
246 *((uint16_t*)pRxBuffer) = (pUSART_Handle->pUSARTx->DR & (uint16_t)0x01FF);
247 /* Increment the pRxBuffer two times, once per byte */
248 pRxBuffer++;
249 pRxBuffer++;
250 }
251 else{
252 /* 8 bits are user data and 1 bit is parity */
253 *pRxBuffer = (pUSART_Handle->pUSARTx->DR & (uint8_t)0xFF);
254 pRxBuffer++;
255 }
256 }
257 else{
258 /* Reception of 8 bits data frame */
259 /* Check for USART parity control */
260 if(pUSART_Handle->USART_Config.USART_ParityControl == USART_PARITY_DISABLE){
261 /* 8 bits are user data */
262 *pRxBuffer = (uint8_t)(pUSART_Handle->pUSARTx->DR & (uint8_t)0xFF);
263 }
264 else{
265 /* 7 bits are user data and 1 bit is parity */
266 *pRxBuffer = (uint8_t)(pUSART_Handle->pUSARTx->DR & (uint8_t)0x7F);
267 }
268 pRxBuffer++;
269 }
270 }
271 }
272
273 uint8_t USART_SendDataIT(USART_Handle_t* pUSART_Handle, uint8_t* pTxBuffer, uint32_t len){
274
275 uint8_t txstate = pUSART_Handle->TxBusyState;
276
277 if(txstate != USART_BUSY_IN_TX){
278 pUSART_Handle->TxLen = len;
279 pUSART_Handle->pTxBuffer = pTxBuffer;
280 pUSART_Handle->TxBusyState = USART_BUSY_IN_TX;
281
282 /* Enable interrupt for TXE */
283 pUSART_Handle->pUSARTx->CR1 |= (1 << USART_CR1_TXEIE);
284
285 /* Enable interrupt for TC */
286 pUSART_Handle->pUSARTx->CR1 |= (1 << USART_CR1_TCIE);
287 }
288
289 return txstate;
290 }
291
292 uint8_t USART_ReceiveDataIT(USART_Handle_t* pUSART_Handle, uint8_t* pRxBuffer, uint32_t len){
293
294 uint8_t rxstate = pUSART_Handle->RxBusyState;
295
296 if(rxstate != USART_BUSY_IN_RX){
297 pUSART_Handle->RxLen = len;
298 pUSART_Handle->pRxBuffer = pRxBuffer;
299 pUSART_Handle->RxBusyState = USART_BUSY_IN_RX;
300
301 /* Enable interrupt for RXNE */
302 pUSART_Handle->pUSARTx->CR1 |= (1 << USART_CR1_RXNEIE);
303 }
304
305 return rxstate;
306 }
307
308 void USART_SetBaudRate(USART_RegDef_t* pUSARTx, uint32_t baudrate){
309
310 uint32_t PCLKx;
311 uint32_t usartdiv;
312 uint32_t mantissa, fraction;
313 uint32_t temp = 0;
314
315 /* Get the value of APB bus clock into the variable PCLKx */
316 if(pUSARTx == USART1 || pUSARTx == USART6){
317 /* USART1 and USART6 are hanging on APB2 bus */
318 PCLKx = RCC_GetPCLK2Value();
319 }
320 else{
321 PCLKx = RCC_GetPCLK1Value();
322 }
323
324 /* Check OVER8 config bit */
325 if(pUSARTx->CR1 & (1 << USART_CR1_OVER8)){
326 /* Over sampling by 8 */
327 usartdiv = ((25 * PCLKx) / (2 * baudrate));
328 }
329 else{
330 /* Over sampling by 16 */
331 usartdiv = ((25 * PCLKx) / (4 * baudrate));
332 }
333
334 /* Calculate the mantissa */
335 mantissa = usartdiv/100;
336 temp |= mantissa << 4;
337
338 /* Calculate the fraction part */
339 fraction = (usartdiv - (mantissa * 100));
340
341 if(pUSARTx->CR1 & (1 << USART_CR1_OVER8)){
342 /* Over sampling by 8 */
343 fraction = (((fraction * 8) + 50) / 100) & ((uint8_t)0x07);
344 }
345 else{
346 /* Over sampling by 16 */
347 fraction = (((fraction * 16) + 50) / 100) & ((uint8_t)0x0F);
348 }
349
350 temp |= fraction;
351
352 /* Set configuration in BRR register */
353 pUSARTx->BRR = temp;
354 }
355
356 void USART_IRQHandling(USART_Handle_t* pUSART_Handle){
357
358 uint32_t temp1, temp2, temp3;
359 uint32_t dummy_read;
360 uint16_t* pdata;
361
362 /* Handle for interrupt generated by TC event */
363
364 /* Check state of TC bit in SR */
365 temp1 = pUSART_Handle->pUSARTx->SR & (1 << USART_SR_TC);
366
367 /* Check state of TCIE bit in CR1 */
368 temp2 = pUSART_Handle->pUSARTx->CR1 & (1 << USART_CR1_TCIE);
369
370 if(temp1 && temp2){
371 /* Close transmission and call application callback if TxLen is zero */
372 if(pUSART_Handle->TxBusyState == USART_BUSY_IN_TX){
373 /* Check the TxLen */
374 if(!pUSART_Handle->TxLen){
375 /* Clear TC flag */
376 pUSART_Handle->pUSARTx->SR &= ~(1 << USART_SR_TC);
377 /* Clear TCIE control bit */
378 pUSART_Handle->pUSARTx->CR1 &= ~(1 << USART_CR1_TCIE);
379 /* Reset application state */
380 pUSART_Handle->TxBusyState = USART_READY;
381 /* Reset buffer adddress to NULL */
382 pUSART_Handle->pTxBuffer = NULL;
383 /* Reset length to zero */
384 pUSART_Handle->TxLen = 0;
385 /* Call application callback */
386 USART_ApplicationEventCallback(pUSART_Handle, USART_EVENT_TX_CMPLT);
387 }
388 }
389 }
390
391 /* Handle for interrupt generated by TXE event */
392
393 /* Check state of TXE bit in SR */
394 temp1 = pUSART_Handle->pUSARTx->SR & (1 << USART_SR_TXE);
395
396 /* Check state of TXEIE bit in CR1 */
397 temp2 = pUSART_Handle->pUSARTx->CR1 & (1 << USART_CR1_TXEIE);
398
399 if(temp1 && temp2){
400 if(pUSART_Handle->TxBusyState == USART_BUSY_IN_TX){
401 /* Keep sending data unitl TxLen reaches to zero */
402 if(pUSART_Handle->TxLen > 0){
403 /* Check USART word length for 9 bits or 8 bits in a frame */
404 if(pUSART_Handle->USART_Config.USART_WordLength == USART_WORDLEN_9BITS){
405 /* 9 bits data transfer */
406 /* Load the DR with 2 bytes masking the bits other than first 9 bits */
407 pdata = (uint16_t*)pUSART_Handle->pTxBuffer;
408 pUSART_Handle->pUSARTx->DR = (*pdata & (uint16_t)0x01FF);
409 /* Check parity control */
410 if(pUSART_Handle->USART_Config.USART_ParityControl == USART_PARITY_DISABLE){
411 /* 9 bits of user data will be sent */
412 pUSART_Handle->pTxBuffer++;
413 pUSART_Handle->pTxBuffer++;
414 pUSART_Handle->TxLen -= 2;
415 }
416 else{
417 /* 8 bits of user data will be sent */
418 /* 9th bit will be replaced by parity bit by HW */
419 pUSART_Handle->pTxBuffer++;
420 pUSART_Handle->TxLen--;
421 }
422 }
423 else{
424 /* 8 bits data transfer */
425 pUSART_Handle->pUSARTx->DR = (*pUSART_Handle->pTxBuffer & (uint8_t)0xFF);
426 pUSART_Handle->pTxBuffer++;
427 pUSART_Handle->TxLen--;
428 }
429 }
430 if(pUSART_Handle->TxLen == 0){
431 /* Clear TXEIE bit (disable interrupt for TXE flag) */
432 pUSART_Handle->pUSARTx->CR1 &= ~(1 << USART_CR1_TXEIE);
433 }
434 }
435 }
436
437 /* Handle for interrupt generated by RXNE event */
438
439 /* Check the state of RXNE bit in SR */
440 temp1 = pUSART_Handle->pUSARTx->SR & (1 << USART_SR_RXNE);
441 /* Check the state of RXNEIE bit in CR1 */
442 temp2 = pUSART_Handle->pUSARTx->CR1 & (1 << USART_CR1_RXNEIE);
443
444 if(temp1 & temp2){
445 if(pUSART_Handle->RxBusyState == USART_BUSY_IN_RX){
446 if(pUSART_Handle->RxLen > 0){
447 /* Check USART word length for receiving 9 bits or 8 bits of data frame */
448 if(pUSART_Handle->USART_Config.USART_WordLength == USART_WORDLEN_9BITS){
449 /* 9 bits data in a frame */
450 /* Check parity control */
451 if(pUSART_Handle->USART_Config.USART_ParityControl == USART_PARITY_DISABLE){
452 /* 9 bits will be of user data */
453 *((uint16_t*)pUSART_Handle->pRxBuffer) = (pUSART_Handle->pUSARTx->DR &
454 (uint16_t)0x01FF);
455 pUSART_Handle->pRxBuffer++;
456 pUSART_Handle->pRxBuffer++;
457 pUSART_Handle->RxLen -= 2;
458 }
459 else{
460 /* 8 bits will be of user data and 1 bit is parity */
461 *pUSART_Handle->pRxBuffer = (pUSART_Handle->pUSARTx->DR & (uint8_t)0xFF);
462 pUSART_Handle->pRxBuffer++;
463 pUSART_Handle->RxLen--;
464 }
465 }
466 else{
467 /* 8 bits data in a frame */
468 /* Check parity control */
469 if(pUSART_Handle->USART_Config.USART_ParityControl == USART_PARITY_DISABLE){
470 /* 8 bits will be of user data */
471 *pUSART_Handle->pRxBuffer = (uint8_t)(pUSART_Handle->pUSARTx->DR & (uint8_t)0xFF);
472 }
473 else{
474 /* 7 bits will be of user data and 1 bit is parity */
475 *pUSART_Handle->pRxBuffer = (uint8_t)(pUSART_Handle->pUSARTx->DR & (uint8_t)0x7F);
476 }
477 pUSART_Handle->pRxBuffer++;
478 pUSART_Handle->RxLen--;
479 }
480 }
481
482 if(!pUSART_Handle->RxLen){
483 /* Disable RXNE */
484 pUSART_Handle->pUSARTx->CR1 &= ~(1 << USART_CR1_RXNEIE);
485 /* Reset application state */
486 pUSART_Handle->RxBusyState = USART_READY;
487 /* Call application callback */
488 USART_ApplicationEventCallback(pUSART_Handle, USART_EVENT_RX_CMPLT);
489 }
490 }
491 }
492
493 /* Handle for interrupt generated by CTS event */
494 /* Note: CTS feature is not applicable for UART4 and UART5 */
495
496 /* Check the state of CTS bit in SR */
497 temp1 = pUSART_Handle->pUSARTx->SR & (1 << USART_SR_CTS);
498
499 /* Check the state of CTSE bit in CR3 */
500 temp2 = pUSART_Handle->pUSARTx->CR1 & (1 << USART_CR3_CTSE);
501
502 /* Check the state of CTSIE bit in CR3 (not available in UART4 and UART5 */
503 temp3 = pUSART_Handle->pUSARTx->CR3 & (1 << USART_CR3_CTSIE);
504
505 if(temp1 && temp2 && temp3){
506 /* Clear CTS flag in SR */
507 pUSART_Handle->pUSARTx->SR &= ~(1 << USART_SR_CTS);
508 /* Call application callback */
509 USART_ApplicationEventCallback(pUSART_Handle, USART_EVENT_CTS);
510 }
511
512 /* Handle for interrupt generated by IDLE event */
513
514 /* Check the state of IDLE bit in SR */
515 temp1 = pUSART_Handle->pUSARTx->SR & (1 << USART_SR_IDLE);
516
517 /* Check the state of IDLEIE bit in CR1 */
518 temp2 = pUSART_Handle->pUSARTx->CR1 & (1 << USART_CR1_IDLEIE);
519
520 if(temp1 && temp2){
521 /* Clear IDLE flag in SR */
522 dummy_read = pUSART_Handle->pUSARTx->SR;
523 dummy_read = pUSART_Handle->pUSARTx->DR;
524 (void)dummy_read;
525
526 /* Call application callback */
527 USART_ApplicationEventCallback(pUSART_Handle, USART_EVENT_IDLE);
528 }
529
530 /* Handle for interrupt generated by overrun event */
531
532 /* Check the state of ORE bit in SR */
533 temp1 = pUSART_Handle->pUSARTx->SR & (1 << USART_SR_ORE);
534
535 /* Check the state of RXNEIE bit in CR1 */
536 temp2 = pUSART_Handle->pUSARTx->CR1 & (1 << USART_CR1_RXNEIE);
537
538 if(temp1 && temp2){
539 /* Clear ORE flag in SR */
540 dummy_read = pUSART_Handle->pUSARTx->SR;
541 dummy_read = pUSART_Handle->pUSARTx->DR;
542 (void)dummy_read;
543
544 /* Call application callback */
545 USART_ApplicationEventCallback(pUSART_Handle, USART_ERROR_ORE);
546 }
547
548 /* Handle for interrupt generated by error event */
549 /* Note: EIE bit is required to enable interrupt generation in case of a framing error, */
550 /* overrun error or noise flag in case of Multi Buffer Communication */
551
552 /* Check the state of EIE bit in CR3 */
553 temp1 = pUSART_Handle->pUSARTx->CR3 & (1 << USART_CR3_EIE);
554
555 if(temp1){
556 temp2 = pUSART_Handle->pUSARTx->SR;
557 if(temp2 & (1 << USART_SR_FE)){
558 USART_ApplicationEventCallback(pUSART_Handle, USART_ERROR_FE);
559 }
560
561 if(temp2 & (1 << USART_SR_NF)){
562 USART_ApplicationEventCallback(pUSART_Handle, USART_ERROR_NF);
563 }
564
565 if(temp2 & (1 << USART_SR_ORE)){
566 USART_ApplicationEventCallback(pUSART_Handle, USART_ERROR_ORE);
567 }
568 }
569 }
570
571 void USART_Enable(USART_RegDef_t* pUSARTx, uint8_t en_or_di){
572
573 if(en_or_di == ENABLE){
574 pUSARTx->CR1 |= (1 << USART_CR1_UE);
575 }
576 else{
577 pUSARTx->CR1 &= ~(1 << USART_CR1_UE);
578 }
579 }
580
581 uint8_t USART_GetFlagStatus(USART_RegDef_t* pUSARTx, uint32_t flagname){
582
583 if(pUSARTx->SR & flagname){
584 return SET;
585 }
586
587 return RESET;
588 }
589
590 void USART_ClearFlag(USART_RegDef_t* pUSARTx, uint16_t status_flagname){
591
592 (void)pUSARTx;
593 (void)status_flagname;
594 }
595
596 __attribute__((weak)) void USART_ApplicationEventCallback(USART_Handle_t* pUSART_Handle, uint8_t app_event){
597
598 /* This is a weak implementation. The application may override this function */
599 (void)pUSART_Handle;
600 (void)app_event;
601 }
602