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  * 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 /* Generated by generate_functions_02_xlsx2func.py, version 0.9.0 on 16. Oct 2020
44  * from File 'csacsc.xlsx', version 0.1.0
45  */
46 
47 /*******************************************************************************
48 ** Author(s) Identity **
49 ********************************************************************************
50 ** Initials Name **
51 ** ---------------------------------------------------------------------------**
52 ** JO Julia Ott **
53 ** BG Blandine Guillot **
54 ** DM Daniel Mysliwitz **
55 *******************************************************************************/
56 
57 /*******************************************************************************
58 ** Revision Control History **
59 ********************************************************************************
60 ** V0.1.0: 2020-05-27, DM: Initial version **
61 ** V0.1.1: 2020-10-06, BG: EP-492: Removed MISRA 2012 errors **
62 ** V0.1.2: 2020-10-16, JO: EP-523: Updated parameter names **
63 ** V0.1.3: 2020-10-21, BG: EP-539: Considered the enable checkbox in CW in **
64 ** the initialization function **
65 ** V0.1.4: 2020-11-12, JO: EP-590: Removed \param none and \return none to **
66 ** avoid doxygen warning **
67 ** Added end of group for doxygen **
68 ** V0.1.5: 2020-11-20, BG: EP-610: Corrected MISRA 2012 errors **
69 ** The following rules are globally deactivated: **
70 ** - Info 774: Boolean within 'if' always evaluates **
71 ** to False/True **
72 ** V0.1.6: 2020-12-18, DM: EP-642: Added shadow transfer to function **
73 ** CSACSC_startCalibration(), **
74 ** separate shadow transfer enable added before **
75 ** actual seq. shadow transfer **
76 ** Replaced the __NOP loop in CSACSC_init() by **
77 ** SCU_delay_us() function to give BIST 50us time **
78 ** to finish **
79 ** V0.1.7: 2020-12-18, BG: EP-652: Corrected name of error code variable **
80 ** V0.1.8: 2021-03-24, BG: EP-749: Added enumerations for gain and offset **
81 ** V0.1.9: 2021-04-06, BG: EP-760: Replaced if instructions to check if the **
82 ** module is enabled with preprocessor directives to**
83 ** avoid compiler warnings **
84 ** V0.2.0: 2021-05-07, BG: EP-796: Cleared fail-safe related registers due **
85 ** to overcurrent flag after BIST test, to make the **
86 ** BDRV initialization working **
87 ** V0.2.1: 2021-06-02, BG: EP-813: Removed the interrupt status clear and **
88 ** interrupt enable initialization since it is done **
89 ** in the INT_init function (see int.c) **
90 ** V0.2.2: 2021-07-27, BG: EP-814: Corrected the value to clear registers **
91 ** FS_STS_CLR and FS_SSD_CLR **
92 ** V0.2.3: 2021-07-30, BG: EP-877: Corrected MISRA 2012 errors **
93 ** V0.2.4: 2021-08-11, BG: EP-902: Removed waiting delay and added better **
94 ** handling of return code in CSACSC_init() **
95 ** V0.2.5: 2021-11-12, JO: EP-937: Updated copyright and branding **
96 ** V0.2.6: 2022-06-23, JO: EP-1150: Removed ARMCC V6.18 warnings **
97 ** V0.2.7: 2022-07-05, JO: EP-1188: Disabled lint rules 9030 & 9034 locally **
98 ** V0.2.8: 2022-11-17, JO: EP-1342: Updated enum documentation to remove **
99 ** doxygen warning **
100 *******************************************************************************/
101 
102 #ifndef _CSACSC_H
103 #define _CSACSC_H
104 
105 /*******************************************************************************
106 ** Includes **
107 *******************************************************************************/
108 
109 #include "types.h"
110 #include "tle989x.h"
111 #include "tle_variants.h"
112 #include "adc1.h"
113 #include "csacsc_defines.h"
114 #include "isr_defines.h"
115 
116 /*******************************************************************************
117 ** Global Macro Declarations **
118 *******************************************************************************/
119 
120 /*******************************************************************************
121 ** Global Type Declarations **
122 *******************************************************************************/
123 
128 typedef enum CSA_gain
129 {
133  CSA_gain_60 = 3
135 
140 typedef enum CSA_offset
141 {
145  CSA_offset_60 = 3
147 
148 /*******************************************************************************
149 ** Global Function Declarations **
150 *******************************************************************************/
151 
152 sint8 CSACSC_init(void);
153 sint8 CSACSC_startCalibration(uint16 *pu16_Val_mV);
154 INLINE void CSACSC_enPower(void);
155 INLINE void CSACSC_disPower(void);
156 INLINE void CSACSC_setMinGain(tCSA_gain e_gain);
158 INLINE void CSACSC_setMinOffset(tCSA_offset e_offset);
160 INLINE void CSACSC_setMaxThreshold(uint16 u16_value);
162 INLINE void CSACSC_setAddInputOffset(uint8 u8_value);
164 INLINE void CSACSC_setGain(tCSA_gain e_gain);
166 INLINE void CSACSC_setOffset(tCSA_offset e_offset);
168 INLINE void CSACSC_setVout(uint8 u8_value);
170 INLINE void CSACSC_setThreshold(uint8 u8_value);
172 INLINE void CSACSC_setFilterTime(uint8 u8_value);
176 INLINE void CSACSC_clrOverCurrSts(void);
177 INLINE void CSACSC_enOverCurrInt(void);
178 INLINE void CSACSC_disOverCurrInt(void);
179 INLINE void CSACSC_enParamErrorInt(void);
186 
187 /*******************************************************************************
188 ** Deprecated Function Declarations **
189 *******************************************************************************/
190 
194 void CSACSC_setOverCurrIntNodePtr(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
195 
199 void CSACSC_setParamErrorIntNodePtr(void) __attribute__((deprecated("Do not change this at runtime, use the ConfigWizard to configure this feature!")));
200 
201 /*******************************************************************************
202 ** Global Inline Function Definitions **
203 *******************************************************************************/
207 {
208  CSACSC->CTRL1.bit.CSAC_EN = 1u;
209 }
210 
214 {
215  CSACSC->CTRL1.bit.CSAC_EN = 0u;
216 }
217 
218 /* The following warning is disabled for ARMCC v6 Compiler */
219 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6000000)
220  #pragma clang diagnostic push
221  #pragma clang diagnostic ignored "-Wcovered-switch-default"
222 #endif
228 {
229  switch (e_gain)
230  {
231  case CSA_gain_10:
232  {
233  CSACSC->CTRL1.bit.GAIN_MIN = 0u;
234  break;
235  }
236 
237  case CSA_gain_20:
238  {
239  CSACSC->CTRL1.bit.GAIN_MIN = 3u;
240  break;
241  }
242 
243  case CSA_gain_40:
244  {
245  CSACSC->CTRL1.bit.GAIN_MIN = 12u;
246  break;
247  }
248 
249  case CSA_gain_60:
250  {
251  CSACSC->CTRL1.bit.GAIN_MIN = 15u;
252  break;
253  }
254 
255  default:
256  {
257  break;
258  }
259  }
260 }
261 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6000000)
262  #pragma clang diagnostic pop
263 #endif
264 
270 {
271  tCSA_gain e_gain;
272  uint8 u8_minGain;
273  u8_minGain = CSACSC->CTRL1.bit.GAIN_MIN;
274 
275  if (u8_minGain == 0u)
276  {
277  e_gain = CSA_gain_10;
278  }
279  else if (u8_minGain == 3u)
280  {
281  e_gain = CSA_gain_20;
282  }
283  else if (u8_minGain == 12u)
284  {
285  e_gain = CSA_gain_40;
286  }
287  else
288  {
289  e_gain = CSA_gain_60;
290  }
291 
292  return e_gain;
293 }
294 
295 /* The following warning is disabled for ARMCC v6 Compiler */
296 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6000000)
297  #pragma clang diagnostic push
298  #pragma clang diagnostic ignored "-Wcovered-switch-default"
299 #endif
305 {
306  switch (e_offset)
307  {
308  case CSA_offset_10:
309  {
310  CSACSC->CTRL1.bit.OFFS_MIN = 0u;
311  break;
312  }
313 
314  case CSA_offset_20:
315  {
316  CSACSC->CTRL1.bit.OFFS_MIN = 3u;
317  break;
318  }
319 
320  case CSA_offset_40:
321  {
322  CSACSC->CTRL1.bit.OFFS_MIN = 12u;
323  break;
324  }
325 
326  case CSA_offset_60:
327  {
328  CSACSC->CTRL1.bit.OFFS_MIN = 15u;
329  break;
330  }
331 
332  default:
333  {
334  break;
335  }
336  }
337 }
338 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6000000)
339  #pragma clang diagnostic pop
340 #endif
341 
347 {
348  tCSA_offset e_offset;
349  uint8 u8_minOffset;
350  u8_minOffset = CSACSC->CTRL1.bit.OFFS_MIN;
351 
352  if (u8_minOffset == 0u)
353  {
354  e_offset = CSA_offset_10;
355  }
356  else if (u8_minOffset == 3u)
357  {
358  e_offset = CSA_offset_20;
359  }
360  else if (u8_minOffset == 12u)
361  {
362  e_offset = CSA_offset_40;
363  }
364  else
365  {
366  e_offset = CSA_offset_60;
367  }
368 
369  return e_offset;
370 }
371 
377 {
378  CSACSC->CTRL1.bit.THR_MAX = u16_value;
379 }
380 
386 {
387  return (uint16)CSACSC->CTRL1.bit.THR_MAX;
388 }
389 
395 {
396  CSACSC->CTRL2.bit.ADD_INP_OFFS = u8_value;
397 }
398 
404 {
405  return (uint8)CSACSC->CTRL2.bit.ADD_INP_OFFS;
406 }
407 
413 {
414  CSACSC->CTRL2.bit.GAIN_SEL = (uint8)e_gain;
415 }
416 
422 {
423  /* Disable lint rules 9030 and 9034 locally, note about cast from uint to enum */
424  //lint -e9030
425  //lint -e9034
426  return (tCSA_gain)CSACSC->CTRL2.bit.GAIN_SEL;
427  //lint +e9030
428  //lint +e9034
429 }
430 
436 {
437  CSACSC->CTRL2.bit.OFFS_SEL = (uint8)e_offset;
438 }
439 
445 {
446  /* Disable lint rules 9030 and 9034 locally, note about cast from uint to enum */
447  //lint -e9030
448  //lint -e9034
449  return (tCSA_offset)CSACSC->CTRL2.bit.OFFS_SEL;
450  //lint +e9030
451  //lint +e9034
452 }
453 
459 {
460  CSACSC->CTRL2.bit.VOUT_SEL = u8_value;
461 }
462 
468 {
469  return (uint8)CSACSC->CTRL2.bit.VOUT_SEL;
470 }
471 
477 {
478  CSACSC->CTRL2.bit.THR_SEL = u8_value;
479 }
480 
486 {
487  return (uint8)CSACSC->CTRL2.bit.THR_SEL;
488 }
489 
495 {
496  CSACSC->CTRL2.bit.TFILT_SEL = u8_value;
497 }
498 
504 {
505  return (uint8)CSACSC->CTRL2.bit.TFILT_SEL;
506 }
507 
511 {
512  CSACSC->IRQCLR.bit.CSC_OC_ISC = 1u;
513 }
514 
518 {
519  CSACSC->IRQCLR.bit.SEL_ERR_ISC = 1u;
520 }
521 
525 {
526  CSACSC->IRQCLR.bit.CSC_OC_SC = 1u;
527 }
528 
532 {
533  CSACSC->IRQEN.bit.CSC_OC_IEN = 1u;
534 }
535 
539 {
540  CSACSC->IRQEN.bit.CSC_OC_IEN = 0u;
541 }
542 
546 {
547  CSACSC->IRQEN.bit.SEL_ERR_IEN = 1u;
548 }
549 
553 {
554  CSACSC->IRQEN.bit.SEL_ERR_IEN = 0u;
555 }
556 
562 {
563  return (uint8)CSACSC->IRQS.bit.CSC_OC_IS;
564 }
565 
571 {
572  return (uint8)CSACSC->IRQS.bit.SEL_ERR_IS;
573 }
574 
580 {
581  return (uint8)CSACSC->IRQS.bit.CSC_OC_STS;
582 }
583 
589 {
590  return (uint8)CSACSC->IRQS.bit.CSC_OC_OUT;
591 }
592 
598 {
599  return (uint8)CSACSC->IRQS.bit.CSC_BIST_STS;
600 }
601 
604 #endif /* _CSACSC_H */
ADC1 low level access library.
sint8 CSACSC_startCalibration(uint16 *pu16_Val_mV)
Perform the calibration of the CSA.
Definition: csacsc.c:108
INLINE uint16 CSACSC_getMaxThreshold(void)
Get Current sense comparator maximum threshold setting.
Definition: csacsc.h:385
INLINE uint8 CSACSC_getFilterTime(void)
Get Filter time for current sense comparator.
Definition: csacsc.h:503
INLINE void CSACSC_enOverCurrInt(void)
Enable Overcurrent event interrupt enable.
Definition: csacsc.h:531
enum CSA_gain tCSA_gain
INLINE void CSACSC_disPower(void)
Disable Current sense amplifier and comparator enable.
Definition: csacsc.h:213
INLINE void CSACSC_setOffset(tCSA_offset e_offset)
Set Current sense amplifier output offset setting.
Definition: csacsc.h:435
INLINE void CSACSC_setGain(tCSA_gain e_gain)
Set Current sense amplifier gain setting.
Definition: csacsc.h:412
INLINE uint8 CSACSC_getAddInputOffset(void)
Get Additional input offset setting.
Definition: csacsc.h:403
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:206
INLINE void CSACSC_setFilterTime(uint8 u8_value)
Set Filter time for current sense comparator.
Definition: csacsc.h:494
INLINE uint8 CSACSC_getParamErrorIntSts(void)
Get CSA minimum gain or offset selection error interrupt status.
Definition: csacsc.h:570
INLINE uint8 CSACSC_getThreshold(void)
Get Current sense comparator threshold setting.
Definition: csacsc.h:485
INLINE tCSA_gain CSACSC_getMinGain(void)
Get Current sense amplifier minimum gain setting.
Definition: csacsc.h:269
INLINE void CSACSC_enParamErrorInt(void)
Enable CSA minimum gain or offset selection error interrupt enable.
Definition: csacsc.h:545
INLINE void CSACSC_setMinOffset(tCSA_offset e_offset)
Set Current sense amplifier minimum output offset setting.
Definition: csacsc.h:304
INLINE uint8 CSACSC_getVout(void)
Get Current sense output selection.
Definition: csacsc.h:467
INLINE void CSACSC_setThreshold(uint8 u8_value)
Set Current sense comparator threshold setting.
Definition: csacsc.h:476
INLINE void CSACSC_clrOverCurrSts(void)
Clear Overcurrent event status clear.
Definition: csacsc.h:524
CSA_offset
This enum lists the CSA offset settings.
Definition: csacsc.h:141
CSA_gain
This enum lists the CSA gain settings.
Definition: csacsc.h:129
INLINE uint8 CSACSC_getOverCurrSts(void)
Get Overcurrent event status.
Definition: csacsc.h:579
enum CSA_offset tCSA_offset
INLINE void CSACSC_setMaxThreshold(uint16 u16_value)
Set Current sense comparator maximum threshold setting.
Definition: csacsc.h:376
INLINE void CSACSC_clrParamErrorIntSts(void)
Clear CSA minimum gain or offset selection error interrupt status clear.
Definition: csacsc.h:517
INLINE void CSACSC_disOverCurrInt(void)
Disable Overcurrent event interrupt enable.
Definition: csacsc.h:538
INLINE void CSACSC_setAddInputOffset(uint8 u8_value)
Set Additional input offset setting.
Definition: csacsc.h:394
INLINE tCSA_offset CSACSC_getMinOffset(void)
Get Current sense amplifier minimum output offset setting.
Definition: csacsc.h:346
INLINE void CSACSC_setVout(uint8 u8_value)
Set Current sense output selection.
Definition: csacsc.h:458
INLINE void CSACSC_setMinGain(tCSA_gain e_gain)
Set Current sense amplifier minimum gain setting.
Definition: csacsc.h:227
INLINE tCSA_gain CSACSC_getGain(void)
Get Current sense amplifier gain setting.
Definition: csacsc.h:421
INLINE uint8 CSACSC_getOverCurrIntSts(void)
Get Overcurrent event interrupt status.
Definition: csacsc.h:561
INLINE void CSACSC_disParamErrorInt(void)
Disable CSA minimum gain or offset selection error interrupt enable.
Definition: csacsc.h:552
INLINE tCSA_offset CSACSC_getOffset(void)
Get Current sense amplifier output offset setting.
Definition: csacsc.h:444
INLINE uint8 CSACSC_getOverCurrCmpOut(void)
Get Overcurrent comparator output.
Definition: csacsc.h:588
INLINE uint8 CSACSC_getBistSts(void)
Get CSC built-in self test status.
Definition: csacsc.h:597
INLINE void CSACSC_clrOverCurrIntSts(void)
Clear Overcurrent event interrupt status clear.
Definition: csacsc.h:510
sint8 CSACSC_init(void)
Initialize all CW registers of the CSA/CSC module.
Definition: csacsc.c:65
@ CSA_offset_60
Definition: csacsc.h:145
@ CSA_offset_10
Definition: csacsc.h:142
@ CSA_offset_40
Definition: csacsc.h:144
@ CSA_offset_20
Definition: csacsc.h:143
@ CSA_gain_60
Definition: csacsc.h:133
@ CSA_gain_40
Definition: csacsc.h:132
@ CSA_gain_10
Definition: csacsc.h:130
@ CSA_gain_20
Definition: csacsc.h:131
#define CSACSC
Definition: tle989x.h:24068
__attribute__((noreturn))
Definition: startup_tle989x.c:208
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
uint16_t uint16
16 bit unsigned value
Definition: types.h:221