Infineon MOTIX™ MCU TLE988x/9x Device Family SDK
sdadc.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 *******************************************************************************/
52 
53 /*******************************************************************************
54 ** Revision Control History **
55 ********************************************************************************
56 ** V0.1.0: 2019-10-28, DM: Initial version **
57 ** V0.2.0: 2020-04-28, BG: Updated revision history format **
58 ** V0.3.0: 2020-08-24, BG: Added first functions **
59 ** V0.3.1: 2020-09-16, BG: Added interrupt enable/disable functions **
60 ** V0.3.2: 2020-10-01, BG: Corrected output type for timestamp functions **
61 ** (uint8 -> uint16) **
62 ** V0.3.3: 2020-10-21, BG: EP-539: Considered the enable checkbox in CW in **
63 ** the initialization function **
64 ** V0.3.4: 2020-11-12, JO: EP-590: Removed \param none and \return none to **
65 ** avoid doxygen warning **
66 ** Added end of group for doxygen **
67 ** V0.3.5: 2020-11-20, BG: EP-610: Corrected MISRA 2012 errors **
68 ** The following rules are globally deactivated: **
69 ** - Info 774: Boolean within 'if' always evaluates **
70 ** to False/True **
71 ** V0.3.6: 2020-12-18, BG: EP-652: Corrected name of error code variable **
72 ** V0.3.7: 2021-04-06, BG: EP-760: Replaced if instructions to check if the **
73 ** module is enabled with preprocessor directives to**
74 ** avoid compiler warnings **
75 ** V0.3.8: 2021-06-11, JO: EP-838: Corrected Interrupt En/Dis functions **
76 ** and SDADC_disSuspendMode **
77 ** V0.3.9: 2021-11-12, JO: EP-937: Updated copyright and branding **
78 ** V0.4.0: 2022-04-19, JO: EP-999: Changed return value of functions **
79 ** SDADC_getCh0Result/SDADC_getCh1Result to sint16 **
80 *******************************************************************************/
81 
82 #ifndef _SDADC_H
83 #define _SDADC_H
84 
85 /*******************************************************************************
86 ** Includes **
87 *******************************************************************************/
88 
89 #include "types.h"
90 #include "tle989x.h"
91 #include "tle_variants.h"
92 #include "sdadc_defines.h"
93 
94 /*******************************************************************************
95 ** Global Constant Declarations **
96 *******************************************************************************/
97 
98 /*******************************************************************************
99 ** Global Type Declarations **
100 *******************************************************************************/
101 
102 /*******************************************************************************
103 ** Global Function Declarations **
104 *******************************************************************************/
105 
106 sint8 SDADC_init(void);
107 INLINE void SDADC_enCh0ResInt(void);
108 INLINE void SDADC_disCh0ResInt(void);
109 INLINE void SDADC_enCh0CmpUpInt(void);
110 INLINE void SDADC_disCh0CmpUpInt(void);
111 INLINE void SDADC_enCh0CmpLoInt(void);
112 INLINE void SDADC_disCh0CmpLoInt(void);
113 INLINE void SDADC_enCh1ResInt(void);
114 INLINE void SDADC_disCh1ResInt(void);
115 INLINE void SDADC_enCh1CmpUpInt(void);
116 INLINE void SDADC_disCh1CmpUpInt(void);
117 INLINE void SDADC_enCh1CmpLoInt(void);
118 INLINE void SDADC_disCh1CmpLoInt(void);
125 INLINE void SDADC_clrCh0ResIntSts(void);
128 INLINE void SDADC_clrCh1ResIntSts(void);
131 INLINE void SDADC_enSuspendMode(void);
132 INLINE void SDADC_disSuspendMode(void);
150 INLINE void SDADC_clrCh0CmpUpSts(void);
151 INLINE void SDADC_clrCh0CmpLoSts(void);
152 INLINE void SDADC_clrCh0WFRSts(void);
153 INLINE void SDADC_clrCh1CmpUpSts(void);
154 INLINE void SDADC_clrCh1CmpLoSts(void);
155 INLINE void SDADC_clrCh1WFRSts(void);
156 
157 /*******************************************************************************
158 ** Deprecated Function Declarations **
159 *******************************************************************************/
163 void SDADC_setCh0ResIntNodePtr(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
164 
168 void SDADC_setCh0CmpUpIntNodePtr(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
169 
173 void SDADC_setCh0CmpLoIntNodePtr(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
174 
178 void SDADC_setCh1ResIntNodePtr(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
179 
183 void SDADC_setCh1CmpUpIntNodePtr(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
184 
188 void SDADC_setCh1CmpLoIntNodePtr(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
189 
190 
191 /*******************************************************************************
192 ** Global Inline Function Definitions **
193 *******************************************************************************/
197 {
198  SDADC->IEN.bit.RES0_EN = 1u;
199 }
200 
204 {
205  SDADC->IEN.bit.RES0_EN = 0u;
206 }
207 
211 {
212  SDADC->IEN.bit.CMP0_UP_EN = 1u;
213 }
214 
218 {
219  SDADC->IEN.bit.CMP0_UP_EN = 0u;
220 }
221 
225 {
226  SDADC->IEN.bit.CMP0_LO_EN = 1u;
227 }
228 
232 {
233  SDADC->IEN.bit.CMP0_LO_EN = 0u;
234 }
235 
239 {
240  SDADC->IEN.bit.RES1_EN = 1u;
241 }
242 
246 {
247  SDADC->IEN.bit.RES1_EN = 0u;
248 }
249 
253 {
254  SDADC->IEN.bit.CMP1_UP_EN = 1u;
255 }
256 
260 {
261  SDADC->IEN.bit.CMP1_UP_EN = 0u;
262 }
263 
267 {
268  SDADC->IEN.bit.CMP1_LO_EN = 1u;
269 }
270 
274 {
275  SDADC->IEN.bit.CMP1_LO_EN = 0u;
276 }
277 
283 {
284  return (uint8)SDADC->IS.bit.RES0_IS;
285 }
286 
292 {
293  return (uint8)SDADC->IS.bit.CMP0_UP_IS;
294 }
295 
301 {
302  return (uint8)SDADC->IS.bit.CMP0_LO_IS;
303 }
304 
310 {
311  return (uint8)SDADC->IS.bit.RES1_IS;
312 }
313 
319 {
320  return (uint8)SDADC->IS.bit.CMP1_UP_IS;
321 }
322 
328 {
329  return (uint8)SDADC->IS.bit.CMP1_LO_IS;
330 }
331 
335 {
336  SDADC->ISR.bit.RES0_ISC = 1u;
337 }
338 
342 {
343  SDADC->ISR.bit.CMP0_UP_ISC = 1u;
344 }
345 
349 {
350  SDADC->ISR.bit.CMP0_LO_ISC = 1u;
351 }
352 
356 {
357  SDADC->ISR.bit.RES1_ISC = 1u;
358 }
359 
363 {
364  SDADC->ISR.bit.CMP1_UP_ISC = 1u;
365 }
366 
370 {
371  SDADC->ISR.bit.CMP1_LO_ISC = 1u;
372 }
373 
377 {
378  SDADC->SUSCTR.bit.EN = 1u;
379 }
380 
384 {
385  SDADC->SUSCTR.bit.EN = 0u;
386 }
387 
393 {
394  return (uint8)SDADC->SUSSTAT.bit.STAT;
395 }
396 
402 {
403  return (sint16)SDADC->RES0.bit.RESULT;
404 }
405 
411 {
412  return (uint16)SDADC->RES0.bit.TIMVAL;
413 }
414 
420 {
421  return (uint16)SDADC->CTIM0.bit.TIMVAL;
422 }
423 
429 {
430  return (uint8)SDADC->RES0.bit.VALCNT;
431 }
432 
438 {
439  return (uint8)SDADC->RES0.bit.RESVALID;
440 }
441 
447 {
448  return (sint16)SDADC->RES1.bit.RESULT;
449 }
450 
456 {
457  return (uint16)SDADC->RES1.bit.TIMVAL;
458 }
459 
465 {
466  return (uint16)SDADC->CTIM1.bit.TIMVAL;
467 }
468 
474 {
475  return (uint8)SDADC->RES1.bit.VALCNT;
476 }
477 
483 {
484  return (uint8)SDADC->RES1.bit.RESVALID;
485 }
486 
492 {
493  return (uint8)SDADC->STS.bit.CMP0_UP_STS;
494 }
495 
501 {
502  return (uint8)SDADC->STS.bit.CMP0_LO_STS;
503 }
504 
510 {
511  return (uint8)SDADC->STS.bit.WFR0_STS;
512 }
513 
519 {
520  return (uint8)SDADC->STS.bit.CMP1_UP_STS;
521 }
522 
528 {
529  return (uint8)SDADC->STS.bit.CMP1_LO_STS;
530 }
531 
537 {
538  return (uint8)SDADC->STS.bit.WFR1_STS;
539 }
540 
544 {
545  SDADC->STSR.bit.CMP0_UP_SC = 1u;
546 }
547 
551 {
552  SDADC->STSR.bit.CMP0_LO_SC = 1u;
553 }
554 
558 {
559  SDADC->STSR.bit.WFR0_SC = 1u;
560 }
561 
565 {
566  SDADC->STSR.bit.CMP1_UP_SC = 1u;
567 }
568 
572 {
573  SDADC->STSR.bit.CMP1_LO_SC = 1u;
574 }
575 
579 {
580  SDADC->STSR.bit.WFR1_SC = 1u;
581 }
582 
585 #endif /* _SDADC_H */
#define SDADC
Definition: internal/tle989x.h:25614
INLINE void SDADC_enCh1CmpLoInt(void)
Enable Channel 1 Lower Compare Level Interrupt.
Definition: sdadc.h:266
void SDADC_setCh0CmpLoIntNodePtr(void) __attribute__((deprecated("Do not change this at runtime
Set Channel 0 Lower Compare Level Interrupt Node Pointer.
INLINE uint16 SDADC_getCh0CaptTimestamp(void)
Get Channel 0 Captured Timestamp SDADC.CTIM0.TIMVAL.
Definition: sdadc.h:419
void SDADC_setCh1CmpLoIntNodePtr(void) __attribute__((deprecated("Do not change this at runtime
Set Channel 1 Lower Compare Level Interrupt Node Pointer.
INLINE uint8 SDADC_getCh0CmpUpIntSts(void)
Get Channel 0 Upper Compare Level Interrupt Status SDADC.IS.CMP0_UP_IS.
Definition: sdadc.h:291
INLINE uint8 SDADC_getCh1CmpLoSts(void)
Get Channel 1 Lower Compare Level Status SDADC.STS.CMP1_LO_STS.
Definition: sdadc.h:527
INLINE uint8 SDADC_getSuspendModeSts(void)
Get Suspend Mode Status SDADC.SUSSTAT.STAT.
Definition: sdadc.h:392
INLINE sint16 SDADC_getCh1Result(void)
Get Channel 1 Result SDADC.RES1.RESULT.
Definition: sdadc.h:446
INLINE uint8 SDADC_getCh0WFRSts(void)
Get Channel 0 Wait For Read Status SDADC.STS.WFR0_STS.
Definition: sdadc.h:509
void SDADC_setCh1ResIntNodePtr(void) __attribute__((deprecated("Do not change this at runtime
Set Channel 1 Result Interrupt Node Pointer.
INLINE void SDADC_clrCh1CmpUpIntSts(void)
Clear Channel 1 Upper Compare Level Interrupt Status SDADC.ISR.CMP1_UP_ISC.
Definition: sdadc.h:362
void SDADC_setCh0CmpUpIntNodePtr(void) __attribute__((deprecated("Do not change this at runtime
Set Channel 0 Upper Compare Level Interrupt Node Pointer.
INLINE void SDADC_disCh1ResInt(void)
Disable Channel 1 Result Interrupt.
Definition: sdadc.h:245
INLINE void SDADC_clrCh1CmpLoSts(void)
Clear Channel 1 Lower Compare Level Status SDADC.STSR.CMP1_LO_SC.
Definition: sdadc.h:571
INLINE uint16 SDADC_getCh1Timestamp(void)
Get Channel 1 Timestamp SDADC.RES1.TIMVAL.
Definition: sdadc.h:455
INLINE uint8 SDADC_getCh0CmpLoIntSts(void)
Get Channel 0 Lower Compare Level Interrupt Status SDADC.IS.CMP0_LO_IS.
Definition: sdadc.h:300
INLINE void SDADC_clrCh1ResIntSts(void)
Clear Channel 1 Result Interrupt Status SDADC.ISR.RES1_ISC.
Definition: sdadc.h:355
INLINE uint8 SDADC_getCh1CmpLoIntSts(void)
Get Channel 1 Lower Compare Level Interrupt Status SDADC.IS.CMP1_LO_IS.
Definition: sdadc.h:327
INLINE uint8 SDADC_getCh0CmpLoSts(void)
Get Channel 0 Lower Compare Level Status SDADC.STS.CMP0_LO_STS.
Definition: sdadc.h:500
INLINE uint8 SDADC_getCh0ValidResSts(void)
Get Channel 0 Valid Result Status SDADC.RES0.RESVALID.
Definition: sdadc.h:437
void SDADC_setCh0ResIntNodePtr(void) __attribute__((deprecated("Do not change this at runtime
Set Channel 0 Result Interrupt Node Pointer.
INLINE void SDADC_disCh0CmpLoInt(void)
Disable Channel 0 Lower Compare Level Interrupt.
Definition: sdadc.h:231
INLINE uint8 SDADC_getCh1ResIntSts(void)
Get Channel 1 Result Interrupt Status SDADC.IS.RES1_IS.
Definition: sdadc.h:309
INLINE uint8 SDADC_getCh1ValidResSts(void)
Get Channel 1 Valid Result Status SDADC.RES1.RESVALID.
Definition: sdadc.h:482
INLINE uint8 SDADC_getCh1ResValidCnt(void)
Get Channel 1 Result Valid Counter SDADC.RES1.VALCNT.
Definition: sdadc.h:473
INLINE uint8 SDADC_getCh0ResIntSts(void)
Get Channel 0 Result Interrupt Status SDADC.IS.RES0_IS.
Definition: sdadc.h:282
INLINE uint8 SDADC_getCh0ResValidCnt(void)
Get Channel 0 Result Valid Counter SDADC.RES0.VALCNT.
Definition: sdadc.h:428
INLINE void SDADC_clrCh0ResIntSts(void)
Clear Channel 0 Result Interrupt Status SDADC.ISR.RES0_ISC.
Definition: sdadc.h:334
INLINE void SDADC_clrCh0WFRSts(void)
Clear Channel 0 Wait For Read Status SDADC.STSR.WFR0_SC.
Definition: sdadc.h:557
INLINE void SDADC_enCh1ResInt(void)
Enable Channel 1 Result Interrupt.
Definition: sdadc.h:238
INLINE uint16 SDADC_getCh0Timestamp(void)
Get Channel 0 Timestamp SDADC.RES0.TIMVAL.
Definition: sdadc.h:410
INLINE void SDADC_clrCh0CmpUpIntSts(void)
Clear Channel 0 Upper Compare Level Interrupt Status SDADC.ISR.CMP0_UP_ISC.
Definition: sdadc.h:341
INLINE void SDADC_enCh0CmpLoInt(void)
Enable Channel 0 Lower Compare Level Interrupt.
Definition: sdadc.h:224
INLINE uint16 SDADC_getCh1CaptTimestamp(void)
Get Channel 1 Captured Timestamp SDADC.CTIM1.TIMVAL.
Definition: sdadc.h:464
INLINE uint8 SDADC_getCh1CmpUpIntSts(void)
Get Channel 1 Upper Compare Level Interrupt Status SDADC.IS.CMP1_UP_IS.
Definition: sdadc.h:318
INLINE uint8 SDADC_getCh1CmpUpSts(void)
Get Channel 1 Upper Compare Level Status SDADC.STS.CMP1_UP_STS.
Definition: sdadc.h:518
INLINE void SDADC_disCh1CmpLoInt(void)
Disable Channel 1 Lower Compare Level Interrupt.
Definition: sdadc.h:273
INLINE sint16 SDADC_getCh0Result(void)
Get Channel 0 Result SDADC.RES0.RESULT.
Definition: sdadc.h:401
sint8 SDADC_init(void)
Initialize all CW registers of the SDADC module.
Definition: sdadc.c:59
INLINE void SDADC_clrCh1WFRSts(void)
Clear Channel 1 Wait For Read Status SDADC.STSR.WFR1_SC.
Definition: sdadc.h:578
INLINE void SDADC_clrCh1CmpUpSts(void)
Clear Channel 1 Upper Compare Level Status SDADC.STSR.CMP1_UP_SC.
Definition: sdadc.h:564
INLINE void SDADC_disSuspendMode(void)
Disable Suspend Mode SDADC.SUSCTR.EN.
Definition: sdadc.h:383
INLINE void SDADC_clrCh1CmpLoIntSts(void)
Clear Channel 1 Lower Compare Level Interrupt Status SDADC.ISR.CMP1_LO_ISC.
Definition: sdadc.h:369
INLINE void SDADC_clrCh0CmpUpSts(void)
Clear Channel 0 Upper Compare Level Status SDADC.STSR.CMP0_UP_SC.
Definition: sdadc.h:543
INLINE void SDADC_enCh0ResInt(void)
Enable Channel 0 Result Interrupt.
Definition: sdadc.h:196
INLINE void SDADC_disCh0CmpUpInt(void)
Disable Channel 0 Upper Compare Level Interrupt.
Definition: sdadc.h:217
void SDADC_setCh1CmpUpIntNodePtr(void) __attribute__((deprecated("Do not change this at runtime
Set Channel 1 Upper Compare Level Interrupt Node Pointer.
INLINE void SDADC_enCh0CmpUpInt(void)
Enable Channel 0 Upper Compare Level Interrupt.
Definition: sdadc.h:210
INLINE void SDADC_enSuspendMode(void)
Enable Suspend Mode SDADC.SUSCTR.EN.
Definition: sdadc.h:376
INLINE void SDADC_clrCh0CmpLoIntSts(void)
Clear Channel 0 Lower Compare Level Interrupt Status SDADC.ISR.CMP0_LO_ISC.
Definition: sdadc.h:348
INLINE void SDADC_clrCh0CmpLoSts(void)
Clear Channel 0 Lower Compare Level Status SDADC.STSR.CMP0_LO_SC.
Definition: sdadc.h:550
INLINE void SDADC_disCh0ResInt(void)
Disable Channel 0 Result Interrupt.
Definition: sdadc.h:203
INLINE void SDADC_disCh1CmpUpInt(void)
Disable Channel 1 Upper Compare Level Interrupt.
Definition: sdadc.h:259
INLINE void SDADC_enCh1CmpUpInt(void)
Enable Channel 1 Upper Compare Level Interrupt.
Definition: sdadc.h:252
INLINE uint8 SDADC_getCh1WFRSts(void)
Get Channel 1 Wait For Read Status SDADC.STS.WFR1_STS.
Definition: sdadc.h:536
INLINE uint8 SDADC_getCh0CmpUpSts(void)
Get Channel 0 Upper Compare Level Status SDADC.STS.CMP0_UP_STS.
Definition: sdadc.h:491
__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
int16_t sint16
16 bit signed value
Definition: types.h:226
uint16_t uint16
16 bit unsigned value
Definition: types.h:221