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  * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the
8  * following conditions are met:
9  *
10  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following
11  * disclaimer.
12  *
13  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
14  * following disclaimer in the documentation and/or other materials provided with the distribution.
15  *
16  * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote
17  * products derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  **********************************************************************************************************************/
43 /*******************************************************************************
44 ** Author(s) Identity **
45 ********************************************************************************
46 ** Initials Name **
47 ** ---------------------------------------------------------------------------**
48 ** DM Daniel Mysliwitz **
49 ** BG Blandine Guillot **
50 ** JO Julia Ott **
51 ** PS Patrik Schwarz **
52 *******************************************************************************/
53 
54 /*******************************************************************************
55 ** Revision Control History **
56 ********************************************************************************
57 ** V0.1.0: 2019-10-28, DM: Initial version **
58 ** V0.2.0: 2020-04-28, BG: Updated revision history format **
59 ** V0.3.0: 2020-05-22, BG: Added first functions **
60 ** V0.4.0: 2020-07-10, BG: Added inline functions list **
61 ** V0.4.1: 2020-09-16, BG: Added interrupt enable/disable functions **
62 ** V0.4.2: 2020-10-06, BG: EP-492: Removed MISRA 2012 errors **
63 ** V0.4.3: 2020-10-16, JO: EP-523: Updated parameter names **
64 ** V0.4.4: 2020-10-21, BG: EP-539: Considered the enable checkbox in CW in **
65 ** the initialization function **
66 ** V0.4.5: 2020-11-12, JO: EP-590: Removed \param none and \return none to **
67 ** avoid doxygen warning **
68 ** Added end of group for doxygen **
69 ** V0.4.6: 2020-11-20, BG: EP-610: Corrected MISRA 2012 errors **
70 ** The following rules are globally deactivated: **
71 ** - Info 774: Boolean within 'if' always evaluates **
72 ** to False/True **
73 ** V0.4.7: 2020-12-10, BG: EP-622: Updated setTXBuffer functions **
74 ** V0.4.8: 2020-12-18, BG: EP-652: Corrected name of error code variable **
75 ** V0.4.9: 2021-01-19, BG: EP-660: Corrected UARTx_setTXBuffer **
76 ** Added functions to enable/disable baudrate **
77 ** generator **
78 ** Corrected initialization to set the bit BR_R **
79 ** separately **
80 ** V0.5.0: 2021-04-06, BG: EP-760: Replaced if instructions to check if the **
81 ** module is enabled with preprocessor directives to**
82 ** avoid compiler warnings **
83 ** V0.5.1: 2021-04-23, EE: EP-676: Added stdout_putchar function to put **
84 ** a character to stdout **
85 ** V0.5.2: 2021-06-02, BG: EP-833: Added if conditions for the functions **
86 ** related to STDIN/STDOUT **
87 ** V0.5.3: 2021-06-16, BG: EP-839: Added stdin_getchar() **
88 ** V0.5.4: 2021-07-21, BG: EP-872: Corrected functions to set a user-defined**
89 ** baudrate: UART{0/1}_setBaudrate(u32_baudrate) **
90 ** V0.5.5: 2021-07-30, BG: EP-877: Corrected MISRA 2012 errors **
91 ** V0.5.6: 2021-10-19, JO: EP-810: Updated init functions for unit testing **
92 ** V0.5.7: 2021-10-20, JO: EP-966: Corrected functions UARTx_getBaudrate **
93 ** V0.5.8: 2021-11-12, JO: EP-937: Updated copyright and branding **
94 ** V0.5.9: 2022-06-23, JO: EP-1150: Removed ARMCC V6.18 warnings **
95 ** V0.6.0: 2023-04-04, PS: EP-1141: Corrected MISRA warnings **
96 ** V0.6.1: 2023-11-29, JO: EP-1448: Added initialization of UARTx->LINCON **
97 *******************************************************************************/
98 
99 #ifndef _UART_H
100 #define _UART_H
101 
102 /*******************************************************************************
103 ** Includes **
104 *******************************************************************************/
105 
106 #include "types.h"
107 #include "tle989x.h"
108 #include "tle_variants.h"
109 #include "uart_defines.h"
110 #include "scu_defines.h"
111 #include "isr_defines.h"
112 
113 /*******************************************************************************
114 ** Global Constant Declarations **
115 *******************************************************************************/
116 
117 /*******************************************************************************
118 ** Global Type Declarations **
119 *******************************************************************************/
120 
121 /*******************************************************************************
122 ** Global Macro Declarations **
123 *******************************************************************************/
124 
125 /*******************************************************************************
126 ** Global Function Declarations **
127 *******************************************************************************/
128 
129 sint8 UART0_init(void);
130 sint8 UART1_init(void);
133 sint8 UART0_setBaudrate(uint32 u32_baudrate);
134 sint8 UART1_setBaudrate(uint32 u32_baudrate);
135 #if ((UART0_STD_EN == 1) || (UART1_STD_EN == 1))
136  sint32 stdout_putchar(sint32 character);
137  sint32 stdin_getchar(void);
138 #endif
140 INLINE void UART0_setTXbuffer(uint16 u16_value);
142 INLINE void UART1_setTXbuffer(uint16 u16_value);
143 INLINE bool UART0_isByteReceived(void);
145 INLINE bool UART1_isByteReceived(void);
147 INLINE void UART0_enBaudrateGen(void);
148 INLINE void UART0_disBaudrateGen(void);
149 INLINE void UART1_enBaudrateGen(void);
150 INLINE void UART1_disBaudrateGen(void);
151 INLINE void UART0_startTX(void);
152 INLINE void UART1_startTX(void);
153 INLINE void UART0_enTXInt(void);
154 INLINE void UART0_enRXErrInt(void);
155 INLINE void UART0_enSyncErrInt(void);
156 INLINE void UART0_enEOSInt(void);
157 INLINE void UART0_disTXInt(void);
158 INLINE void UART0_disRXErrInt(void);
159 INLINE void UART0_disSyncErrInt(void);
160 INLINE void UART0_disEOSInt(void);
161 INLINE void UART1_enTXInt(void);
162 INLINE void UART1_enRXErrInt(void);
163 INLINE void UART1_enSyncErrInt(void);
164 INLINE void UART1_enEOSInt(void);
165 INLINE void UART1_disTXInt(void);
166 INLINE void UART1_disRXErrInt(void);
167 INLINE void UART1_disSyncErrInt(void);
168 INLINE void UART1_disEOSInt(void);
173 INLINE void UART0_clrTXIntSts(void);
174 INLINE void UART0_clrRXIntSts(void);
175 INLINE void UART0_clrSyncErrIntSts(void);
176 INLINE void UART0_clrEOFIntSts(void);
181 INLINE void UART1_clrTXIntSts(void);
182 INLINE void UART1_clrRXIntSts(void);
183 INLINE void UART1_clrSyncErrIntSts(void);
184 INLINE void UART1_clrEOFIntSts(void);
185 
186 /*******************************************************************************
187 ** Deprecated Function Declarations **
188 *******************************************************************************/
189 
193 void UART0_setTXIntSts(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
194 
198 void UART0_setRXIntSts(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
199 
203 void UART0_setSyncErrIntSts(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
204 
208 void UART0_setEOFIntSts(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
209 
213 void UART1_setTXIntSts(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
214 
218 void UART1_setRXIntSts(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
219 
223 void UART1_setSyncErrIntSts(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
224 
228 void UART1_setEOFIntSts(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
229 
230 /*******************************************************************************
231 ** Global Inline Function Definitions **
232 *******************************************************************************/
233 
239 {
241  return (uint16)(UART0->RXBUF.reg);
242 }
243 
249 {
251  UART0->TXBUF.reg = u16_value;
252 }
253 
259 {
261  return (uint16)(UART1->RXBUF.reg);
262 }
263 
269 {
271  UART1->TXBUF.reg = u16_value;
272 }
273 
279 {
280  //lint --e{9034}
281  bool result = false;
282 
283  if (UART0_getRXIntSts() == 1u)
284  {
285  result = true;
286  }
287 
288  return result;
289 }
290 
296 {
297  //lint --e{9034}
298  bool result = false;
299 
300  if (UART0_getTXIntSts() == 1u)
301  {
302  result = true;
303  }
304 
305  return result;
306 }
307 
313 {
314  //lint --e{9034}
315  bool result = false;
316 
317  if (UART1_getRXIntSts() == 1u)
318  {
319  result = true;
320  }
321 
322  return result;
323 }
324 
330 {
331  //lint --e{9034}
332  bool result = false;
333 
334  if (UART1_getTXIntSts() == 1u)
335  {
336  result = true;
337  }
338 
339  return result;
340 }
341 
345 {
346  UART0->BCON.bit.BR_R = 1u;
347 }
348 
352 {
353  UART0->BCON.bit.BR_R = 0u;
354 }
355 
359 {
360  UART1->BCON.bit.BR_R = 1u;
361 }
362 
366 {
367  UART1->BCON.bit.BR_R = 0u;
368 }
369 
373 {
374  UART0->TSTART.bit.TXSTART = 1u;
375 }
376 
380 {
381  UART1->TSTART.bit.TXSTART = 1u;
382 }
383 
387 {
388  UART0->IEN.bit.TIEN = 1u;
389 }
390 
394 {
395  UART0->IEN.bit.RIEN = 1u;
396 }
397 
401 {
402  UART0->IEN.bit.ERRSYNEN = 1u;
403 }
404 
408 {
409  UART0->IEN.bit.EOFSYNEN = 1u;
410 }
411 
415 {
416  UART0->IEN.bit.TIEN = 0u;
417 }
418 
422 {
423  UART0->IEN.bit.RIEN = 0u;
424 }
425 
429 {
430  UART0->IEN.bit.ERRSYNEN = 0u;
431 }
432 
436 {
437  UART0->IEN.bit.EOFSYNEN = 0u;
438 }
439 
443 {
444  UART1->IEN.bit.TIEN = 1u;
445 }
446 
450 {
451  UART1->IEN.bit.RIEN = 1u;
452 }
453 
457 {
458  UART1->IEN.bit.ERRSYNEN = 1u;
459 }
460 
464 {
465  UART1->IEN.bit.EOFSYNEN = 1u;
466 }
467 
471 {
472  UART1->IEN.bit.TIEN = 0u;
473 }
474 
478 {
479  UART1->IEN.bit.RIEN = 0u;
480 }
481 
485 {
486  UART1->IEN.bit.ERRSYNEN = 0u;
487 }
488 
492 {
493  UART1->IEN.bit.EOFSYNEN = 0u;
494 }
495 
501 {
502  return (uint8)UART0->IS.bit.TI;
503 }
504 
510 {
511  return (uint8)UART0->IS.bit.RI;
512 }
513 
519 {
520  return (uint8)UART0->IS.bit.ERRSYN;
521 }
522 
528 {
529  return (uint8)UART0->IS.bit.EOFSYN;
530 }
531 
535 {
536  UART0->ISC.bit.TICLR = 1u;
537 }
538 
542 {
543  UART0->ISC.bit.RICLR = 1u;
544 }
545 
549 {
550  UART0->ISC.bit.ERRSYNCLR = 1u;
551 }
552 
556 {
557  UART0->ISC.bit.EOFSYNCLR = 1u;
558 }
559 
565 {
566  return (uint8)UART1->IS.bit.TI;
567 }
568 
574 {
575  return (uint8)UART1->IS.bit.RI;
576 }
577 
583 {
584  return (uint8)UART1->IS.bit.ERRSYN;
585 }
586 
592 {
593  return (uint8)UART1->IS.bit.EOFSYN;
594 }
595 
599 {
600  UART1->ISC.bit.TICLR = 1u;
601 }
602 
606 {
607  UART1->ISC.bit.RICLR = 1u;
608 }
609 
613 {
614  UART1->ISC.bit.ERRSYNCLR = 1u;
615 }
616 
620 {
621  UART1->ISC.bit.EOFSYNCLR = 1u;
622 }
623 
626 #endif /* _UART_H */
#define UART0
Definition: internal/tle989x.h:25619
#define UART1
Definition: internal/tle989x.h:25620
sint8 UART1_setBaudrate(uint32 u32_baudrate)
Set the baudrate for UART1.
Definition: uart.c:310
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:612
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:564
uint32 UART1_getBaudrate(void)
Get the baudrate for UART1 Transform equation (SCU_fUART_MHz * 1000000 / (16 * (1U << (uint8)UART1->B...
Definition: uart.c:156
INLINE void UART0_setTXbuffer(uint16 u16_value)
Set the UART0 TX buffer value.
Definition: uart.h:248
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:548
INLINE void UART1_setTXbuffer(uint16 u16_value)
Set the UART1 TX buffer value.
Definition: uart.h:268
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:329
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:491
INLINE void UART0_enRXErrInt(void)
Enable UART0 Receive Interrupt.
Definition: uart.h:393
INLINE void UART1_clrTXIntSts(void)
Clear the UART1 Empty Transmit Buffer Interrupt Status, UART1.ISC.TICLR.
Definition: uart.h:598
sint8 UART0_setBaudrate(uint32 u32_baudrate)
Set the baudrate for UART0.
Definition: uart.c:293
INLINE bool UART0_isByteTransmitted(void)
Check if UART0 has transmitted a byte.
Definition: uart.h:295
INLINE bool UART1_isByteReceived(void)
Check if UART1 has received a byte.
Definition: uart.h:312
INLINE void UART1_disSyncErrInt(void)
Disable UART1 Sync Error Interrupt.
Definition: uart.h:484
INLINE uint8 UART1_getSyncErrIntSts(void)
Get the UART1 Sync Error Interrupt Status, UART1.IS.ERRSYN.
Definition: uart.h:582
INLINE void UART0_disEOSInt(void)
Disable UART0 End of Sync Interrupt.
Definition: uart.h:435
INLINE void UART1_clrEOFIntSts(void)
Clear the UART1 End of Sync Interrupt Status, UART1.ISC.EOFSYNCLR.
Definition: uart.h:619
INLINE bool UART0_isByteReceived(void)
Check if UART0 has received a byte.
Definition: uart.h:278
INLINE void UART0_clrRXIntSts(void)
Clear the UART0 Empty Receive Buffer Interrupt Status, UART0.ISC.RICLR.
Definition: uart.h:541
INLINE void UART1_enRXErrInt(void)
Enable UART1 Receive Interrupt.
Definition: uart.h:449
INLINE void UART0_clrTXIntSts(void)
Clear the UART0 Empty Transmit Buffer Interrupt Status, UART0.ISC.TICLR.
Definition: uart.h:534
INLINE void UART0_enBaudrateGen(void)
Enable the baudrate generator, UART0.BCON.BR_R.
Definition: uart.h:344
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:365
INLINE uint8 UART0_getSyncErrIntSts(void)
Get the UART0 Sync Error Interrupt Status, UART0.IS.ERRSYN.
Definition: uart.h:518
INLINE void UART0_disTXInt(void)
Disable UART0 Transmit Interrupt.
Definition: uart.h:414
INLINE uint8 UART1_getRXIntSts(void)
Get the UART1 Empty Receive Buffer Interrupt Status, UART1.IS.RI.
Definition: uart.h:573
INLINE void UART1_enBaudrateGen(void)
Enable the baudrate generator, UART1.BCON.BR_R.
Definition: uart.h:358
INLINE void UART1_enEOSInt(void)
Enable UART1 End of Sync Interrupt.
Definition: uart.h:463
INLINE uint8 UART1_getEOFIntSts(void)
Get the UART1 End of Sync Interrupt Status, UART1.IS.EOFSYN.
Definition: uart.h:591
INLINE uint16 UART0_getRXbuffer(void)
Get the UART0 RX buffer value.
Definition: uart.h:238
uint32 UART0_getBaudrate(void)
Get the baudrate for UART0 Transform equation (SCU_fUART_MHz * 1000000 / (16 * (1U << (uint8)UART0->B...
Definition: uart.c:142
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:372
INLINE void UART0_enTXInt(void)
Enable UART0 Transmit Interrupt.
Definition: uart.h:386
INLINE uint8 UART0_getTXIntSts(void)
Get the UART0 Empty Transmit Buffer Interrupt Status, UART0.IS.TI.
Definition: uart.h:500
INLINE void UART0_enEOSInt(void)
Enable UART0 End of Sync Interrupt.
Definition: uart.h:407
INLINE void UART1_enTXInt(void)
Enable UART1 Transmit Interrupt.
Definition: uart.h:442
INLINE void UART1_enSyncErrInt(void)
Enable UART1 Sync Error Interrupt.
Definition: uart.h:456
INLINE void UART0_clrEOFIntSts(void)
Clear the UART0 End of Sync Interrupt Status, UART0.ISC.EOFSYNCLR.
Definition: uart.h:555
INLINE uint8 UART0_getEOFIntSts(void)
Get the UART0 End of Sync Interrupt Status, UART0.IS.EOFSYN.
Definition: uart.h:527
INLINE uint8 UART0_getRXIntSts(void)
Get the UART0 Empty Receive Buffer Interrupt Status, UART0.IS.RI.
Definition: uart.h:509
INLINE void UART1_disRXErrInt(void)
Disable UART1 Receive Interrupt.
Definition: uart.h:477
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:470
sint8 UART0_init(void)
Initialize UART0.
Definition: uart.c:95
INLINE void UART1_startTX(void)
Start the transmission, UART1.TSTART.TXSTART.
Definition: uart.h:379
INLINE void UART0_enSyncErrInt(void)
Enable UART0 Sync Error Interrupt.
Definition: uart.h:400
INLINE void UART1_clrRXIntSts(void)
Clear the UART1 Empty Receive Buffer Interrupt Status, UART1.ISC.RICLR.
Definition: uart.h:605
sint8 UART1_init(void)
Initialize UART1.
Definition: uart.c:117
INLINE uint16 UART1_getRXbuffer(void)
Get the UART1 RX buffer value.
Definition: uart.h:258
INLINE void UART0_disBaudrateGen(void)
Disable the baudrate generator, UART0.BCON.BR_R.
Definition: uart.h:351
INLINE void UART0_disSyncErrInt(void)
Disable UART0 Sync Error Interrupt.
Definition: uart.h:428
INLINE void UART0_disRXErrInt(void)
Disable UART0 Receive Interrupt.
Definition: uart.h:421
__attribute__((noreturn))
Definition: startup_tle989x.c:221
Device specific memory layout defines and features.
General type declarations.
#define INLINE
Definition: types.h:167
uint8_t uint8
8 bit unsigned value
Definition: types.h:220
int8_t sint8
8 bit signed value
Definition: types.h:225
int32_t sint32
32 bit signed value
Definition: types.h:227
uint16_t uint16
16 bit unsigned value
Definition: types.h:221
uint32_t uint32
32 bit unsigned value
Definition: types.h:222