Infineon MOTIX™ MCU TLE988x/9x Device Family SDK
uart.h
Go to the documentation of this file.
1 /*
2  ***********************************************************************************************************************
3  *
4  * Copyright (c) Infineon Technologies AG
5  * All rights reserved.
6  *
7  * The applicable license agreement can be found at this pack's installation directory in the file
8  * license/IFX_SW_Licence_MOTIX_LITIX.txt
9  *
10  **********************************************************************************************************************/
26 /*******************************************************************************
27 ** Author(s) Identity **
28 ********************************************************************************
29 ** Initials Name **
30 ** ---------------------------------------------------------------------------**
31 ** DM Daniel Mysliwitz **
32 ** BG Blandine Guillot **
33 ** JO Julia Ott **
34 ** PS Patrik Schwarz **
35 *******************************************************************************/
36 
37 /*******************************************************************************
38 ** Revision Control History **
39 ********************************************************************************
40 ** V0.1.0: 2019-10-28, DM: Initial version **
41 ** V0.2.0: 2020-04-28, BG: Updated revision history format **
42 ** V0.3.0: 2020-05-22, BG: Added first functions **
43 ** V0.4.0: 2020-07-10, BG: Added inline functions list **
44 ** V0.4.1: 2020-09-16, BG: Added interrupt enable/disable functions **
45 ** V0.4.2: 2020-10-06, BG: EP-492: Removed MISRA 2012 errors **
46 ** V0.4.3: 2020-10-16, JO: EP-523: Updated parameter names **
47 ** V0.4.4: 2020-10-21, BG: EP-539: Considered the enable checkbox in CW in **
48 ** the initialization function **
49 ** V0.4.5: 2020-11-12, JO: EP-590: Removed \param none and \return none to **
50 ** avoid doxygen warning **
51 ** Added end of group for doxygen **
52 ** V0.4.6: 2020-11-20, BG: EP-610: Corrected MISRA 2012 errors **
53 ** The following rules are globally deactivated: **
54 ** - Info 774: Boolean within 'if' always evaluates **
55 ** to False/True **
56 ** V0.4.7: 2020-12-10, BG: EP-622: Updated setTXBuffer functions **
57 ** V0.4.8: 2020-12-18, BG: EP-652: Corrected name of error code variable **
58 ** V0.4.9: 2021-01-19, BG: EP-660: Corrected UARTx_setTXBuffer **
59 ** Added functions to enable/disable baudrate **
60 ** generator **
61 ** Corrected initialization to set the bit BR_R **
62 ** separately **
63 ** V0.5.0: 2021-04-06, BG: EP-760: Replaced if instructions to check if the **
64 ** module is enabled with preprocessor directives to**
65 ** avoid compiler warnings **
66 ** V0.5.1: 2021-04-23, EE: EP-676: Added stdout_putchar function to put **
67 ** a character to stdout **
68 ** V0.5.2: 2021-06-02, BG: EP-833: Added if conditions for the functions **
69 ** related to STDIN/STDOUT **
70 ** V0.5.3: 2021-06-16, BG: EP-839: Added stdin_getchar() **
71 ** V0.5.4: 2021-07-21, BG: EP-872: Corrected functions to set a user-defined**
72 ** baudrate: UART{0/1}_setBaudrate(u32_baudrate) **
73 ** V0.5.5: 2021-07-30, BG: EP-877: Corrected MISRA 2012 errors **
74 ** V0.5.6: 2021-10-19, JO: EP-810: Updated init functions for unit testing **
75 ** V0.5.7: 2021-10-20, JO: EP-966: Corrected functions UARTx_getBaudrate **
76 ** V0.5.8: 2021-11-12, JO: EP-937: Updated copyright and branding **
77 ** V0.5.9: 2022-06-23, JO: EP-1150: Removed ARMCC V6.18 warnings **
78 ** V0.6.0: 2023-04-04, PS: EP-1141: Corrected MISRA warnings **
79 ** V0.6.1: 2023-11-29, JO: EP-1448: Added initialization of UARTx->LINCON **
80 ** V0.6.2: 2024-11-05, JO: EP-1494: Updated license **
81 *******************************************************************************/
82 
83 #ifndef _UART_H
84 #define _UART_H
85 
86 /*******************************************************************************
87 ** Includes **
88 *******************************************************************************/
89 
90 #include "types.h"
91 #include "tle989x.h"
92 #include "tle_variants.h"
93 #include "uart_defines.h"
94 #include "scu_defines.h"
95 #include "isr_defines.h"
96 
97 /*******************************************************************************
98 ** Global Constant Declarations **
99 *******************************************************************************/
100 
101 /*******************************************************************************
102 ** Global Type Declarations **
103 *******************************************************************************/
104 
105 /*******************************************************************************
106 ** Global Macro Declarations **
107 *******************************************************************************/
108 
109 /*******************************************************************************
110 ** Global Function Declarations **
111 *******************************************************************************/
112 
113 sint8 UART0_init(void);
114 sint8 UART1_init(void);
117 sint8 UART0_setBaudrate(uint32 u32_baudrate);
118 sint8 UART1_setBaudrate(uint32 u32_baudrate);
119 #if ((UART0_STD_EN == 1) || (UART1_STD_EN == 1))
120  sint32 stdout_putchar(sint32 character);
121  sint32 stdin_getchar(void);
122 #endif
124 INLINE void UART0_setTXbuffer(uint16 u16_value);
126 INLINE void UART1_setTXbuffer(uint16 u16_value);
127 INLINE bool UART0_isByteReceived(void);
129 INLINE bool UART1_isByteReceived(void);
131 INLINE void UART0_enBaudrateGen(void);
132 INLINE void UART0_disBaudrateGen(void);
133 INLINE void UART1_enBaudrateGen(void);
134 INLINE void UART1_disBaudrateGen(void);
135 INLINE void UART0_startTX(void);
136 INLINE void UART1_startTX(void);
137 INLINE void UART0_enTXInt(void);
138 INLINE void UART0_enRXErrInt(void);
139 INLINE void UART0_enSyncErrInt(void);
140 INLINE void UART0_enEOSInt(void);
141 INLINE void UART0_disTXInt(void);
142 INLINE void UART0_disRXErrInt(void);
143 INLINE void UART0_disSyncErrInt(void);
144 INLINE void UART0_disEOSInt(void);
145 INLINE void UART1_enTXInt(void);
146 INLINE void UART1_enRXErrInt(void);
147 INLINE void UART1_enSyncErrInt(void);
148 INLINE void UART1_enEOSInt(void);
149 INLINE void UART1_disTXInt(void);
150 INLINE void UART1_disRXErrInt(void);
151 INLINE void UART1_disSyncErrInt(void);
152 INLINE void UART1_disEOSInt(void);
157 INLINE void UART0_clrTXIntSts(void);
158 INLINE void UART0_clrRXIntSts(void);
159 INLINE void UART0_clrSyncErrIntSts(void);
160 INLINE void UART0_clrEOFIntSts(void);
165 INLINE void UART1_clrTXIntSts(void);
166 INLINE void UART1_clrRXIntSts(void);
167 INLINE void UART1_clrSyncErrIntSts(void);
168 INLINE void UART1_clrEOFIntSts(void);
169 
170 /*******************************************************************************
171 ** Deprecated Function Declarations **
172 *******************************************************************************/
173 
177 void UART0_setTXIntSts(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
178 
182 void UART0_setRXIntSts(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
183 
187 void UART0_setSyncErrIntSts(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
188 
192 void UART0_setEOFIntSts(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
193 
197 void UART1_setTXIntSts(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
198 
202 void UART1_setRXIntSts(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
203 
207 void UART1_setSyncErrIntSts(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
208 
212 void UART1_setEOFIntSts(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
213 
214 /*******************************************************************************
215 ** Global Inline Function Definitions **
216 *******************************************************************************/
217 
223 {
225  return (uint16)(UART0->RXBUF.reg);
226 }
227 
233 {
235  UART0->TXBUF.reg = u16_value;
236 }
237 
243 {
245  return (uint16)(UART1->RXBUF.reg);
246 }
247 
253 {
255  UART1->TXBUF.reg = u16_value;
256 }
257 
263 {
264  //lint --e{9034}
265  bool result = false;
266 
267  if (UART0_getRXIntSts() == 1u)
268  {
269  result = true;
270  }
271 
272  return result;
273 }
274 
280 {
281  //lint --e{9034}
282  bool result = false;
283 
284  if (UART0_getTXIntSts() == 1u)
285  {
286  result = true;
287  }
288 
289  return result;
290 }
291 
297 {
298  //lint --e{9034}
299  bool result = false;
300 
301  if (UART1_getRXIntSts() == 1u)
302  {
303  result = true;
304  }
305 
306  return result;
307 }
308 
314 {
315  //lint --e{9034}
316  bool result = false;
317 
318  if (UART1_getTXIntSts() == 1u)
319  {
320  result = true;
321  }
322 
323  return result;
324 }
325 
329 {
330  UART0->BCON.bit.BR_R = 1u;
331 }
332 
336 {
337  UART0->BCON.bit.BR_R = 0u;
338 }
339 
343 {
344  UART1->BCON.bit.BR_R = 1u;
345 }
346 
350 {
351  UART1->BCON.bit.BR_R = 0u;
352 }
353 
357 {
358  UART0->TSTART.bit.TXSTART = 1u;
359 }
360 
364 {
365  UART1->TSTART.bit.TXSTART = 1u;
366 }
367 
371 {
372  UART0->IEN.bit.TIEN = 1u;
373 }
374 
378 {
379  UART0->IEN.bit.RIEN = 1u;
380 }
381 
385 {
386  UART0->IEN.bit.ERRSYNEN = 1u;
387 }
388 
392 {
393  UART0->IEN.bit.EOFSYNEN = 1u;
394 }
395 
399 {
400  UART0->IEN.bit.TIEN = 0u;
401 }
402 
406 {
407  UART0->IEN.bit.RIEN = 0u;
408 }
409 
413 {
414  UART0->IEN.bit.ERRSYNEN = 0u;
415 }
416 
420 {
421  UART0->IEN.bit.EOFSYNEN = 0u;
422 }
423 
427 {
428  UART1->IEN.bit.TIEN = 1u;
429 }
430 
434 {
435  UART1->IEN.bit.RIEN = 1u;
436 }
437 
441 {
442  UART1->IEN.bit.ERRSYNEN = 1u;
443 }
444 
448 {
449  UART1->IEN.bit.EOFSYNEN = 1u;
450 }
451 
455 {
456  UART1->IEN.bit.TIEN = 0u;
457 }
458 
462 {
463  UART1->IEN.bit.RIEN = 0u;
464 }
465 
469 {
470  UART1->IEN.bit.ERRSYNEN = 0u;
471 }
472 
476 {
477  UART1->IEN.bit.EOFSYNEN = 0u;
478 }
479 
485 {
486  return (uint8)UART0->IS.bit.TI;
487 }
488 
494 {
495  return (uint8)UART0->IS.bit.RI;
496 }
497 
503 {
504  return (uint8)UART0->IS.bit.ERRSYN;
505 }
506 
512 {
513  return (uint8)UART0->IS.bit.EOFSYN;
514 }
515 
519 {
520  UART0->ISC.bit.TICLR = 1u;
521 }
522 
526 {
527  UART0->ISC.bit.RICLR = 1u;
528 }
529 
533 {
534  UART0->ISC.bit.ERRSYNCLR = 1u;
535 }
536 
540 {
541  UART0->ISC.bit.EOFSYNCLR = 1u;
542 }
543 
549 {
550  return (uint8)UART1->IS.bit.TI;
551 }
552 
558 {
559  return (uint8)UART1->IS.bit.RI;
560 }
561 
567 {
568  return (uint8)UART1->IS.bit.ERRSYN;
569 }
570 
576 {
577  return (uint8)UART1->IS.bit.EOFSYN;
578 }
579 
583 {
584  UART1->ISC.bit.TICLR = 1u;
585 }
586 
590 {
591  UART1->ISC.bit.RICLR = 1u;
592 }
593 
597 {
598  UART1->ISC.bit.ERRSYNCLR = 1u;
599 }
600 
604 {
605  UART1->ISC.bit.EOFSYNCLR = 1u;
606 }
607 
610 #endif /* _UART_H */
#define UART0
Definition: tle989x.h:24081
#define UART1
Definition: tle989x.h:24082
sint8 UART1_setBaudrate(uint32 u32_baudrate)
Set the baudrate for UART1.
Definition: uart.c:293
void UART1_setEOFIntSts(void) __attribute__((deprecated("Do not change this at runtime
Set UART1 End Of Sync Interrupt Node Pointer.
INLINE void UART1_clrSyncErrIntSts(void)
Clear the UART1 Sync Error Interrupt Status, UART1.ISC.ERRSYNCLR.
Definition: uart.h:596
void UART1_setRXIntSts(void) __attribute__((deprecated("Do not change this at runtime
Set UART1 RX Interrupt Node Pointer.
INLINE uint8 UART1_getTXIntSts(void)
Get the UART1 Empty Transmit Buffer Interrupt Status, UART1.IS.TI.
Definition: uart.h:548
uint32 UART1_getBaudrate(void)
Get the baudrate for UART1 Transform equation (SCU_fUART_MHz * 1000000 / (16 * (1U << (uint8)UART1->B...
Definition: uart.c:139
INLINE void UART0_setTXbuffer(uint16 u16_value)
Set the UART0 TX buffer value.
Definition: uart.h:232
void UART0_setSyncErrIntSts(void) __attribute__((deprecated("Do not change this at runtime
Set UART0 Sync Error Interrupt Node Pointer.
INLINE void UART0_clrSyncErrIntSts(void)
Clear the UART0 Sync Error Interrupt Status, UART0.ISC.ERRSYNCLR.
Definition: uart.h:532
INLINE void UART1_setTXbuffer(uint16 u16_value)
Set the UART1 TX buffer value.
Definition: uart.h:252
void UART1_setSyncErrIntSts(void) __attribute__((deprecated("Do not change this at runtime
Set UART1 Sync Error Interrupt Node Pointer.
INLINE bool UART1_isByteTransmitted(void)
Check if UART1 has transmitted a byte.
Definition: uart.h:313
void UART0_setEOFIntSts(void) __attribute__((deprecated("Do not change this at runtime
Set UART0 End Of Sync Interrupt Node Pointer.
INLINE void UART1_disEOSInt(void)
Disable UART1 End of Sync Interrupt.
Definition: uart.h:475
INLINE void UART0_enRXErrInt(void)
Enable UART0 Receive Interrupt.
Definition: uart.h:377
INLINE void UART1_clrTXIntSts(void)
Clear the UART1 Empty Transmit Buffer Interrupt Status, UART1.ISC.TICLR.
Definition: uart.h:582
sint8 UART0_setBaudrate(uint32 u32_baudrate)
Set the baudrate for UART0.
Definition: uart.c:276
INLINE bool UART0_isByteTransmitted(void)
Check if UART0 has transmitted a byte.
Definition: uart.h:279
INLINE bool UART1_isByteReceived(void)
Check if UART1 has received a byte.
Definition: uart.h:296
INLINE void UART1_disSyncErrInt(void)
Disable UART1 Sync Error Interrupt.
Definition: uart.h:468
INLINE uint8 UART1_getSyncErrIntSts(void)
Get the UART1 Sync Error Interrupt Status, UART1.IS.ERRSYN.
Definition: uart.h:566
INLINE void UART0_disEOSInt(void)
Disable UART0 End of Sync Interrupt.
Definition: uart.h:419
INLINE void UART1_clrEOFIntSts(void)
Clear the UART1 End of Sync Interrupt Status, UART1.ISC.EOFSYNCLR.
Definition: uart.h:603
INLINE bool UART0_isByteReceived(void)
Check if UART0 has received a byte.
Definition: uart.h:262
INLINE void UART0_clrRXIntSts(void)
Clear the UART0 Empty Receive Buffer Interrupt Status, UART0.ISC.RICLR.
Definition: uart.h:525
INLINE void UART1_enRXErrInt(void)
Enable UART1 Receive Interrupt.
Definition: uart.h:433
INLINE void UART0_clrTXIntSts(void)
Clear the UART0 Empty Transmit Buffer Interrupt Status, UART0.ISC.TICLR.
Definition: uart.h:518
INLINE void UART0_enBaudrateGen(void)
Enable the baudrate generator, UART0.BCON.BR_R.
Definition: uart.h:328
void UART0_setTXIntSts(void) __attribute__((deprecated("Do not change this at runtime
Set UART0 TX Interrupt Node Pointer.
INLINE void UART1_disBaudrateGen(void)
Disable the baudrate generator, UART1.BCON.BR_R.
Definition: uart.h:349
INLINE uint8 UART0_getSyncErrIntSts(void)
Get the UART0 Sync Error Interrupt Status, UART0.IS.ERRSYN.
Definition: uart.h:502
INLINE void UART0_disTXInt(void)
Disable UART0 Transmit Interrupt.
Definition: uart.h:398
INLINE uint8 UART1_getRXIntSts(void)
Get the UART1 Empty Receive Buffer Interrupt Status, UART1.IS.RI.
Definition: uart.h:557
INLINE void UART1_enBaudrateGen(void)
Enable the baudrate generator, UART1.BCON.BR_R.
Definition: uart.h:342
INLINE void UART1_enEOSInt(void)
Enable UART1 End of Sync Interrupt.
Definition: uart.h:447
INLINE uint8 UART1_getEOFIntSts(void)
Get the UART1 End of Sync Interrupt Status, UART1.IS.EOFSYN.
Definition: uart.h:575
INLINE uint16 UART0_getRXbuffer(void)
Get the UART0 RX buffer value.
Definition: uart.h:222
uint32 UART0_getBaudrate(void)
Get the baudrate for UART0 Transform equation (SCU_fUART_MHz * 1000000 / (16 * (1U << (uint8)UART0->B...
Definition: uart.c:125
void UART0_setRXIntSts(void) __attribute__((deprecated("Do not change this at runtime
Set UART0 RX Interrupt Node Pointer.
INLINE void UART0_startTX(void)
Start the transmission, UART0.TSTART.TXSTART.
Definition: uart.h:356
INLINE void UART0_enTXInt(void)
Enable UART0 Transmit Interrupt.
Definition: uart.h:370
INLINE uint8 UART0_getTXIntSts(void)
Get the UART0 Empty Transmit Buffer Interrupt Status, UART0.IS.TI.
Definition: uart.h:484
INLINE void UART0_enEOSInt(void)
Enable UART0 End of Sync Interrupt.
Definition: uart.h:391
INLINE void UART1_enTXInt(void)
Enable UART1 Transmit Interrupt.
Definition: uart.h:426
INLINE void UART1_enSyncErrInt(void)
Enable UART1 Sync Error Interrupt.
Definition: uart.h:440
INLINE void UART0_clrEOFIntSts(void)
Clear the UART0 End of Sync Interrupt Status, UART0.ISC.EOFSYNCLR.
Definition: uart.h:539
INLINE uint8 UART0_getEOFIntSts(void)
Get the UART0 End of Sync Interrupt Status, UART0.IS.EOFSYN.
Definition: uart.h:511
INLINE uint8 UART0_getRXIntSts(void)
Get the UART0 Empty Receive Buffer Interrupt Status, UART0.IS.RI.
Definition: uart.h:493
INLINE void UART1_disRXErrInt(void)
Disable UART1 Receive Interrupt.
Definition: uart.h:461
void UART1_setTXIntSts(void) __attribute__((deprecated("Do not change this at runtime
Set UART1 TX Interrupt Node Pointer.
INLINE void UART1_disTXInt(void)
Disable UART1 Transmit Interrupt.
Definition: uart.h:454
sint8 UART0_init(void)
Initialize UART0.
Definition: uart.c:78
INLINE void UART1_startTX(void)
Start the transmission, UART1.TSTART.TXSTART.
Definition: uart.h:363
INLINE void UART0_enSyncErrInt(void)
Enable UART0 Sync Error Interrupt.
Definition: uart.h:384
INLINE void UART1_clrRXIntSts(void)
Clear the UART1 Empty Receive Buffer Interrupt Status, UART1.ISC.RICLR.
Definition: uart.h:589
sint8 UART1_init(void)
Initialize UART1.
Definition: uart.c:100
INLINE uint16 UART1_getRXbuffer(void)
Get the UART1 RX buffer value.
Definition: uart.h:242
INLINE void UART0_disBaudrateGen(void)
Disable the baudrate generator, UART0.BCON.BR_R.
Definition: uart.h:335
INLINE void UART0_disSyncErrInt(void)
Disable UART0 Sync Error Interrupt.
Definition: uart.h:412
INLINE void UART0_disRXErrInt(void)
Disable UART0 Receive Interrupt.
Definition: uart.h:405
__attribute__((noreturn))
Definition: startup_tle989x.c:193
Device specific memory layout defines and features.
General type declarations.
#define INLINE
Definition: types.h:151
uint8_t uint8
8 bit unsigned value
Definition: types.h:204
int8_t sint8
8 bit signed value
Definition: types.h:209
int32_t sint32
32 bit signed value
Definition: types.h:211
uint16_t uint16
16 bit unsigned value
Definition: types.h:205
uint32_t uint32
32 bit unsigned value
Definition: types.h:206