Infineon MOTIX™ MCU TLE988x/9x Device Family SDK
csacsc.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 /* Generated by generate_functions_02_xlsx2func.py, version 0.9.0 on 16. Oct 2020
27  * from File 'csacsc.xlsx', version 0.1.0
28  */
29 
30 /*******************************************************************************
31 ** Author(s) Identity **
32 ********************************************************************************
33 ** Initials Name **
34 ** ---------------------------------------------------------------------------**
35 ** JO Julia Ott **
36 ** BG Blandine Guillot **
37 ** DM Daniel Mysliwitz **
38 *******************************************************************************/
39 
40 /*******************************************************************************
41 ** Revision Control History **
42 ********************************************************************************
43 ** V0.1.0: 2020-05-27, DM: Initial version **
44 ** V0.1.1: 2020-10-06, BG: EP-492: Removed MISRA 2012 errors **
45 ** V0.1.2: 2020-10-16, JO: EP-523: Updated parameter names **
46 ** V0.1.3: 2020-10-21, BG: EP-539: Considered the enable checkbox in CW in **
47 ** the initialization function **
48 ** V0.1.4: 2020-11-12, JO: EP-590: Removed \param none and \return none to **
49 ** avoid doxygen warning **
50 ** Added end of group for doxygen **
51 ** V0.1.5: 2020-11-20, BG: EP-610: Corrected MISRA 2012 errors **
52 ** The following rules are globally deactivated: **
53 ** - Info 774: Boolean within 'if' always evaluates **
54 ** to False/True **
55 ** V0.1.6: 2020-12-18, DM: EP-642: Added shadow transfer to function **
56 ** CSACSC_startCalibration(), **
57 ** separate shadow transfer enable added before **
58 ** actual seq. shadow transfer **
59 ** Replaced the __NOP loop in CSACSC_init() by **
60 ** SCU_delay_us() function to give BIST 50us time **
61 ** to finish **
62 ** V0.1.7: 2020-12-18, BG: EP-652: Corrected name of error code variable **
63 ** V0.1.8: 2021-03-24, BG: EP-749: Added enumerations for gain and offset **
64 ** V0.1.9: 2021-04-06, BG: EP-760: Replaced if instructions to check if the **
65 ** module is enabled with preprocessor directives to**
66 ** avoid compiler warnings **
67 ** V0.2.0: 2021-05-07, BG: EP-796: Cleared fail-safe related registers due **
68 ** to overcurrent flag after BIST test, to make the **
69 ** BDRV initialization working **
70 ** V0.2.1: 2021-06-02, BG: EP-813: Removed the interrupt status clear and **
71 ** interrupt enable initialization since it is done **
72 ** in the INT_init function (see int.c) **
73 ** V0.2.2: 2021-07-27, BG: EP-814: Corrected the value to clear registers **
74 ** FS_STS_CLR and FS_SSD_CLR **
75 ** V0.2.3: 2021-07-30, BG: EP-877: Corrected MISRA 2012 errors **
76 ** V0.2.4: 2021-08-11, BG: EP-902: Removed waiting delay and added better **
77 ** handling of return code in CSACSC_init() **
78 ** V0.2.5: 2021-11-12, JO: EP-937: Updated copyright and branding **
79 ** V0.2.6: 2022-06-23, JO: EP-1150: Removed ARMCC V6.18 warnings **
80 ** V0.2.7: 2022-07-05, JO: EP-1188: Disabled lint rules 9030 & 9034 locally **
81 ** V0.2.8: 2022-11-17, JO: EP-1342: Updated enum documentation to remove **
82 ** doxygen warning **
83 ** V0.2.9: 2024-11-05, JO: EP-1494: Updated license **
84 *******************************************************************************/
85 
86 #ifndef _CSACSC_H
87 #define _CSACSC_H
88 
89 /*******************************************************************************
90 ** Includes **
91 *******************************************************************************/
92 
93 #include "types.h"
94 #include "tle989x.h"
95 #include "tle_variants.h"
96 #include "adc1.h"
97 #include "csacsc_defines.h"
98 #include "isr_defines.h"
99 
100 /*******************************************************************************
101 ** Global Macro Declarations **
102 *******************************************************************************/
103 
104 /*******************************************************************************
105 ** Global Type Declarations **
106 *******************************************************************************/
107 
112 typedef enum CSA_gain
113 {
117  CSA_gain_60 = 3
119 
124 typedef enum CSA_offset
125 {
129  CSA_offset_60 = 3
131 
132 /*******************************************************************************
133 ** Global Function Declarations **
134 *******************************************************************************/
135 
136 sint8 CSACSC_init(void);
137 sint8 CSACSC_startCalibration(uint16 *pu16_Val_mV);
138 INLINE void CSACSC_enPower(void);
139 INLINE void CSACSC_disPower(void);
140 INLINE void CSACSC_setMinGain(tCSA_gain e_gain);
142 INLINE void CSACSC_setMinOffset(tCSA_offset e_offset);
144 INLINE void CSACSC_setMaxThreshold(uint16 u16_value);
146 INLINE void CSACSC_setAddInputOffset(uint8 u8_value);
148 INLINE void CSACSC_setGain(tCSA_gain e_gain);
150 INLINE void CSACSC_setOffset(tCSA_offset e_offset);
152 INLINE void CSACSC_setVout(uint8 u8_value);
154 INLINE void CSACSC_setThreshold(uint8 u8_value);
156 INLINE void CSACSC_setFilterTime(uint8 u8_value);
160 INLINE void CSACSC_clrOverCurrSts(void);
161 INLINE void CSACSC_enOverCurrInt(void);
162 INLINE void CSACSC_disOverCurrInt(void);
163 INLINE void CSACSC_enParamErrorInt(void);
170 
171 /*******************************************************************************
172 ** Deprecated Function Declarations **
173 *******************************************************************************/
174 
178 void CSACSC_setOverCurrIntNodePtr(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
179 
183 void CSACSC_setParamErrorIntNodePtr(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
184 
185 /*******************************************************************************
186 ** Global Inline Function Definitions **
187 *******************************************************************************/
191 {
192  CSACSC->CTRL1.bit.CSAC_EN = 1u;
193 }
194 
198 {
199  CSACSC->CTRL1.bit.CSAC_EN = 0u;
200 }
201 
202 /* The following warning is disabled for ARMCC v6 Compiler */
203 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6000000)
204  #pragma clang diagnostic push
205  #pragma clang diagnostic ignored "-Wcovered-switch-default"
206 #endif
212 {
213  switch (e_gain)
214  {
215  case CSA_gain_10:
216  {
217  CSACSC->CTRL1.bit.GAIN_MIN = 0u;
218  break;
219  }
220 
221  case CSA_gain_20:
222  {
223  CSACSC->CTRL1.bit.GAIN_MIN = 3u;
224  break;
225  }
226 
227  case CSA_gain_40:
228  {
229  CSACSC->CTRL1.bit.GAIN_MIN = 12u;
230  break;
231  }
232 
233  case CSA_gain_60:
234  {
235  CSACSC->CTRL1.bit.GAIN_MIN = 15u;
236  break;
237  }
238 
239  default:
240  {
241  break;
242  }
243  }
244 }
245 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6000000)
246  #pragma clang diagnostic pop
247 #endif
248 
254 {
255  tCSA_gain e_gain;
256  uint8 u8_minGain;
257  u8_minGain = CSACSC->CTRL1.bit.GAIN_MIN;
258 
259  if (u8_minGain == 0u)
260  {
261  e_gain = CSA_gain_10;
262  }
263  else if (u8_minGain == 3u)
264  {
265  e_gain = CSA_gain_20;
266  }
267  else if (u8_minGain == 12u)
268  {
269  e_gain = CSA_gain_40;
270  }
271  else
272  {
273  e_gain = CSA_gain_60;
274  }
275 
276  return e_gain;
277 }
278 
279 /* The following warning is disabled for ARMCC v6 Compiler */
280 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6000000)
281  #pragma clang diagnostic push
282  #pragma clang diagnostic ignored "-Wcovered-switch-default"
283 #endif
289 {
290  switch (e_offset)
291  {
292  case CSA_offset_10:
293  {
294  CSACSC->CTRL1.bit.OFFS_MIN = 0u;
295  break;
296  }
297 
298  case CSA_offset_20:
299  {
300  CSACSC->CTRL1.bit.OFFS_MIN = 3u;
301  break;
302  }
303 
304  case CSA_offset_40:
305  {
306  CSACSC->CTRL1.bit.OFFS_MIN = 12u;
307  break;
308  }
309 
310  case CSA_offset_60:
311  {
312  CSACSC->CTRL1.bit.OFFS_MIN = 15u;
313  break;
314  }
315 
316  default:
317  {
318  break;
319  }
320  }
321 }
322 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6000000)
323  #pragma clang diagnostic pop
324 #endif
325 
331 {
332  tCSA_offset e_offset;
333  uint8 u8_minOffset;
334  u8_minOffset = CSACSC->CTRL1.bit.OFFS_MIN;
335 
336  if (u8_minOffset == 0u)
337  {
338  e_offset = CSA_offset_10;
339  }
340  else if (u8_minOffset == 3u)
341  {
342  e_offset = CSA_offset_20;
343  }
344  else if (u8_minOffset == 12u)
345  {
346  e_offset = CSA_offset_40;
347  }
348  else
349  {
350  e_offset = CSA_offset_60;
351  }
352 
353  return e_offset;
354 }
355 
361 {
362  CSACSC->CTRL1.bit.THR_MAX = u16_value;
363 }
364 
370 {
371  return (uint16)CSACSC->CTRL1.bit.THR_MAX;
372 }
373 
379 {
380  CSACSC->CTRL2.bit.ADD_INP_OFFS = u8_value;
381 }
382 
388 {
389  return (uint8)CSACSC->CTRL2.bit.ADD_INP_OFFS;
390 }
391 
397 {
398  CSACSC->CTRL2.bit.GAIN_SEL = (uint8)e_gain;
399 }
400 
406 {
407  /* Disable lint rules 9030 and 9034 locally, note about cast from uint to enum */
408  //lint -e9030
409  //lint -e9034
410  return (tCSA_gain)CSACSC->CTRL2.bit.GAIN_SEL;
411  //lint +e9030
412  //lint +e9034
413 }
414 
420 {
421  CSACSC->CTRL2.bit.OFFS_SEL = (uint8)e_offset;
422 }
423 
429 {
430  /* Disable lint rules 9030 and 9034 locally, note about cast from uint to enum */
431  //lint -e9030
432  //lint -e9034
433  return (tCSA_offset)CSACSC->CTRL2.bit.OFFS_SEL;
434  //lint +e9030
435  //lint +e9034
436 }
437 
443 {
444  CSACSC->CTRL2.bit.VOUT_SEL = u8_value;
445 }
446 
452 {
453  return (uint8)CSACSC->CTRL2.bit.VOUT_SEL;
454 }
455 
461 {
462  CSACSC->CTRL2.bit.THR_SEL = u8_value;
463 }
464 
470 {
471  return (uint8)CSACSC->CTRL2.bit.THR_SEL;
472 }
473 
479 {
480  CSACSC->CTRL2.bit.TFILT_SEL = u8_value;
481 }
482 
488 {
489  return (uint8)CSACSC->CTRL2.bit.TFILT_SEL;
490 }
491 
495 {
496  CSACSC->IRQCLR.bit.CSC_OC_ISC = 1u;
497 }
498 
502 {
503  CSACSC->IRQCLR.bit.SEL_ERR_ISC = 1u;
504 }
505 
509 {
510  CSACSC->IRQCLR.bit.CSC_OC_SC = 1u;
511 }
512 
516 {
517  CSACSC->IRQEN.bit.CSC_OC_IEN = 1u;
518 }
519 
523 {
524  CSACSC->IRQEN.bit.CSC_OC_IEN = 0u;
525 }
526 
530 {
531  CSACSC->IRQEN.bit.SEL_ERR_IEN = 1u;
532 }
533 
537 {
538  CSACSC->IRQEN.bit.SEL_ERR_IEN = 0u;
539 }
540 
546 {
547  return (uint8)CSACSC->IRQS.bit.CSC_OC_IS;
548 }
549 
555 {
556  return (uint8)CSACSC->IRQS.bit.SEL_ERR_IS;
557 }
558 
564 {
565  return (uint8)CSACSC->IRQS.bit.CSC_OC_STS;
566 }
567 
573 {
574  return (uint8)CSACSC->IRQS.bit.CSC_OC_OUT;
575 }
576 
582 {
583  return (uint8)CSACSC->IRQS.bit.CSC_BIST_STS;
584 }
585 
588 #endif /* _CSACSC_H */
ADC1 low level access library.
sint8 CSACSC_startCalibration(uint16 *pu16_Val_mV)
Perform the calibration of the CSA.
Definition: csacsc.c:91
INLINE uint16 CSACSC_getMaxThreshold(void)
Get Current sense comparator maximum threshold setting.
Definition: csacsc.h:369
INLINE uint8 CSACSC_getFilterTime(void)
Get Filter time for current sense comparator.
Definition: csacsc.h:487
INLINE void CSACSC_enOverCurrInt(void)
Enable Overcurrent event interrupt enable.
Definition: csacsc.h:515
enum CSA_gain tCSA_gain
INLINE void CSACSC_disPower(void)
Disable Current sense amplifier and comparator enable.
Definition: csacsc.h:197
INLINE void CSACSC_setOffset(tCSA_offset e_offset)
Set Current sense amplifier output offset setting.
Definition: csacsc.h:419
INLINE void CSACSC_setGain(tCSA_gain e_gain)
Set Current sense amplifier gain setting.
Definition: csacsc.h:396
INLINE uint8 CSACSC_getAddInputOffset(void)
Get Additional input offset setting.
Definition: csacsc.h:387
void CSACSC_setParamErrorIntNodePtr(void) __attribute__((deprecated("Do not change this at runtime
Set Parameter Error Interrupt Node Pointer.
void CSACSC_setOverCurrIntNodePtr(void) __attribute__((deprecated("Do not change this at runtime
Set Overcurrent Interrupt Node Pointer.
INLINE void CSACSC_enPower(void)
Enable Current sense amplifier and comparator enable.
Definition: csacsc.h:190
INLINE void CSACSC_setFilterTime(uint8 u8_value)
Set Filter time for current sense comparator.
Definition: csacsc.h:478
INLINE uint8 CSACSC_getParamErrorIntSts(void)
Get CSA minimum gain or offset selection error interrupt status.
Definition: csacsc.h:554
INLINE uint8 CSACSC_getThreshold(void)
Get Current sense comparator threshold setting.
Definition: csacsc.h:469
INLINE tCSA_gain CSACSC_getMinGain(void)
Get Current sense amplifier minimum gain setting.
Definition: csacsc.h:253
INLINE void CSACSC_enParamErrorInt(void)
Enable CSA minimum gain or offset selection error interrupt enable.
Definition: csacsc.h:529
INLINE void CSACSC_setMinOffset(tCSA_offset e_offset)
Set Current sense amplifier minimum output offset setting.
Definition: csacsc.h:288
INLINE uint8 CSACSC_getVout(void)
Get Current sense output selection.
Definition: csacsc.h:451
INLINE void CSACSC_setThreshold(uint8 u8_value)
Set Current sense comparator threshold setting.
Definition: csacsc.h:460
INLINE void CSACSC_clrOverCurrSts(void)
Clear Overcurrent event status clear.
Definition: csacsc.h:508
CSA_offset
This enum lists the CSA offset settings.
Definition: csacsc.h:125
CSA_gain
This enum lists the CSA gain settings.
Definition: csacsc.h:113
INLINE uint8 CSACSC_getOverCurrSts(void)
Get Overcurrent event status.
Definition: csacsc.h:563
enum CSA_offset tCSA_offset
INLINE void CSACSC_setMaxThreshold(uint16 u16_value)
Set Current sense comparator maximum threshold setting.
Definition: csacsc.h:360
INLINE void CSACSC_clrParamErrorIntSts(void)
Clear CSA minimum gain or offset selection error interrupt status clear.
Definition: csacsc.h:501
INLINE void CSACSC_disOverCurrInt(void)
Disable Overcurrent event interrupt enable.
Definition: csacsc.h:522
INLINE void CSACSC_setAddInputOffset(uint8 u8_value)
Set Additional input offset setting.
Definition: csacsc.h:378
INLINE tCSA_offset CSACSC_getMinOffset(void)
Get Current sense amplifier minimum output offset setting.
Definition: csacsc.h:330
INLINE void CSACSC_setVout(uint8 u8_value)
Set Current sense output selection.
Definition: csacsc.h:442
INLINE void CSACSC_setMinGain(tCSA_gain e_gain)
Set Current sense amplifier minimum gain setting.
Definition: csacsc.h:211
INLINE tCSA_gain CSACSC_getGain(void)
Get Current sense amplifier gain setting.
Definition: csacsc.h:405
INLINE uint8 CSACSC_getOverCurrIntSts(void)
Get Overcurrent event interrupt status.
Definition: csacsc.h:545
INLINE void CSACSC_disParamErrorInt(void)
Disable CSA minimum gain or offset selection error interrupt enable.
Definition: csacsc.h:536
INLINE tCSA_offset CSACSC_getOffset(void)
Get Current sense amplifier output offset setting.
Definition: csacsc.h:428
INLINE uint8 CSACSC_getOverCurrCmpOut(void)
Get Overcurrent comparator output.
Definition: csacsc.h:572
INLINE uint8 CSACSC_getBistSts(void)
Get CSC built-in self test status.
Definition: csacsc.h:581
INLINE void CSACSC_clrOverCurrIntSts(void)
Clear Overcurrent event interrupt status clear.
Definition: csacsc.h:494
sint8 CSACSC_init(void)
Initialize all CW registers of the CSA/CSC module.
Definition: csacsc.c:48
@ CSA_offset_60
Definition: csacsc.h:129
@ CSA_offset_10
Definition: csacsc.h:126
@ CSA_offset_40
Definition: csacsc.h:128
@ CSA_offset_20
Definition: csacsc.h:127
@ CSA_gain_60
Definition: csacsc.h:117
@ CSA_gain_40
Definition: csacsc.h:116
@ CSA_gain_10
Definition: csacsc.h:114
@ CSA_gain_20
Definition: csacsc.h:115
#define CSACSC
Definition: tle989x.h:24068
__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
uint16_t uint16
16 bit unsigned value
Definition: types.h:205