1 
2 /**
3  * @file xmc_hrpwm.h
4  * @date 2015-06-20
5  *
6  * @cond
7  **********************************************************************************
8  * XMClib v2.1.24 - XMC Peripheral Driver Library
9  *
10  * Copyright (c) 2015-2019, Infineon Technologies AG
11  * All rights reserved.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification,are permitted provided that the following conditions are met:
15  *
16  *   Redistributions of source code must retain the above copyright notice,
17  *   this list of conditions and the following disclaimer.
18  *
19  *   Redistributions in binary form must reproduce the above copyright notice,
20  *   this list of conditions and the following disclaimer in the documentation
21  *   and/or other materials provided with the distribution.
22  *
23  *   Neither the name of the copyright holders nor the names of its contributors
24  *   may be used to endorse or promote products derived from this software without
25  *   specific prior written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30  * ARE  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
31  * LIABLE  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33  * SUBSTITUTE GOODS OR  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35  * CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37  * POSSIBILITY OF SUCH DAMAGE.
38  *
39  * To improve the quality of the software, users are encouraged to share
40  * modifications, enhancements or bug fixes with Infineon Technologies AG
41  * dave@infineon.com).
42  **********************************************************************************
43  *
44  * Change History
45  * --------------
46  *
47  * 2015-02-18:
48  *     - Driver description updated<br>
49  *     - API's are renamed <br>
50  *       XMC_HRPWM_HRC_SetResolutionCR1() -> XMC_HRPWM_HRC_SetCompare1()<br>
51  *       XMC_HRPWM_HRC_SetResolutionCR2() -> XMC_HRPWM_HRC_SetCompare2()<br>
52  *       XMC_HRPWM_HRC_SetDeadTimeDCF()   -> XMC_HRPWM_HRC_SetDeadTimeFalling()<br>
53  *       XMC_HRPWM_HRC_SetDeadTimeDCR()   -> XMC_HRPWM_HRC_SetDeadTimeRising()<br>
54  *
55  * 2015-05-12:
56  *     - XMC_HRPWM_CSG_SelClampingInput() api is added to select the clamping input<br>
57  *     - Enum XMC_HRPWM_SHADOW_TX_t is renamed to XMC_HRPWM_SHADOW_TX_DAC_t to represent that shadow transfer is for DAC <br>
58  *
59  * 2015-06-20:
60  *     - Removed version macros and declaration of GetDriverVersion API <br>
61  *     - Updated copyright and change history section.
62  *
63  * @endcond
64  *
65  */
66 
67 #ifndef HRPWM_H
68 #define HRPWM_H
69 
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
73 
74 /***********************************************************************************************************************
75  * HEADER FILES
76  **********************************************************************************************************************/
77 #include <xmc_common.h>
78 
79 #if defined(HRPWM0)
80 #include <xmc_hrpwm_map.h>
81 
82 /**
83  * @addtogroup XMClib XMC Peripheral Library
84  * @{
85  */
86 
87 /**
88  * @addtogroup HRPWM
89  * @brief High Resolution PWM Unit (HRPWM) driver for the XMC microcontroller family.<br>
90  *
91  * The HRPWM extends the capabilities of the associated Capture/Compare Unit(CCU8), that simplifies the design various of SMPS.
92  * It allows easy and fast implementation of control loop, reduced total number of external components, avoid susceptibility
93  * to environmental and process variations there by reducing the size of the power supply.<br>
94  *
95  *<b>Comparator Slope Generator(CSG)</b><br>
96  * HRPWM module consists 3 Comparator Slope Generator(CSG) units. Each CSG unit comprised of one High Speed Comparator,
97  * a dedicated 10 bit 30 MS/s DAC and one hardware controlled Slope Compensation module.<br>
98  *
99  * <b>CSG features include:</b><br>
100  * <OL>
101  * <LI>3 High Speed Comparators, that can be use to compare an external signal against the DAC value<br>
102  * <LI>3 (30MS/s) 10 bit DAC<br>
103  * <LI>3 Slope generation blocks, that are used to generate the DAC input value<br>
104  * <LI>different slope generations schemes, for a flexible and automated DAC voltage generation<br>
105  * <LI>2 DAC reference values, to allow flexible hysteretic mode control<br>
106  * <LI>Input multiplexer for the inverting comparator input, allowing several analog inputs to be connected to each comparator and also dynamic input switching.<br>
107  * <LI>blanking compare mode, to avoid premature switch OFF due to noise<br>
108  * <LI>a dedicated output per Comparator<br>
109  * <LI>programmable clock prescaler<br>
110  * <LI>programmable clock pulse swallower for slope linearization with uneven clock scale<br>
111  * <LI>different slope generation schemes:<br>
112  *     – incrementing mode<br>
113  *     – decrementing mode<br>
114  *     – triangular mode<br>
115  * <LI>shadow transfer for one DAC reference value<br>
116  * <LI>external trigger for the DAC<br>
117  * <LI>external control for the DAC reference values<br>
118  * <LI>four dedicated service request lines<br>
119  *</OL>
120  *
121  *<b>High Resolution Channel unit(HRC)</b><br>
122  * It also has 4 High Resolution Channel unit(HRC) that upgrades 4 compare channels of a Capture/Compare unit (CCU8), enabling
123  * generation of PWM with 150ps resolution. ie; the rise time and/or fall time of PWM can be changed in steps of 150ps.<br>
124  *
125  * <b>HRC features include:</b><br>
126  * <OL>
127  * <LI>Upgrade up to 4 PWM signals of CCU8 outputs for high resolution positioning.<br>
128  * <LI>Independent control of PWM set and reset.<br>
129  * <LI>Delay the PWM rise time in steps of 150ps. This does not insert dead time.<br>
130  * <LI>Extent the fall time of PWM in steps of 150ps. This does not insert dead time.<br>
131  * <LI>Dead time insertion on complementary signals<br>
132  * <LI>Passive level selection on outputs.<br>
133  *</OL>
134  * @{
135  */
136 /***********************************************************************************************************************
137  * MACROS
138  ********************************************************************************************************************/
139 #define XMC_HRPWM_CSG0_MEMORY_ADDRESS 0x40020A40 /* CSG0 memory location */
140 #define XMC_HRPWM_CSG1_MEMORY_ADDRESS 0x40020B40 /* CSG1 memory location */
141 #define XMC_HRPWM_CSG2_MEMORY_ADDRESS 0x40020C40 /* CSG2 memory location */
142 
143 #define XMC_HRPWM_COMPARATOR_STATUS (HRPWM0_CSGTRSG_D0STE_Msk + HRPWM0_CSGTRSG_D1STE_Msk + HRPWM0_CSGTRSG_D2STE_Msk)
144 
145 #define XMC_HRPWM_CHECK_MODULE_PTR(PTR)  ((PTR)== HRPWM0)
146 #define XMC_HRPWM_CHECK_HRC_PTR(PTR)     ( ((PTR)== HRPWM0_HRC0) || ((PTR)== HRPWM0_HRC1) || ((PTR)== HRPWM0_HRC2) || ((PTR)== HRPWM0_HRC3) )
147 #define XMC_HRPWM_CHECK_CSG_PTR(PTR)     ( ((PTR)== HRPWM0_CSG0) || ((PTR)== HRPWM0_CSG1) || ((PTR)== HRPWM0_CSG2) )
148 
149 /***********************************************************************************************************************
150  * ENUMS - General
151  **********************************************************************************************************************/
152 /**
153  * Return HRPWM driver status
154  */
155 typedef enum XMC_HRPWM_STATUS
156 {
157   XMC_HRPWM_STATUS_OK = 0U,              /**< Driver successfully completed the request */
158   XMC_HRPWM_STATUS_BUSY,                 /**< Driver busy, cannot handle request */
159   XMC_HRPWM_STATUS_ERROR                 /**< Driver cannot fulfill request, error occurred */
160 } XMC_HRPWM_STATUS_t;
161 
162 /***********************************************************************************************************************
163  * ENUMS - HRPWM
164  **********************************************************************************************************************/
165 /**
166  * HRPWM module clock frequency
167  */
168 typedef enum XMC_HRPWM_CLK_FREQ
169 {
170   XMC_HRPWM_CLK_FREQ_NONE   = 0U,         /**< No clock frequency is selected */
171   XMC_HRPWM_CLK_FREQ_180MHZ,              /**< Module clock frequency is 180MHz */
172   XMC_HRPWM_CLK_FREQ_120MHZ,              /**< Module clock frequency is 120MHz */
173   XMC_HRPWM_CLK_FREQ_80MHZ                /**< Module clock frequency is 80MHz */
174 } XMC_HRPWM_CLK_FREQ_t;
175 
176 /***********************************************************************************************************************
177  * ENUMS - HRPWM HRC
178  **********************************************************************************************************************/
179 /**
180  * HRPWM HRC High Resolution mode configuration
181  */
182 typedef enum XMC_HRPWM_HRC_HR_EDGE
183 {
184   XMC_HRPWM_HRC_HR_EDGE_SEL_RISING = 0U,  /**< Rising edge high resolution signal positioning enabled */
185   XMC_HRPWM_HRC_HR_EDGE_SEL_FALLING,      /**< Falling edge high resolution signal positioning enabled */
186   XMC_HRPWM_HRC_HR_EDGE_SEL_BOTH,         /**< Both edges high resolution signal positioning enabled */
187   XMC_HRPWM_HRC_HR_EDGE_SEL_NONE          /**< No high resolution signal positioning */
188 } XMC_HRPWM_HRC_HR_EDGE_t;
189 
190 /**
191  * HRPWM HRC source selector input
192  */
193 typedef enum XMC_HRPWM_HRC_SRC_INPUT
194 {
195   XMC_HRPWM_HRC_SRC_INPUT_CCU = 0U,       /**< Source selector is controlled via CCU timer signal */
196   XMC_HRPWM_HRC_SRC_INPUT_CSG             /**< Source selector is controlled via CSG output signal */
197 } XMC_HRPWM_HRC_SRC_INPUT_t;
198 
199 /**
200  * HRPWM HRC source selector - connection of source selector to which CSG unit
201  */
202 typedef enum XMC_HRPWM_HRC_CMP_SEL
203 {
204   XMC_HRPWM_HRC_CMP_SEL_CSG0 = 0U,       /**< Comparator output of CSG0 selected */
205   XMC_HRPWM_HRC_CMP_SEL_CSG1,            /**< Comparator output of CSG1 selected */
206   XMC_HRPWM_HRC_CMP_SEL_CSG2             /**< Comparator output of CSG2 selected */
207 } XMC_HRPWM_HRC_CMP_SEL_t;
208 
209 /**
210  * HRPWM HRC source selector - connection of source selector to which CCU timer
211  */
212 typedef enum XMC_HRPWM_HRC_TIMER_SEL
213 {
214   XMC_HRPWM_HRC_TIMER_SEL_CCU_CC0 = 0U,  /**< CCU timer 0 selected */
215   XMC_HRPWM_HRC_TIMER_SEL_CCU_CC1,       /**< CCU timer 1 selected */
216   XMC_HRPWM_HRC_TIMER_SEL_CCU_CC2,       /**< CCU timer 2 selected */
217   XMC_HRPWM_HRC_TIMER_SEL_CCU_CC3        /**< CCU timer 3 selected */
218 } XMC_HRPWM_HRC_TIMER_SEL_t;
219 
220 /**
221  * HR source selector edge configuration (GSEL)
222  */
223 typedef enum XMC_HRPWM_HRC_SRC_EDGE_SEL
224 {
225   XMC_HRPWM_HRC_SRC_EDGE_SEL_DISABLED = 0U,  /**< source signal generation disabled */
226   XMC_HRPWM_HRC_SRC_EDGE_SEL_RISING,         /**< source signal generation on rising edge */
227   XMC_HRPWM_HRC_SRC_EDGE_SEL_FALLING,        /**< source signal generation on falling edge */
228   XMC_HRPWM_HRC_SRC_EDGE_SEL_BOTH            /**< source signal generation on both edges */
229 } XMC_HRPWM_HRC_SRC_EDGE_SEL_t;
230 
231 /**
232  * HRPWM function Enable / Disable status
233  */
234 typedef enum XMC_HRPWM_FUNC_STATUS
235 {
236   XMC_HRPWM_FUNC_STATUS_DISABLE = 0U,       /**< Function is disabled  */
237   XMC_HRPWM_FUNC_STATUS_ENABLE = 1U         /**< Function is enabled  */
238 } XMC_HRPWM_FUNC_STATUS_t;
239 
240 /**
241  * HRPWM high resolution module status
242  */
243 typedef enum XMC_HRPWM_HR_LOGIC
244 {
245   XMC_HRPWM_HR_LOGIC_NOT_WORKING = 0U,     /**< High resolution signal path is switched off for all HRC channels */
246   XMC_HRPWM_HR_LOGIC_WORKING               /**< High resolution signal path is switched on for all HRC channels */
247 } XMC_HRPWM_HR_LOGIC_t;
248 
249 /**
250  * High resolution paths for HRC channels
251  */
252 typedef enum XMC_HRPWM_HR_PATH
253 {
254   XMC_HRPWM_HR_PATH_HRC0 = HRPWM0_HRCCFG_HRC0E_Msk,  /**< HRC0 path selected for High resolution */
255   XMC_HRPWM_HR_PATH_HRC1 = HRPWM0_HRCCFG_HRC1E_Msk,  /**< HRC1 path selected for High resolution */
256   XMC_HRPWM_HR_PATH_HRC2 = HRPWM0_HRCCFG_HRC2E_Msk,  /**< HRC2 path selected for High resolution */
257   XMC_HRPWM_HR_PATH_HRC3 = HRPWM0_HRCCFG_HRC3E_Msk,  /**< HRC3 path selected for High resolution */
258 } XMC_HRPWM_HR_PATH_t;
259 
260 /**
261  * @brief Low resolution paths for HRC channels
262  */
263 typedef enum XMC_HRPWM_LR_PATH
264 {
265   XMC_HRPWM_LR_PATH_HRC0 = HRPWM0_HRCCFG_LRC0E_Msk,  /**< LRC0 path selected for Low resolution */
266   XMC_HRPWM_LR_PATH_HRC1 = HRPWM0_HRCCFG_LRC1E_Msk,  /**< LRC0 path selected for Low resolution */
267   XMC_HRPWM_LR_PATH_HRC2 = HRPWM0_HRCCFG_LRC2E_Msk,  /**< LRC0 path selected for Low resolution */
268   XMC_HRPWM_LR_PATH_HRC3 = HRPWM0_HRCCFG_LRC3E_Msk   /**< LRC0 path selected for Low resolution */
269 } XMC_HRPWM_LR_PATH_t;
270 
271 /**
272  * Shadow transfer for HRC values
273  * The enum is used to access the bitfields of registers HRCSTRG, HRCCTRG, HRCSTSG
274  */
275 typedef enum XMC_HRPWM_HRC_SHADOW_TX
276 {
277   XMC_HRPWM_HRC_SHADOW_TX_HRC0_VALUE      = 0x1U,     /**< HRC0 shadow transfer mask for CR1 & CR2 */
278   XMC_HRPWM_HRC_SHADOW_TX_HRC0_DT_VALUE   = 0x2U,     /**< HRC0 shadow transfer mask for DCR & DCRF */
279   XMC_HRPWM_HRC_SHADOW_TX_HRC1_VALUE      = 0x10U,    /**< HRC1 shadow transfer mask for CR1 & CR2 */
280   XMC_HRPWM_HRC_SHADOW_TX_HRC1_DT_VALUE   = 0x20U,    /**< HRC1 shadow transfer mask for DCR & DCRF */
281   XMC_HRPWM_HRC_SHADOW_TX_HRC2_VALUE      = 0x100U,   /**< HRC2 shadow transfer mask for CR1 & CR2 */
282   XMC_HRPWM_HRC_SHADOW_TX_HRC2_DT_VALUE   = 0x200U,   /**< HRC2 shadow transfer mask for DCR & DCRF */
283   XMC_HRPWM_HRC_SHADOW_TX_HRC3_VALUE      = 0x1000U,  /**< HRC3 shadow transfer mask for CR1 & CR2 */
284   XMC_HRPWM_HRC_SHADOW_TX_HRC3_DT_VALUE   = 0x2000U   /**< HRC3 shadow transfer mask for DCR & DCRF */
285 } XMC_HRPWM_HRC_SHADOW_TX_t;
286 
287 /**
288  * HR source selector
289  */
290 typedef enum XMC_HRPWM_HRC_SOURCE
291 {
292   XMC_HRPWM_HRC_SOURCE_0 = 0U,  /**< High resolution source 0 */
293   XMC_HRPWM_HRC_SOURCE_1        /**< High resolution source 1 */
294 } XMC_HRPWM_HRC_SOURCE_t;
295 
296 /**
297  * HRC dead time shadow transfer trigger selection
298  */
299 typedef enum XMC_HRPWM_HRC_DT_TR_SEL
300 {
301   XMC_HRPWM_HRC_DT_TR_SEL_TIMER = 0U,  /**< Source for shadow transfer trigger is CCU8 timer. */
302   XMC_HRPWM_HRC_DT_TR_SEL_OVERFLOW     /**< Source for shadow transfer trigger is dead time timer overflow. */
303 } XMC_HRPWM_HRC_DT_TR_SEL_t;
304 
305 /**
306  * HRPWM HRC output - Passive level
307  */
308 typedef enum XMC_HRPWM_HRC_OUT_PASSIVE_LVL
309 {
310   XMC_HRPWM_HRC_OUT_PASSIVE_LVL_LOW = 0U,  /**< Passive low output */
311   XMC_HRPWM_HRC_OUT_PASSIVE_LVL_HIGH       /**< Passive high output */
312 } XMC_HRPWM_HRC_OUT_PASSIVE_LVL_t;
313 
314 /***********************************************************************************************************************
315  * ENUMS - HRPWM CSG
316  **********************************************************************************************************************/
317 /**
318  * CSG power modes
319  */
320  typedef enum XMC_HRPWM_CSG_POWER_MODE
321 {
322   XMC_HRPWM_CSG_POWER_MODE_OFF       = 0U << HRPWM0_CSGCFG_C0PM_Pos,   /**< Comparator slope generator turned off */
323   XMC_HRPWM_CSG_POWER_MODE_LOW_SPEED = 1U << HRPWM0_CSGCFG_C0PM_Pos,   /**< Comparator slope generator in low speed mode */
324   XMC_HRPWM_CSG_POWER_MODE_HI_SPEED  = 3U << HRPWM0_CSGCFG_C0PM_Pos    /**< Comparator slope generator in high speed mode */
325 } XMC_HRPWM_CSG_POWER_MODE_t;
326 
327 /**
328  * DAC, Comparator start controls & Comparator clamped state control
329  * The enum is used to access the bitfields of registers CSGSETG, CSGCLRG, CSGSTATG
330  */
331 typedef enum XMC_HRPWM_CSG_RUN_BIT
332 {
333   XMC_HRPWM_CSG_RUN_BIT_DAC0       = 0x1U,    /**< Start DAC0 */
334   XMC_HRPWM_CSG_RUN_BIT_CMP0       = 0x2U,    /**< Start comparator 0 */
335   XMC_HRPWM_CSG_RUN_BIT_CMP0_PSL   = 0x4U,    /**< Set comparator 0 output to clamped state */
336   XMC_HRPWM_CSG_RUN_BIT_DAC1       = 0x10U,   /**< Start DAC1 */
337   XMC_HRPWM_CSG_RUN_BIT_CMP1       = 0x20U,   /**< Start comparator 1 */
338   XMC_HRPWM_CSG_RUN_BIT_CMP1_PSL   = 0x40U,   /**< Set comparator 1 output to clamped state */
339   XMC_HRPWM_CSG_RUN_BIT_DAC2       = 0x100U,  /**< Start DAC2 */
340   XMC_HRPWM_CSG_RUN_BIT_CMP2       = 0x200U,  /**< Start comparator2 */
341   XMC_HRPWM_CSG_RUN_BIT_CMP2_PSL   = 0x400U   /**< Set comparator 2 output to clamped state */
342 } XMC_HRPWM_CSG_RUN_BIT_t;
343 
344 /**
345  * Slope start for DAC units
346  */
347 typedef enum XMC_HRPWM_CSG_SLOPE_START
348 {
349   XMC_HRPWM_CSG_SLOPE_START_DAC0  = HRPWM0_CSGFCG_S0STR_Msk,       /**< Start slope generation for DAC0 */
350   XMC_HRPWM_CSG_SLOPE_START_DAC1  = HRPWM0_CSGFCG_S1STR_Msk,       /**< Start slope generation for DAC1 */
351   XMC_HRPWM_CSG_SLOPE_START_DAC2  = HRPWM0_CSGFCG_S2STR_Msk        /**< Start slope generation for DAC2 */
352 } XMC_HRPWM_CSG_SLOPE_START_t;
353 
354 /**
355  * Slope stop for DAC units
356  */
357 typedef enum XMC_HRPWM_CSG_SLOPE_STOP
358 {
359   XMC_HRPWM_CSG_SLOPE_STOP_DAC0  = HRPWM0_CSGFCG_S0STP_Msk,        /**< Stop slope generation for DAC0 */
360   XMC_HRPWM_CSG_SLOPE_STOP_DAC1  = HRPWM0_CSGFCG_S1STP_Msk,        /**< Stop slope generation for DAC1 */
361   XMC_HRPWM_CSG_SLOPE_STOP_DAC2  = HRPWM0_CSGFCG_S2STP_Msk         /**< Stop slope generation for DAC2 */
362 } XMC_HRPWM_CSG_SLOPE_STOP_t;
363 
364 /**
365  * Prescaler start in CSG
366  */
367 typedef enum XMC_HRPWM_CSG_PRESCALER_START
368 {
369   XMC_HRPWM_CSG_PRESCALER_START_CSG0  = HRPWM0_CSGFCG_PS0STR_Msk,  /**< Start prescaler of CSG0 */
370   XMC_HRPWM_CSG_PRESCALER_START_CSG1  = HRPWM0_CSGFCG_PS1STR_Msk,  /**< Start prescaler of CSG1 */
371   XMC_HRPWM_CSG_PRESCALER_START_CSG2  = HRPWM0_CSGFCG_PS2STR_Msk   /**< Start prescaler of CSG2 */
372 } XMC_HRPWM_CSG_PRESCALER_START_t;
373 
374 /**
375  * Prescaler stop in CSG
376  */
377 typedef enum XMC_HRPWM_CSG_PRESCALER_STOP
378 {
379   XMC_HRPWM_CSG_PRESCALER_STOP_CSG0  = HRPWM0_CSGFCG_PS0STP_Msk,   /**< Stop prescaler of CSG0 */
380   XMC_HRPWM_CSG_PRESCALER_STOP_CSG1  = HRPWM0_CSGFCG_PS1STP_Msk,   /**< Stop prescaler of CSG1 */
381   XMC_HRPWM_CSG_PRESCALER_STOP_CSG2  = HRPWM0_CSGFCG_PS2STP_Msk    /**< Stop prescaler of CSG2 */
382 } XMC_HRPWM_CSG_PRESCALER_STOP_t;
383 
384 /**
385  * Clear prescaler in CSG
386  */
387 typedef enum XMC_HRPWM_CSG_PRESCALER_CLR
388 {
389   XMC_HRPWM_CSG_PRESCALER_CLR_CSG0  = HRPWM0_CSGFCG_PS0CLR_Msk,    /**< Clear prescaler of CSG0 */
390   XMC_HRPWM_CSG_PRESCALER_CLR_CSG1  = HRPWM0_CSGFCG_PS1CLR_Msk,    /**< Clear prescaler of CSG1 */
391   XMC_HRPWM_CSG_PRESCALER_CLR_CSG2  = HRPWM0_CSGFCG_PS2CLR_Msk     /**< Clear prescaler of CSG2 */
392 } XMC_HRPWM_CSG_PRESCALER_CLR_t;
393 
394 /**
395  * DAC slope generation status
396  */
397 typedef enum XMC_HRPWM_DAC_SLOPE_GEN_STATUS
398 {
399   XMC_HRPWM_DAC_SLOPE_GEN_STATUS_DAC0  = HRPWM0_CSGFSG_S0RB_Msk,   /**< Slope generation status mask for DAC0 */
400   XMC_HRPWM_DAC_SLOPE_GEN_STATUS_DAC1  = HRPWM0_CSGFSG_S1RB_Msk,   /**< Slope generation status mask for DAC1 */
401   XMC_HRPWM_DAC_SLOPE_GEN_STATUS_DAC2  = HRPWM0_CSGFSG_S2RB_Msk    /**< Slope generation status mask for DAC2 */
402 } XMC_HRPWM_DAC_SLOPE_GEN_STATUS_t;
403 
404 /**
405  * CSG prescaler status
406  */
407 typedef enum XMC_HRPWM_CSG_PRESCALER_STATUS
408 {
409   XMC_HRPWM_CSG_PRESCALER_STATUS_CSG0  = HRPWM0_CSGFSG_P0RB_Msk,   /**< Prescaler status in CSG0 */
410   XMC_HRPWM_CSG_PRESCALER_STATUS_CSG1  = HRPWM0_CSGFSG_P1RB_Msk,   /**< Prescaler status in CSG1 */
411   XMC_HRPWM_CSG_PRESCALER_STATUS_CSG2  = HRPWM0_CSGFSG_P2RB_Msk    /**< Prescaler status in CSG2 */
412 } XMC_HRPWM_CSG_PRESCALER_STATUS_t;
413 
414 /**
415  * Comparator inputs
416  */
417 typedef enum XMC_HRPWM_CSG_CMP_INPUT
418 {
419   XMC_HRPWM_CSG_CMP_INPUT_CINA = 0U,  /**< Input for comparator is CINA */
420   XMC_HRPWM_CSG_CMP_INPUT_CINB        /**< Input for comparator is CINB */
421 } XMC_HRPWM_CSG_CMP_INPUT_t;
422 
423 /**
424  * CSG comparator input switch request
425  */
426 typedef enum XMC_HRPWM_CSG_SWITCH_CMP_INPUT
427 {
428   XMC_HRPWM_CSG_SWITCH_CMP_INPUT_CMP0 = HRPWM0_CSGTRSG_SW0ST_Msk,  /**< Request to switch the analog input connected to the comparator 0 between CINA and CINB */
429   XMC_HRPWM_CSG_SWITCH_CMP_INPUT_CMP1 = HRPWM0_CSGTRSG_SW1ST_Msk,  /**< Request to switch the analog input connected to the comparator 1 between CINA and CINB */
430   XMC_HRPWM_CSG_SWITCH_CMP_INPUT_CMP2 = HRPWM0_CSGTRSG_SW2ST_Msk   /**< Request to switch the analog input connected to the comparator 2 between CINA and CINB */
431 } XMC_HRPWM_CSG_SWITCH_CMP_INPUT_t;
432 
433 /**
434  * CSG comparator input switch request
435  */
436 typedef enum XMC_HRPWM_CSG_CMP_INVERTING_INPUT
437 {
438   XMC_HRPWM_CSG_CMP_INVERTING_INPUT_CMP0 = HRPWM0_CSGTRSG_D0STE_Msk,  /**< Comparator 0 inverting input connection */
439   XMC_HRPWM_CSG_CMP_INVERTING_INPUT_CMP1 = HRPWM0_CSGTRSG_D1STE_Msk,  /**< Comparator 1 inverting input connection */
440   XMC_HRPWM_CSG_CMP_INVERTING_INPUT_CMP2 = HRPWM0_CSGTRSG_D2STE_Msk   /**< Comparator 2 inverting input connection */
441 } XMC_HRPWM_CSG_CMP_INVERTING_INPUT_t;
442 
443 /**
444  * Input list to CSG
445  */
446 typedef enum XMC_HRPWM_CSG_INPUT_SEL
447 {
448   XMC_HRPWM_CSG_INPUT_SEL_IA = 0U,  /**< Input selected for blanking or comparator switch: Input-A */
449   XMC_HRPWM_CSG_INPUT_SEL_IB,       /**< Input selected for blanking or comparator switch: Input-B */
450   XMC_HRPWM_CSG_INPUT_SEL_IC,       /**< Input selected for blanking or comparator switch: Input-C */
451   XMC_HRPWM_CSG_INPUT_SEL_ID,       /**< Input selected for blanking or comparator switch: Input-D */
452   XMC_HRPWM_CSG_INPUT_SEL_IE,       /**< Input selected for blanking or comparator switch: Input-E */
453   XMC_HRPWM_CSG_INPUT_SEL_IF,       /**< Input selected for blanking or comparator switch: Input-F */
454   XMC_HRPWM_CSG_INPUT_SEL_IG,       /**< Input selected for blanking or comparator switch: Input-G */
455   XMC_HRPWM_CSG_INPUT_SEL_IH,       /**< Input selected for blanking or comparator switch: Input-H */
456   XMC_HRPWM_CSG_INPUT_SEL_II,       /**< Input selected for blanking or comparator switch: Input-I */
457   XMC_HRPWM_CSG_INPUT_SEL_IJ,       /**< Input selected for blanking or comparator switch: Input-J */
458   XMC_HRPWM_CSG_INPUT_SEL_IK,       /**< Input selected for blanking or comparator switch: Input-K */
459   XMC_HRPWM_CSG_INPUT_SEL_IL,       /**< Input selected for blanking or comparator switch: Input-L */
460   XMC_HRPWM_CSG_INPUT_SEL_IM,       /**< Input selected for blanking or comparator switch: Input-M */
461   XMC_HRPWM_CSG_INPUT_SEL_IN,       /**< Input selected for blanking or comparator switch: Input-N */
462   XMC_HRPWM_CSG_INPUT_SEL_IO,       /**< Input selected for blanking or comparator switch: Input-O */
463   XMC_HRPWM_CSG_INPUT_SEL_IP        /**< Input selected for blanking or comparator switch: Input-P */
464 } XMC_HRPWM_CSG_INPUT_SEL_t;
465 
466 /**
467  * HRPWM CSG - Selection of edge sensitivity
468  */
469 typedef enum XMC_HRPWM_CSG_EDGE_SEL
470 {
471   XMC_HRPWM_CSG_EDGE_SEL_DISABLED = 0U,  /**< Trigger event not generated */
472   XMC_HRPWM_CSG_EDGE_SEL_RISING_EDGE,    /**< Trigger event not generated in rising edge */
473   XMC_HRPWM_CSG_EDGE_SEL_FALLING_EDGE,   /**< Trigger event not generated in falling edge */
474   XMC_HRPWM_CSG_EDGE_SEL_BOTH_EDGE       /**< Trigger event not generated in both edges */
475 } XMC_HRPWM_CSG_EDGE_SEL_t;
476 
477 /**
478  * HRPWM CSG - Selection of level sensitivity
479  */
480 typedef enum XMC_HRPWM_CSG_LVL_SEL
481 {
482   XMC_HRPWM_CSG_LVL_SEL_DISABLED = 0U,  /**< Level sensitivity is disabled */
483   XMC_HRPWM_CSG_LVL_SEL_HIGH,           /**< Level sensitivity is High */
484   XMC_HRPWM_CSG_LVL_SEL_LOW             /**< Level sensitivity is Low */
485 } XMC_HRPWM_CSG_LVL_SEL_t;
486 
487 /**
488  * HRPWM CSG - Slope Generation clock selection
489  */
490 typedef enum XMC_HRPWM_CSG_CLK_INPUT
491 {
492   XMC_HRPWM_CSG_CLK_INPUT_MCLK = 0U,  /**< Clock for CSG is module clock */
493   XMC_HRPWM_CSG_CLK_INPUT_ECLKA,      /**< Clock for CSG is external clock A */
494   XMC_HRPWM_CSG_CLK_INPUT_ECLKB,      /**< Clock for CSG is external clock B */
495   XMC_HRPWM_CSG_CLK_INPUT_ECLKC       /**< Clock for CSG is external clock C */
496 } XMC_HRPWM_CSG_CLK_INPUT_t;
497 
498 /**
499  * HRPWM CSG - IRQ Event Id
500  * The enum is used to access the bitfields of registers CSGySRE, CSGySRS, CSGySWS, CSGySWC, CSGyISTAT
501  */
502 typedef enum XMC_HRPWM_CSG_IRQ_ID
503 {
504   XMC_HRPWM_CSG_IRQ_ID_VLS1 = 0x1U,   /**< Interrupt on DAC value switch from CSGyDSV1 to CSGyDSV2 interrupt */
505   XMC_HRPWM_CSG_IRQ_ID_VLS2 = 0x2U,   /**< Interrupt on DAC value switch from CSGyDSV2 to CSGyDSV1 interrupt */
506   XMC_HRPWM_CSG_IRQ_ID_TRGS = 0x4U,   /**< Interrupt on DAC conversion trigger */
507   XMC_HRPWM_CSG_IRQ_ID_STRS = 0x8U,   /**< Interrupt on DAC start trigger */
508   XMC_HRPWM_CSG_IRQ_ID_STPS = 0x10U,  /**< Interrupt on DAC stop trigger */
509   XMC_HRPWM_CSG_IRQ_ID_STD  = 0x20U,  /**< Interrupt on DAC shadow transfer */
510   XMC_HRPWM_CSG_IRQ_ID_CRSE = 0x40U,  /**< Interrupt on comparator output rise edge */
511   XMC_HRPWM_CSG_IRQ_ID_CFSE = 0x80U,  /**< Interrupt on comparator output fall edge */
512   XMC_HRPWM_CSG_IRQ_ID_CSEE = 0x100U  /**< Interrupt on comparator output clamped state */
513 } XMC_HRPWM_CSG_IRQ_ID_t;
514 
515 /**
516  * HRPWM CSG - Initial DAC start mode
517  */
518 typedef enum XMC_HRPWM_CSG_SWSM
519 {
520   XMC_HRPWM_CSG_SWSM_DSV2_W_TRIGGER = 0U,  /**< DSV2 is used as initial DAC value & conversion trigger is generated */
521   XMC_HRPWM_CSG_SWSM_DSV1_W_TRIGGER,       /**< DSV1 is used as initial DAC value & conversion trigger is generated */
522   XMC_HRPWM_CSG_SWSM_DSV2_NO_TRIGGER,      /**< DSV2 is used as initial DAC value & no conversion trigger generated */
523   XMC_HRPWM_CSG_SWSM_DSV1_NO_TRIGGER       /**< DSV1 is used as initial DAC value & no conversion trigger generated */
524 } XMC_HRPWM_CSG_SWSM_t;
525 
526 /**
527  * HRPWM CSG - Configuration for Clock disable
528  */
529 typedef enum XMC_HRPWM_CSG_CLK
530 {
531   XMC_HRPWM_CSG_CLK_CSG0 = HRPWM0_CSGCFG_C0CD_Msk,  /**< CSG0 clock mask */
532   XMC_HRPWM_CSG_CLK_CSG1 = HRPWM0_CSGCFG_C1CD_Msk,  /**< CSG1 clock mask */
533   XMC_HRPWM_CSG_CLK_CSG2 = HRPWM0_CSGCFG_C2CD_Msk   /**< CSG2 clock mask */
534 } XMC_HRPWM_CSG_CLK_t;
535 
536 /**
537  * HRPWM CSG - DAC shadow transfer values
538  */
539 typedef enum XMC_HRPWM_SHADOW_TX
540 {
541   XMC_HRPWM_SHADOW_TX_DAC0 = HRPWM0_CSGTRC_D0SEC_Msk,  /**< Shadow transfer mask for DAC0 - reference value 1 & Pulse swallow value */
542   XMC_HRPWM_SHADOW_TX_DAC1 = HRPWM0_CSGTRC_D1SEC_Msk,  /**< Shadow transfer mask for DAC1 - reference value 1 & Pulse swallow value */
543   XMC_HRPWM_SHADOW_TX_DAC2 = HRPWM0_CSGTRC_D2SEC_Msk   /**< Shadow transfer mask for DAC2 - reference value 1 & Pulse swallow value */
544 } XMC_HRPWM_SHADOW_TX_DAC_t;
545 
546 /**
547  * HRPWM CSG - Service request line
548  */
549 typedef enum XMC_HRPWM_CSG_IRQ_SR_LINE
550 {
551   XMC_HRPWM_CSG_IRQ_SR_LINE_0 = 0U, /**< CSG - Service request SR-0 */
552   XMC_HRPWM_CSG_IRQ_SR_LINE_1 = 1U, /**< CSG - Service request SR-1 */
553   XMC_HRPWM_CSG_IRQ_SR_LINE_2 = 2U, /**< CSG - Service request SR-2 */
554   XMC_HRPWM_CSG_IRQ_SR_LINE_3 = 3U  /**< CSG - Service request SR-3 */
555 } XMC_HRPWM_CSG_IRQ_SR_LINE_t;
556 
557 /**
558  * HRPWM CSG - Slope Generation control mode
559  */
560 typedef enum XMC_HRPWM_CSG_SLOPE_CTRL_MODE
561 {
562   XMC_HRPWM_CSG_SLOPE_CTRL_MODE_STATIC = 0U,  /**< Slope generation mode - Static mode */
563   XMC_HRPWM_CSG_SLOPE_CTRL_MODE_DEC_GEN,      /**< Slope generation mode - Decrementing slope generation */
564   XMC_HRPWM_CSG_SLOPE_CTRL_MODE_INC_GEN,      /**< Slope generation mode - Incrementing slope generation */
565   XMC_HRPWM_CSG_SLOPE_CTRL_MODE_TRIANGULAR    /**< Slope generation mode - Triangular slope generation */
566 } XMC_HRPWM_CSG_SLOPE_CTRL_MODE_t;
567 
568 /**
569  * HRPWM CSG - Prescaler external start configuration
570  */
571 typedef enum XMC_HRPWM_CSG_PRESCALER_EXT_START
572 {
573   XMC_HRPWM_CSG_PRESCALER_EXT_START_IGNORE = 0U,  /**< Prescaler operation on external start trigger is: Ignore */
574   XMC_HRPWM_CSG_PRESCALER_EXT_START_STRT,         /**< Prescaler operation on external start trigger is: Start prescaler */
575   XMC_HRPWM_CSG_PRESCALER_EXT_START_CLR,          /**< Prescaler operation on external start trigger is: Clear prescaler */
576   XMC_HRPWM_CSG_PRESCALER_EXT_START_CLR_N_STRT    /**< Prescaler operation on external start trigger is: Clear & Start prescaler */
577 } XMC_HRPWM_CSG_PRESCALER_EXT_START_t;
578 
579 /**
580  * HRPWM CSG - Prescaler external stop configuration
581  */
582 typedef enum XMC_HRPWM_CSG_PRESCALER_EXT_STOP
583 {
584   XMC_HRPWM_CSG_PRESCALER_EXT_STOP_IGNORE = 0U,  /**< Prescaler operation on external stop trigger is: Ignore */
585   XMC_HRPWM_CSG_PRESCALER_EXT_STOP_STP,          /**< Prescaler operation on external stop trigger is: Stop prescaler */
586   XMC_HRPWM_CSG_PRESCALER_EXT_STOP_CLR,          /**< Prescaler operation on external stop trigger is: Clear prescaler */
587   XMC_HRPWM_CSG_PRESCALER_EXT_STOP_CLR_N_STOP    /**< Prescaler operation on external stop trigger is: Clear & Stop prescaler */
588 } XMC_HRPWM_CSG_PRESCALER_EXT_STOP_t;
589 
590 /**
591  * HRPWM CSG - Slope Generation external start configuration
592  */
593 typedef enum XMC_HRPWM_CSG_SLOPE_EXT_START
594 {
595   XMC_HRPWM_CSG_SLOPE_EXT_START_IGNORE = 0U,  /**< Slope generation on external start trigger is: Ignore */
596   XMC_HRPWM_CSG_SLOPE_EXT_START_STRT,         /**< Slope generation on external start trigger is: Start/restart slope generation */
597   XMC_HRPWM_CSG_SLOPE_EXT_START_RESUME,       /**< Slope generation on external start trigger is: Resumes slope generation */
598 } XMC_HRPWM_CSG_SLOPE_EXT_START_t;
599 
600 /**
601  * HRPWM CGS - Slope Generation external stop configuration
602  */
603 typedef enum XMC_HRPWM_CSG_SLOPE_EXT_STOP
604 {
605   XMC_HRPWM_CSG_SLOPE_EXT_STOP_IGNORE = 0U,  /**< Slope generation on external stop trigger is: Ignore */
606   XMC_HRPWM_CSG_SLOPE_EXT_STOP_STP,          /**< Slope generation on external stop trigger is: Stops/Halts the slope generation */
607   XMC_HRPWM_CSG_SLOPE_EXT_STOP_FREEZE,       /**< Slope generation on external stop trigger is: Freezes slope generation & feeds constantly
608                                                                                                 the value programmed in CSGyDSV2 to the DAC */
609 } XMC_HRPWM_CSG_SLOPE_EXT_STOP_t;
610 
611 /**
612  * HRPWM CSG - Slice numbers
613  */
614 typedef enum XMC_HRPWM_CSG_SLICE
615 {
616   XMC_HRPWM_CSG_SLICE_0 = 0U, /**< CSG slice number is 0 */
617   XMC_HRPWM_CSG_SLICE_1,      /**< CSG slice number is 1 */
618   XMC_HRPWM_CSG_SLICE_2       /**< CSG slice number is 2 */
619 } XMC_HRPWM_CSG_SLICE_t;
620 
621 /**
622  * HRPWM CSG - Comparator output filter window
623  */
624 typedef enum XMC_HRPWM_CSG_CMP_FILTER_WINDOW
625 {
626   XMC_HRPWM_CSG_CMP_FILTER_WINDOW_2_CLK_CYCLES = 0U , /**< Needs to be stable for 2 clk cycles */
627   XMC_HRPWM_CSG_CMP_FILTER_WINDOW_3_CLK_CYCLES,       /**< Needs to be stable for 3 clk cycles */
628   XMC_HRPWM_CSG_CMP_FILTER_WINDOW_4_CLK_CYCLES,       /**< Needs to be stable for 4 clk cycles */
629   XMC_HRPWM_CSG_CMP_FILTER_WINDOW_5_CLK_CYCLES,       /**< Needs to be stable for 5 clk cycles */
630   XMC_HRPWM_CSG_CMP_FILTER_WINDOW_6_CLK_CYCLES,       /**< Needs to be stable for 6 clk cycles */
631   XMC_HRPWM_CSG_CMP_FILTER_WINDOW_7_CLK_CYCLES,       /**< Needs to be stable for 7 clk cycles */
632   XMC_HRPWM_CSG_CMP_FILTER_WINDOW_8_CLK_CYCLES,       /**< Needs to be stable for 8 clk cycles */
633   XMC_HRPWM_CSG_CMP_FILTER_WINDOW_9_CLK_CYCLES,       /**< Needs to be stable for 9 clk cycles */
634   XMC_HRPWM_CSG_CMP_FILTER_WINDOW_10_CLK_CYCLES,      /**< Needs to be stable for 10 clk cycles */
635   XMC_HRPWM_CSG_CMP_FILTER_WINDOW_11_CLK_CYCLES,      /**< Needs to be stable for 11 clk cycles */
636   XMC_HRPWM_CSG_CMP_FILTER_WINDOW_12_CLK_CYCLES,      /**< Needs to be stable for 12 clk cycles */
637   XMC_HRPWM_CSG_CMP_FILTER_WINDOW_13_CLK_CYCLES,      /**< Needs to be stable for 13 clk cycles */
638   XMC_HRPWM_CSG_CMP_FILTER_WINDOW_14_CLK_CYCLES,      /**< Needs to be stable for 14 clk cycles */
639   XMC_HRPWM_CSG_CMP_FILTER_WINDOW_15_CLK_CYCLES,      /**< Needs to be stable for 15 clk cycles */
640   XMC_HRPWM_CSG_CMP_FILTER_WINDOW_16_CLK_CYCLES,      /**< Needs to be stable for 16 clk cycles */
641   XMC_HRPWM_CSG_CMP_FILTER_WINDOW_32_CLK_CYCLES       /**< Needs to be stable for 32 clk cycles */
642 } XMC_HRPWM_CSG_CMP_FILTER_WINDOW_t;
643 
644 /**
645  * HRPWM CSG - Slope step gain
646  */
647 typedef enum XMC_HRPWM_CSG_SLOPE_STEP_GAIN
648 {
649   XMC_HRPWM_CSG_SLOPE_STEP_GAIN_INC_DEC_BY_1 = 0U,    /**< slope step has an increment/decrement of 1 */
650   XMC_HRPWM_CSG_SLOPE_STEP_GAIN_INC_DEC_BY_2,         /**< slope step has an increment/decrement of 2 */
651   XMC_HRPWM_CSG_SLOPE_STEP_GAIN_INC_DEC_BY_4,         /**< slope step has an increment/decrement of 4 */
652   XMC_HRPWM_CSG_SLOPE_STEP_GAIN_INC_DEC_BY_8          /**< slope step has an increment/decrement of 8 */
653 } XMC_HRPWM_CSG_SLOPE_STEP_GAIN_t;
654 
655 /**
656  * HRPWM CSG - Slope step gain
657  */
658 typedef enum XMC_HRPWM_CSG_PRESCALER_DIVISION
659 {
660   XMC_HRPWM_CSG_PRESCALER_DIVISION_BY_1 = 0U,         /**< Division by 1 */
661   XMC_HRPWM_CSG_PRESCALER_DIVISION_BY_2,              /**< Division by 2 */
662   XMC_HRPWM_CSG_PRESCALER_DIVISION_BY_4,              /**< Division by 4 */
663   XMC_HRPWM_CSG_PRESCALER_DIVISION_BY_8               /**< Division by 8 */
664 } XMC_HRPWM_CSG_PRESCALER_DIVISION_t;
665 
666 /*********************************************************************************************************************
667  * DATA STRUCTURES - HRPWM
668  ********************************************************************************************************************/
669 /**
670  * Typedef for HRPWM Global registers data structure
671  */
672 typedef HRPWM0_Type XMC_HRPWM_t;
673 
674 /**
675  * Typedef for HRPWM high resolution channel registers data structure
676  */
677 typedef HRPWM0_HRC_Type XMC_HRPWM_HRC_t;
678 
679 /**
680  * Typedef for CSG unit registers data structure
681  */
682 typedef HRPWM0_CSG_Type XMC_HRPWM_CSG_t;
683 
684 /**
685  * HRPWM HRC source path configuration
686  */
687 typedef struct XMC_HRPWM_HRC_SRC_CONFIG
688 {
689   XMC_HRPWM_HRC_HR_EDGE_t       high_res_mode;      /**< high resolution mode configuration */
690   XMC_HRPWM_HRC_SRC_INPUT_t     set_config;         /**< Selection of input for set configuration */
691   XMC_HRPWM_HRC_SRC_INPUT_t     clear_config;       /**< Selection of input clear configuration */
692   XMC_HRPWM_HRC_CMP_SEL_t       cmp_set;            /**< Selection of comparator for set configuration */
693   XMC_HRPWM_HRC_CMP_SEL_t       cmp_clear;          /**< Selection of comparator for clear configuration */
694   XMC_HRPWM_HRC_TIMER_SEL_t     timer_sel;          /**< Selection of timer */
695   XMC_HRPWM_HRC_SRC_EDGE_SEL_t  set_edge_config;    /**< Selection of edge for generating set signal */
696   XMC_HRPWM_HRC_SRC_EDGE_SEL_t  clear_edge_config;  /**< Selection of edge for generating clear signal */
697   XMC_HRPWM_FUNC_STATUS_t       src_trap_enable;    /**< Selection of source for trap signal generation */
698 } XMC_HRPWM_HRC_SRC_CONFIG_t;
699 
700 /*Anonymous structure/union guard start*/
701 #if defined(__CC_ARM)
702   #pragma push
703   #pragma anon_unions
704 #elif defined(__TASKING__)
705   #pragma warning 586
706 #endif
707 
708 /**
709  * HRPWM HRC configuration
710  */
711 typedef struct XMC_HRPWM_HRC_CONFIG
712 {
713   union
714   {
715     struct
716     {
717       uint32_t : 2;
718       uint32_t : 2;
719       uint32_t : 4;
720       uint32_t dt_enable: 1;                   /**< Enables dead time. Accepts enum @ref XMC_HRPWM_FUNC_STATUS_t */
721       uint32_t hr_out0_trap_enable: 1;         /**< Enables trap for HROUT0. Accepts enum XMC_HRPWM_FUNC_STATUS_t */
722       uint32_t hr_out1_trap_enable: 1;         /**< Enables trap for HROUT1. Accepts enum XMC_HRPWM_FUNC_STATUS_t */
723       uint32_t hrc_shadow_xfer_linktoCCU8: 1;  /**< Shadow transfer for CR1 and CR2 linked to shadow transfer trigger of CCU8 slice.
724                                                     Accepts enum XMC_HRPWM_FUNC_STATUS_t */
725       uint32_t dt_shadow_xfer_linktoCCU8: 1;   /**< Shadow transfer for DCR and DCF linked to shadow transfer trigger of CCU8 slice.
726                                                     Accepts enum XMC_HRPWM_FUNC_STATUS_t */
727       uint32_t hr_out0_inv_enable: 1;          /**< Enables inversion of HROUT0 output pin. Accepts enum XMC_HRPWM_FUNC_STATUS_t */
728       uint32_t hr_out1_inv_enable: 1;          /**< Enables inversion of HROUT1 output pin. Accepts enum XMC_HRPWM_FUNC_STATUS_t */
729       uint32_t : 1;
730       uint32_t dt_trigger_sel: 1;              /**< Selection of trigger for dead time shadow transfer. Accepts enum XMC_HRPWM_HRC_DT_TR_SEL_t */
731       uint32_t : 15;
732 	};
733     uint32_t gc;                               /**< General high resolution channel configuration */
734   };
735 
736   union
737   {
738     struct
739     {
740       uint32_t hr_out0_passive_level_out: 1;   /**< Selection of HROUT0 passive level. Accepts enum XMC_HRPWM_HRC_OUT_PASSIVE_LVL_t */
741       uint32_t hr_out1_passive_level_out: 1;   /**< Selection of HROUT0 passive level. Accepts enum XMC_HRPWM_HRC_OUT_PASSIVE_LVL_t */
742       uint32_t : 30;
743     };
744     uint32_t psl;                              /**< Output passive level configuration */
745   };
746 } XMC_HRPWM_HRC_CONFIG_t;
747 
748 /***********************************************************************************************************************
749  * DATA STRUCTURES - CSG
750  **********************************************************************************************************************/
751 /**
752  * Configuration data structure of a CSG input selection
753  */
754 typedef struct XMC_HRPWM_CSG_INPUT_CONFIG
755 {
756   XMC_HRPWM_CSG_INPUT_SEL_t  mapped_input; /**< CSG input selection */
757   XMC_HRPWM_CSG_EDGE_SEL_t   edge;         /**< Active edge of mapped_input */
758   XMC_HRPWM_CSG_LVL_SEL_t    level;        /**< Active level of mapped_input */
759 } XMC_HRPWM_CSG_INPUT_CONFIG_t;
760 
761 /**
762  *CSG Unit - Comparator configuration
763  */
764 typedef struct XMC_HRPWM_CSG_CMP
765 {
766   union
767   {
768     struct
769     {
770       uint32_t : 4;
771       uint32_t : 4;
772       uint32_t cmp_input_sel: 1;      /**< Comparator input pin selection. Accepts enum XMC_HRPWM_CSG_CMP_INPUT_t */
773       uint32_t cmp_input_sw: 2;       /**< Comparator input switching configuration. Accepts enum XMC_HRPWM_CSG_LVL_SEL_t */
774       uint32_t cmp_ext_sw_enable: 1;  /**< Enable switching of input between CINA and CINB via external trigger.
775                                            Accepts enum XMC_HRPWM_FUNC_STATUS_t */
776       uint32_t cmp_out_inv: 1;        /**< Invert comparator output. Accepts enum XMC_HRPWM_FUNC_STATUS_t */
777       uint32_t : 1;                      /*Enable Comparator output synchronization */
778       uint32_t blanking_mode: 2;      /**< Select the edge for blanking. Accepts enum XMC_HRPWM_CSG_EDGE_SEL_t */
779       uint32_t blank_ext_enable: 1;   /**< Enable blanking via external trigger. Accepts enum XMC_HRPWM_FUNC_STATUS_t */
780       uint32_t filter_enable: 1;      /**< Enable comparator output filter. Accepts enum XMC_HRPWM_FUNC_STATUS_t */
781       uint32_t filter_window: 4;      /**< Select the comparator output filter window */
782       uint32_t : 2;
783       uint32_t filter_control: 2;     /**< Select the filter application condition
784                                            00B Filtering is always done if enabled
785                                            01B Filtering is only done when CSGyDSV1 value is currently fed to the DAC
786                                            10B Filtering is only done when the CSGyDSV2 value is currently fed to the DAC */
787       uint32_t : 6;
788     };
789     uint32_t cc;                      /**< Comparator general configuration */
790   };
791 
792   uint32_t blanking_val;              /**< blanking value, blanking time = blanking_val * module clk freq */
793 
794   union
795   {
796     struct
797     {
798       uint32_t : 4;
799       uint32_t : 4;
800       uint32_t clamp_ctrl_lvl: 2;        /**< Select the trigger signal level for clamping the comparator output.
801                                               Accepts enum XMC_HRPWM_CSG_LVL_SEL_t */
802       uint32_t clamp_level: 1;           /**< Select the comparator output passive level value. */
803       uint32_t clamp_exit_sw_config: 1;  /**< Clamped state exit software configuration */
804       uint32_t clamp_enter_config: 2;    /**< Clamping level enter configuration */
805       uint32_t clamp_exit_config: 2;     /**< Clamping level exit configuration */
806       uint32_t : 16;
807     };
808     uint32_t plc;                        /**< Comparator passive level configuration */
809   };
810 } XMC_HRPWM_CSG_CMP_t;
811 
812 /**
813  * CSG Unit - DAC configuration
814  */
815 typedef struct XMC_HRPWM_CSG_DAC
816 {
817   XMC_HRPWM_CSG_SWSM_t     start_mode;  /**< Initial DAC start mode */
818   uint32_t                 dac_dsv1;    /**< DAC reference value 1 */
819   uint32_t                 dac_dsv2;    /**< DAC reference value 2 */
820 } XMC_HRPWM_CSG_DAC_t;
821 
822 /**
823  * CSG Unit - Slope Generation configuration
824  */
825 typedef struct XMC_HRPWM_CSG_SGEN
826 {
827   union
828   {
829     struct
830     {
831       uint32_t prescaler_ext_start_mode: 2;  /**< Pre-scaler external start mode. Accepts enum XMC_HRPWM_CSG_PRESCALER_EXT_START_t */
832       uint32_t prescaler_ext_stop_mode: 2;   /**< Pre-scaler external stop mode. Accepts enum XMC_HRPWM_CSG_PRESCALER_EXT_STOP_t */
833       uint32_t fixed_prescaler_enable: 1;    /**< Fixed pre-scaler, 0:enabled, 1:disabled */
834       uint32_t prescaler: 2;                 /**< Pre-scaler division factor */
835       uint32_t : 1;
836       uint32_t ctrl_mode: 2;                 /**< Slope control mode. Accepts enum XMC_HRPWM_CSG_SLOPE_CTRL_MODE_t */
837       uint32_t ext_start_mode: 2;            /**< Slope external start mode. Accepts enum XMC_HRPWM_CSG_SLOPE_EXT_START_t */
838       uint32_t ext_stop_mode: 2;             /**< Slope external stop mode. Accepts enum XMC_HRPWM_CSG_SLOPE_EXT_STOP_t */
839       uint32_t slope_ref_val_mode: 2;        /**< Slope reference value mode */
840       uint32_t : 2; /* start_mode */
841       uint32_t step_gain: 2;                 /**< Slope step gain configuration */
842       uint32_t static_mode_ist_enable: 1;    /**< Immediate shadow transfer in static mode enabled. Accepts enum XMC_HRPWM_FUNC_STATUS_t */
843       uint32_t pulse_swallow_enable: 1;      /**< Pulse swallow enable / disable. Accepts enum XMC_HRPWM_FUNC_STATUS_t */
844       uint32_t : 2;
845       uint32_t pulse_swallow_win_mode: 2;    /**< Pulse swallow window mode */
846       uint32_t : 6;
847     };
848     uint32_t sc;                             /**< Slope Generation Configuration */
849   };
850   uint32_t   pulse_swallow_val;              /**< Pulse swallow value */
851 } XMC_HRPWM_CSG_SGEN_t;
852 
853 /*Anonymous structure/union guard end*/
854 #if defined(__CC_ARM)
855   #pragma pop
856 #elif defined(__TASKING__)
857   #pragma warning restore
858 #endif
859 
860 /**
861  * HRPWM CSG configuration
862  */
863 typedef struct XMC_HRPWM_CSG_CONFIG
864 {
865   XMC_HRPWM_CSG_CMP_t	  cmp_config;       /**< Comparator set up */
866   XMC_HRPWM_CSG_DAC_t     dac_config;       /**< DAC configuration of CSG */
867   XMC_HRPWM_CSG_SGEN_t    sgen_config;      /**< Slope generation related configurations */
868 } XMC_HRPWM_CSG_CONFIG_t;
869 
870 /***********************************************************************************************************************
871  * API PROTOTYPES
872  **********************************************************************************************************************/
873 /**
874  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
875  * @return XMC_HRPWM_STATUS_t
876  *
877  * \par<b>Description </b>
878  * <br>HRPWM Init <br>\n
879  *
880  * This function initializes the HRPWM global registers. It configures the CSG trimming data.
881  * This is the first function that needs to be called in initializing HRC or CSG modules.
882  *
883  * \par<b>Related APIs: </b><br>
884  * XMC_SDMMC_TriggerEvent()\n\n\n
885 
886  */
887 XMC_HRPWM_STATUS_t XMC_HRPWM_Init(XMC_HRPWM_t *const hrpwm);
888 
889 /**
890  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
891  * @return None
892  *
893  * \par<b>Description </b>
894  * <br>Enable global high resolution generation<br>\n
895  *
896  * Enables global high resolution generation by setting GLBANA.GHREN bit.
897  *
898  * \par<b>Related APIs: </b><br>
899  *  XMC_HRPWM_DisableGlobalHR()<br>
900  */
901 void XMC_HRPWM_EnableGlobalHR(XMC_HRPWM_t *const hrpwm);
902 
903 /**
904  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
905  * @return None
906  *
907  * \par<b>Description </b>
908  * <br>Disable global high resolution generation<br>\n
909  *
910  * Disables global high resolution generation by clearing GLBANA.GHREN bit.
911  *
912  * \par<b>Related APIs: </b><br>
913  *  XMC_HRPWM_EnableGlobalHR()<br>
914  */
915 
916 void XMC_HRPWM_DisableGlobalHR(XMC_HRPWM_t *const hrpwm);
917 
918 /**
919  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
920  * @return None
921  *
922  * \par<b>Description </b>
923  * <br>Enables the bias generation<br>\n
924  *
925  * Enables the bias generation of high resolution generation by setting HRBSC.HRBE bit.
926  *
927  * \par<b>Related APIs: </b><br>
928  *  XMC_HRPWM_DisableBias()<br>
929  */
930 
XMC_HRPWM_EnableBias(XMC_HRPWM_t * const hrpwm)931 __STATIC_INLINE void XMC_HRPWM_EnableBias(XMC_HRPWM_t *const hrpwm)
932 {
933   XMC_ASSERT("XMC_HRPWM_EnableBias:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
934   hrpwm->HRBSC |= HRPWM0_HRBSC_HRBE_Msk;
935 }
936 
937 /**
938  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
939  * @return None
940  *
941  * \par<b>Description </b>
942  * <br>Disables the bias generation<br>\n
943  *
944  * Disables the bias generation of high resolution generation by clearing HRBSC.HRBE bit.
945  *
946  * \par<b>Related APIs: </b><br>
947  *  XMC_HRPWM_EnableBias()<br>
948  */
XMC_HRPWM_DisableBias(XMC_HRPWM_t * const hrpwm)949 __STATIC_INLINE void XMC_HRPWM_DisableBias(XMC_HRPWM_t *const hrpwm)
950 {
951   XMC_ASSERT("XMC_HRPWM_DisableBias:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
952   hrpwm->HRBSC &= ~(HRPWM0_HRBSC_HRBE_Msk);
953 }
954 
955 /***********************************************************************************************************************
956  * API PROTOTYPES - HRPWM HRC GLOBAL
957  **********************************************************************************************************************/
958 /**
959  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
960  * @return XMC_HRPWM_HR_LOGIC_t
961  *
962  * \par<b>Description </b>
963  * <br>Returns the status of the high resolution logic.<br>\n
964  *
965  * Returns status of the high resolution logic by checking HRGHRS.HRGR bit.
966  * The return value should be @ref XMC_HRPWM_HR_LOGIC_WORKING for proper generation of high resolution signal positioning.
967  */
968 
969 XMC_HRPWM_HR_LOGIC_t XMC_HRPWM_GetHRGenReadyStatus(XMC_HRPWM_t *const hrpwm);
970 
971 /**
972  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
973  * @param mask masked values of selected HRC modules. Use the enum type @ref XMC_HRPWM_HR_PATH_t to generate the mask.
974  * @return None
975  *
976  * \par<b>Description</b>
977  * <br>Enables the high resolution path.<br>\n
978  *
979  * Enables the high resolution path determined by passed mask value, by setting HRCCFG.HRC0E bit.
980  * By default signals from source selector 0 are linked to HR path and signals from source selector 1 are linked to LR path.
981  * This connections can be reversed at runtime, if bit HRCySC.ST is set to 1.
982  *
983  * \par<b>Related APIs: </b><br>
984  *  XMC_HRPWM_HRC_Set_HR_Source()<br>
985  *  XMC_HRPWM_DisableHighResolutionPath()<br>
986  *  XMC_HRPWM_EnableLowResolutionPath()<br>
987  *  XMC_HRPWM_DisableLowResolutionPath()<br>
988  *  XMC_HRPWM_EnableHRPowerMode()<br>
989  *
990  */
991 
XMC_HRPWM_EnableHighResolutionPath(XMC_HRPWM_t * const hrpwm,const uint32_t mask)992 __STATIC_INLINE void XMC_HRPWM_EnableHighResolutionPath(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
993 {
994   XMC_ASSERT("XMC_HRPWM_EnableHighResolutionPath:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
995   hrpwm->HRCCFG |= mask;
996 }
997 
998 /**
999  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1000  * @param mask masked values of selected HRC modules. Use the enum type @ref XMC_HRPWM_HR_PATH_t to generate the mask.
1001  * @return None
1002  *
1003  * \par<b>Description </b>
1004  * <br>Disables the high resolution path<br>\n
1005  *
1006  * Disables the high resolution path determined by passed mask value, by clearing HRCCFG.HRC0E bit.
1007  *
1008  * \par<b>Related APIs: </b><br>
1009  * XMC_HRPWM_EnableHighResolutionPath()<br>
1010  * XMC_HRPWM_EnableLowResolutionPath()<br>
1011  * XMC_HRPWM_DisableLowResolutionPath()<br>
1012  *
1013  */
XMC_HRPWM_DisableHighResolutionPath(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1014 __STATIC_INLINE void XMC_HRPWM_DisableHighResolutionPath(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1015 {
1016   XMC_ASSERT("XMC_HRPWM_DisableHighResolutionPath:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1017   hrpwm->HRCCFG &= ~mask;
1018 }
1019 
1020 /**
1021  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1022  * @param mask masked values of selected HRC modules. Use the enum type @ref XMC_HRPWM_LR_PATH_t to generate the mask.
1023  * @return None
1024  *
1025  * \par<b>Description </b>
1026  * <br>Enables the low resolution path<br>\n
1027  *
1028  * Enables the low resolution path determined by passed mask value, by setting HRCCFG.LRC0E bit.
1029  * By default signals from source selector 0 are linked to HR path and signals from source selector 1 are linked to LR path.
1030  * This connections can be reversed at runtime, if bit HRCySC.ST is set to 1.
1031  *
1032  * \par<b>Related APIs: </b><br>
1033  * XMC_HRPWM_HRC_Set_HR_Source()<br>
1034  * XMC_HRPWM_EnableHighResolutionPath()<br>
1035  * XMC_HRPWM_DisableHighResolutionPath()<br>
1036  * XMC_HRPWM_DisableLowResolutionPath()<br>
1037  * XMC_HRPWM_EnableHRPowerMode()<br>
1038  */
1039 
XMC_HRPWM_EnableLowResolutionPath(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1040 __STATIC_INLINE void XMC_HRPWM_EnableLowResolutionPath(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1041 {
1042   XMC_ASSERT("XMC_HRPWM_EnableLowResolutionPath:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1043   hrpwm->HRCCFG |= mask;
1044 }
1045 
1046 /**
1047  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1048  * @param mask masked values of selected HRC modules. Use the enum type @ref XMC_HRPWM_LR_PATH_t to generate the mask.
1049  * @return None
1050  *
1051  * \par<b>Description </b>
1052  * <br>Disables the low resolution path<br>\n
1053  *
1054  * Disables the low resolution path determined by passed mask value, by clearing HRCCFG.LRC0E bit.
1055  *
1056  * \par<b>Related APIs: </b><br>
1057  * XMC_HRPWM_EnableHighResolutionPath()<br>
1058  * XMC_HRPWM_DisableHighResolutionPath()<br>
1059  * XMC_HRPWM_EnableLowResolutionPath()<br>
1060  *
1061  */
XMC_HRPWM_DisableLowResolutionPath(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1062  __STATIC_INLINE void XMC_HRPWM_DisableLowResolutionPath(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1063 {
1064   XMC_ASSERT("XMC_HRPWM_DisableLowResolutionPath:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1065   hrpwm->HRCCFG &= ~mask;
1066 }
1067 
1068  /**
1069   * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1070   * @param mask masked values of selected HRC modules. Use the enum type @ref XMC_HRPWM_HRC_SHADOW_TX_t to generate the mask.
1071   * @return None
1072   *
1073   * \par<b>Description </b>
1074   * <br>Enables the high resolution shadow transfer<br> \n
1075   *
1076   * Enables the high resolution shadow transfer determined by passed mask value, by setting HRCSTRG.H0ES, HRCSTRG.H0DES bits.
1077   * The input for trigger for shadow transfer needs to be configured correctly.
1078   *
1079   * \par<b>Related APIs: </b><br>
1080   * XMC_HRPWM_DisableHighResolutionShadowTransfer()<br>
1081   * XMC_HRPWM_GetHighResolutionShadowTransferStatus()<br>
1082   *
1083   */
1084 
XMC_HRPWM_EnableHighResolutionShadowTransfer(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1085 __STATIC_INLINE void XMC_HRPWM_EnableHighResolutionShadowTransfer(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1086 {
1087   XMC_ASSERT("XMC_HRPWM_EnableHighResolutionShadowTransfer:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1088   hrpwm->HRCSTRG = mask;
1089 }
1090 
1091 /**
1092  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1093  * @param mask masked values of selected HRC modules. Use the enum type @ref XMC_HRPWM_HRC_SHADOW_TX_t to generate the mask.
1094  * @return None
1095  *
1096  * \par<b>Description </b>
1097  * <br>Disables the high resolution shadow transfer<br>\n
1098  *
1099  * Disables the high resolution shadow transfer determined by passed mask value, by setting HRCCTRG.H0EC, HRCCTRG.H0DEC bits.
1100  * It cancels shadow transfer request by @ref XMC_HRPWM_EnableHighResolutionShadowTransfer(), provided the shadow transfer has not occurred.
1101  *
1102  * \par<b>Related APIs: </b><br>
1103  * XMC_HRPWM_EnableHighResolutionShadowTransfer()<br>
1104  *
1105  */
XMC_HRPWM_DisableHighResolutionShadowTransfer(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1106 __STATIC_INLINE void XMC_HRPWM_DisableHighResolutionShadowTransfer(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1107 {
1108   XMC_ASSERT("XMC_HRPWM_DisableHighResolutionShadowTransfer:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1109   hrpwm->HRCCTRG = mask;
1110 }
1111 
1112 /**
1113  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1114  * @param mask masked values of selected HRC modules. Use the enum type @ref XMC_HRPWM_HRC_SHADOW_TX_t to generate the mask.
1115  * @return uint32_t
1116  *
1117  * \par<b>Description </b>
1118  * <br>Returns the shadow transfer request status<br>\n
1119  *
1120  * Returns the shadow transfer request status, by checking HRCSTSG.H0STE, HRCSTSG.H0DSTE bits.
1121  * Returns a non zero value if corresponding shadow transfer request has been performed.
1122  *
1123  * \par<b>Related APIs: </b><br>
1124  * XMC_HRPWM_EnableHighResolutionShadowTransfer()<br>
1125  *
1126  */
XMC_HRPWM_GetHighResolutionShadowTransferStatus(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1127 __STATIC_INLINE uint32_t XMC_HRPWM_GetHighResolutionShadowTransferStatus(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1128 {
1129   XMC_ASSERT("XMC_HRPWM_GetHighResolutionShadowTransferStatus:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1130   return (hrpwm->HRCSTSG & mask);
1131 }
1132 
1133 /**
1134  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1135  * @return None
1136  *
1137  * \par<b>Description </b>
1138  * <br>Turns ON the power to all HR and LR path<br>\n
1139  *
1140  * Turns ON the power to all HR and LR path by setting HRCCFG.HRCPM bit. Enable the HR and LR paths as per requirement by
1141  * calling following API @ref XMC_HRPWM_EnableHighResolutionPath() and @ref XMC_HRPWM_EnableLowResolutionPath().
1142  *
1143  * \par<b>Related APIs: </b><br>
1144  * XMC_HRPWM_EnableHighResolutionPath()<br>
1145  * XMC_HRPWM_EnableLowResolutionPath()<br>
1146  *
1147  */
XMC_HRPWM_EnableHRPowerMode(XMC_HRPWM_t * const hrpwm)1148 __STATIC_INLINE void XMC_HRPWM_EnableHRPowerMode(XMC_HRPWM_t *const hrpwm)
1149 {
1150   XMC_ASSERT("XMC_HRPWM_EnableHRPowerMode:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1151   hrpwm->HRCCFG |= HRPWM0_HRCCFG_HRCPM_Msk;
1152 }
1153 
1154 /**
1155  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1156  * @return None
1157  *
1158  * \par<b>Description </b>
1159  * <br>Turns OFF the power to all HR and LR path<br>\n
1160  *
1161  * Turns OFF the power to all HR and LR path by clearing HRCCFG.HRCPM bit.
1162  * This disables all HR and LR paths.
1163  *
1164  * \par<b>Related APIs: </b><br>
1165  * XMC_HRPWM_EnableHRPowerMode()<br>
1166  *
1167  */
XMC_HRPWM_DisableHRPowerMode(XMC_HRPWM_t * const hrpwm)1168 __STATIC_INLINE void XMC_HRPWM_DisableHRPowerMode(XMC_HRPWM_t *const hrpwm)
1169 {
1170   XMC_ASSERT("XMC_HRPWM_DisableHRPowerMode:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1171 
1172   /* Turn off high resolution generation logic */
1173   hrpwm->HRCCFG &= ~(HRPWM0_HRCCFG_HRCPM_Msk);
1174 }
1175 
1176 /**
1177  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1178  * @param clk_freq The operating clock frequency of HRPWM module. Use the enum type @ref XMC_HRPWM_CLK_FREQ_t to generate the mask.
1179  * @return None
1180  *
1181  * \par<b>Description </b>
1182  * <br>Configures the clock frequency of operation of HRPWM module<br>\n
1183  *
1184  * Configures the clock frequency of operation of HRPWM module by configuring HRCCFG.CLKC bits.
1185  * The clock is generally selected based on the device type selected.
1186  *
1187  */
1188 
XMC_HRPWM_ModuleClkFreq(XMC_HRPWM_t * const hrpwm,const XMC_HRPWM_CLK_FREQ_t clk_freq)1189 __STATIC_INLINE void XMC_HRPWM_ModuleClkFreq(XMC_HRPWM_t *const hrpwm, const XMC_HRPWM_CLK_FREQ_t clk_freq)
1190 {
1191   XMC_ASSERT("XMC_HRPWM_ModuleClkFreq:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1192 
1193   hrpwm->HRCCFG &= ~(HRPWM0_HRCCFG_CLKC_Msk);
1194   hrpwm->HRCCFG |= (clk_freq << HRPWM0_HRCCFG_CLKC_Pos);
1195 }
1196 
1197 /***********************************************************************************************************************
1198  * API PROTOTYPES - HRPWM CSG GLOBAL
1199  **********************************************************************************************************************/
1200 /**
1201  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1202  * @param mask masked values of selected CSG modules. Use the enum type @ref XMC_HRPWM_CSG_RUN_BIT_t to generate the mask.
1203  * @return None
1204  *
1205  * \par<b>Description </b>
1206  * <br>Enables the operation of comparator <br>\n
1207  *
1208  * Enables the operation of comparator by setting CSGSETG.SC0R bit.
1209  *
1210  * \par<b>Related APIs: </b><br>
1211  * XMC_HRPWM_StopComparator()<br>
1212  * XMC_HRPWM_IsComparatorRunning()<br>
1213  */
1214 
XMC_HRPWM_StartComparator(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1215 __STATIC_INLINE void XMC_HRPWM_StartComparator(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1216 {
1217   XMC_ASSERT("XMC_HRPWM_StartComparator:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1218   hrpwm->CSGSETG = mask;
1219 }
1220 
1221 /**
1222  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1223  * @param mask masked values of selected CSG modules. Use the enum type @ref XMC_HRPWM_CSG_RUN_BIT_t to generate the mask.
1224  * @return None
1225  *
1226  * \par<b>Description </b>
1227  * <br>Disables the operation of comparator<br>\n
1228  *
1229  * Disables the operation of comparator by setting CSGCLRG.CC0R bit.
1230  *
1231  * \par<b>Related APIs: </b><br>
1232  * XMC_HRPWM_StartComparator()<br>
1233  * XMC_HRPWM_IsComparatorRunning()<br>
1234  */
XMC_HRPWM_StopComparator(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1235 __STATIC_INLINE void XMC_HRPWM_StopComparator(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1236 {
1237   XMC_ASSERT("XMC_HRPWM_StopComparator:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1238   hrpwm->CSGCLRG = mask;
1239 }
1240 
1241 /**
1242  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1243  * @param mask masked values of selected CSG modules. Use the enum type @ref XMC_HRPWM_CSG_RUN_BIT_t to generate the mask.
1244  * @return bool
1245  *
1246  * \par<b>Description </b>
1247  * <br>Checks if comparator is enabled<br>\n
1248  *
1249  * Checks if comparator is enabled by checking CSGSTATG.C0RB bit.
1250  * Returns true if comparator run bit is set, else returns false.
1251  *
1252  * \par<b>Related APIs: </b><br>
1253  * XMC_HRPWM_StartComparator()<br>
1254  * XMC_HRPWM_StopComparator()<br>
1255  */
XMC_HRPWM_IsComparatorRunning(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1256 __STATIC_INLINE bool XMC_HRPWM_IsComparatorRunning(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1257 {
1258   bool status;
1259 
1260   XMC_ASSERT("XMC_HRPWM_IsComparatorRunning:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1261 
1262   if(hrpwm->CSGSTATG & mask)
1263   {
1264     status = true;
1265   }
1266   else
1267   {
1268     status = false;
1269   }
1270 
1271   return (status);
1272 }
1273 
1274 /**
1275  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1276  * @param mask masked values of selected CSG modules. Use the enum type @ref XMC_HRPWM_CSG_RUN_BIT_t to generate the mask.
1277  * @return None
1278  *
1279  * \par<b>Description </b>
1280  * <br>Enables the operation of CSG DAC<br>\n
1281  *
1282  * Enables the operation of CSG DAC by setting CSGSETG.SD0R bit.
1283  * The DAC operation is enabled. Either the value in DSV1 or DSV2 is sent to DAC, based on configuration.
1284  *
1285  * \par<b>Related APIs: </b><br>
1286  * XMC_HRPWM_StopDac()<br>
1287  * XMC_HRPWM_IsDacRunning()<br>
1288  */
1289 
XMC_HRPWM_StartDac(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1290 __STATIC_INLINE void XMC_HRPWM_StartDac(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1291 {
1292   XMC_ASSERT("XMC_HRPWM_StartDac:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1293   hrpwm->CSGSETG = mask;
1294 }
1295 
1296 /**
1297  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1298  * @param mask masked values of selected CSG modules. Use the enum type @ref XMC_HRPWM_CSG_RUN_BIT_t to generate the mask.
1299  * @return None
1300  *
1301  * \par<b>Description </b>
1302  * <br>Disables the operation of CSG DAC<br>\n
1303  *
1304  * Disables the operation of CSG DAC by setting CSGCLRG.CD0R bit.
1305  *
1306  * \par<b>Related APIs: </b><br>
1307  * XMC_HRPWM_StartDac()<br>
1308  * XMC_HRPWM_IsDacRunning()<br>
1309  *
1310  */
XMC_HRPWM_StopDac(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1311 __STATIC_INLINE void XMC_HRPWM_StopDac(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1312 {
1313   XMC_ASSERT("XMC_HRPWM_StopDac:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1314   hrpwm->CSGCLRG = mask;
1315 }
1316 
1317 /**
1318  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1319  * @param mask masked values of selected CSG modules. Use the enum type @ref XMC_HRPWM_CSG_RUN_BIT_t to generate the mask.
1320  * @return uint32_t
1321  *
1322  * \par<b>Description </b>
1323  * <br>Checks if CSG DAC is operational<br>\n
1324  *
1325  * Checks if CSG DAC is operational by checking CSGSTATG.D0RB bit.
1326  *
1327  * \par<b>Related APIs: </b><br>
1328  * XMC_HRPWM_StartDac()<br>
1329  * XMC_HRPWM_StopDac()<br>
1330  */
XMC_HRPWM_IsDacRunning(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1331 __STATIC_INLINE uint32_t XMC_HRPWM_IsDacRunning(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1332 {
1333   XMC_ASSERT("XMC_HRPWM_IsDacRunning:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1334   return (hrpwm->CSGSTATG & mask);
1335 }
1336 
1337 /**
1338  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1339  * @param mask masked values of selected CSG modules. Use the enum type @ref XMC_HRPWM_CSG_RUN_BIT_t to generate the mask.
1340  * @return None
1341  *
1342  * \par<b>Description </b>
1343  * <br>Set the comparator output to clamp state<br> \n
1344  *
1345  * Sets the comparator to clamped state via software by setting CSGSETG.SC0P bit. The output of comparator is now not dependent on its inputs pins.
1346  * The clamped state is defined by comparator output passive level value. Output passive level can be set to high or low.
1347  *
1348  * \par<b>Related APIs: </b><br>
1349  * XMC_HRPWM_UnClampComparatorOutput()<br>
1350  * XMC_HRPWM_IsComparatorClamped()<br>
1351  */
1352 
XMC_HRPWM_ClampComparatorOutput(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1353 __STATIC_INLINE void XMC_HRPWM_ClampComparatorOutput(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1354 {
1355   XMC_ASSERT("XMC_HRPWM_ClampComparatorOutput:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1356 
1357   hrpwm->CSGSETG = mask;
1358 }
1359 
1360 /**
1361  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1362  * @param mask masked values of selected CSG modules. Use the enum type @ref XMC_HRPWM_CSG_RUN_BIT_t to generate the mask.
1363  * @return None
1364  *
1365  * \par<b>Description </b>
1366  * <br>Clear the comparator output from clamp state<br>\n
1367  *
1368  * Un-clamps the output of comparator from clamped state set via software by setting CSGCLRG.CC0P bit. The output of
1369  * comparator is now dependent on the inputs of comparator.
1370  *
1371  * \par<b>Related APIs: </b><br>
1372  * XMC_HRPWM_ClampComparatorOutput()<br>
1373  * XMC_HRPWM_IsComparatorClamped()<br>
1374  */
XMC_HRPWM_UnClampComparatorOutput(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1375 __STATIC_INLINE void XMC_HRPWM_UnClampComparatorOutput(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1376 {
1377   XMC_ASSERT("XMC_HRPWM_UnClampComparatorOutput:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1378 
1379   hrpwm->CSGCLRG = mask;
1380 }
1381 
1382 /**
1383  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1384  * @param mask masked values of selected CSG modules. Use the enum type @ref XMC_HRPWM_CSG_RUN_BIT_t to generate the mask.
1385  * @return uint32_t
1386  *
1387  * \par<b>Description </b>
1388  * <br>Checks if comparator is in clamped state <br>\n
1389  *
1390  * Checks if comparator is in clamped state by checking CSGSTATG.PSLS0 bit.
1391  * Returns bit encoded status if comparator is set to clamped state via software.
1392  *
1393  * \par<b>Related APIs: </b><br>
1394  * XMC_HRPWM_ClampComparatorOutput()<br>
1395  * XMC_HRPWM_UnClampComparatorOutput()<br>
1396  */
1397 
XMC_HRPWM_IsComparatorClamped(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1398 __STATIC_INLINE uint32_t XMC_HRPWM_IsComparatorClamped(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1399 {
1400   XMC_ASSERT("XMC_HRPWM_IsComparatorClamped:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1401 
1402   return (hrpwm->CSGSTATG & mask);
1403 }
1404 
1405 /**
1406  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1407  * @param mask masked values of selected CSG modules. Use the enum type @ref XMC_HRPWM_CSG_RUN_BIT_t to generate the mask.
1408  * @return uint32_t
1409  *
1410  * \par<b>Description </b>
1411  * <br>Returns bit encoded status of multiple DACs and Comparators, defined by the mask.<br>\n
1412  *
1413  * Returns bit encoded status of multiple DACs and Comparators from register CSGSTATG, defined by the mask.
1414  * The mask is generated by bitwise ORing multiple Enums.<br>
1415  * mask = (uint32_t) (XMC_HRPWM_CSG_RUN_BIT_CMP0 | XMC_HRPWM_CSG_RUN_BIT_DAC0 | XMC_HRPWM_CSG_RUN_BIT_CMP0_PSL);
1416  *
1417  * \par<b>Related APIs: </b><br>
1418  * XMC_HRPWM_IsDacRunning()<br>
1419  * XMC_HRPWM_IsComparatorClamped()<br>
1420  */
1421 
XMC_HRPWM_GetRunBitStatus(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1422 __STATIC_INLINE uint32_t XMC_HRPWM_GetRunBitStatus(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1423 {
1424   XMC_ASSERT("XMC_HRPWM_GetRunBitStatus:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1425   return (hrpwm->CSGSTATG & mask);
1426 }
1427 
1428 /**
1429  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1430  * @param mask masked values of selected CSG modules. Use the enum type @ref XMC_HRPWM_CSG_RUN_BIT_t to generate the mask.
1431  * @return None
1432  *
1433  * \par<b>Description </b>
1434  * <br>Start the prescaler & slope generation of DAC<br>\n
1435  *
1436  * Start the prescaler & slope generation of DAC by setting CSGFCG.S0STR and CSGFCG.PS0STR bits.
1437  * The mask is generated by bitwise ORing multiple Enums.<br>
1438  * mask = (uint32_t) (XMC_HRPWM_CSG_SLOPE_START_DAC0 | XMC_HRPWM_CSG_PRESCALER_START_CSG0);
1439  *
1440  * \par<b>Related APIs: </b><br>
1441  * XMC_HRPWM_StopSlopeGeneration()<br>
1442  * XMC_HRPWM_IsSlopeGenerationRunning()<br>
1443  */
1444 
XMC_HRPWM_StartSlopeGeneration(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1445 __STATIC_INLINE void XMC_HRPWM_StartSlopeGeneration(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1446 {
1447   XMC_ASSERT("XMC_HRPWM_StartSlopeGeneration:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1448   hrpwm->CSGFCG = mask;
1449 }
1450 
1451 /**
1452  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1453  * @param mask masked values of selected CSG modules. Use the enum type @ref XMC_HRPWM_CSG_RUN_BIT_t to generate the mask.
1454  * @return None
1455  *
1456  * \par<b>Description </b>
1457  * <br>Stops the prescaler & slope generation of DAC<br>\n
1458  *
1459  * Stops the prescaler & slope generation of DAC by setting CSGFCG.S0STP and CSGFCG.PS0STP bits.
1460  * The mask is generated by bitwise ORing multiple Enums.<br>
1461  * mask = (uint32_t) (XMC_HRPWM_CSG_SLOPE_START_DAC0 | XMC_HRPWM_CSG_PRESCALER_START_CSG0);
1462  *
1463  * \par<b>Related APIs: </b><br>
1464  * XMC_HRPWM_StartSlopeGeneration()<br>
1465  * XMC_HRPWM_IsSlopeGenerationRunning()<br>
1466  */
XMC_HRPWM_StopSlopeGeneration(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1467 __STATIC_INLINE void XMC_HRPWM_StopSlopeGeneration(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1468 {
1469   XMC_ASSERT("XMC_HRPWM_StopSlopeGeneration:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1470   hrpwm->CSGFCG = mask;
1471 }
1472 
1473 /**
1474  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1475  * @param mask masked values of selected CSG modules. Use the enum type @ref XMC_HRPWM_CSG_RUN_BIT_t to generate the mask.
1476  * @return bool
1477  *
1478  * \par<b>Description </b>
1479  * <br>Checks if Prescaler & slope generation is running<br>\n
1480  *
1481  * Checks if Prescaler & slope generation is running by checking CSGFSG.S0RB CSGFSG.P0RB bits.
1482  * The mask is generated by bitwise ORing multiple Enums.<br>
1483  * mask = (uint32_t) (XMC_HRPWM_CSG_SLOPE_START_DAC0 | XMC_HRPWM_CSG_PRESCALER_START_CSG0);
1484  *
1485  * \par<b>Related APIs: </b><br>
1486  * XMC_HRPWM_StartSlopeGeneration()<br>
1487  * XMC_HRPWM_StopSlopeGeneration()<br>
1488  */
XMC_HRPWM_IsSlopeGenerationRunning(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1489 __STATIC_INLINE bool XMC_HRPWM_IsSlopeGenerationRunning(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1490 {
1491   bool status;
1492 
1493   XMC_ASSERT("XMC_HRPWM_IsSlopeGenerationRunning:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1494 
1495   if (hrpwm->CSGFSG & mask)
1496   {
1497     status = true;
1498   }
1499   else
1500   {
1501     status = false;
1502   }
1503 
1504   return (status);
1505 }
1506 
1507 /**
1508  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1509  * @param mask masked values of selected HRC modules. Use the enum type @ref XMC_HRPWM_SHADOW_TX_DAC_t to generate the mask.
1510  * @return None
1511  *
1512  * \par<b>Description </b>
1513  * <br>Enables the shadow transfer of DSV1 and pulse swallow registers of DACs selected by mask<br>\n
1514  *
1515  * Enables the shadow transfer of DSV1 and pulse swallow registers of DACs selected by mask by setting CSGTRG.D0SES bit.
1516  * The transfer is done at the next shadow transfer trigger.
1517  *
1518  * \par<b>Related APIs: </b><br>
1519  * XMC_HRPWM_DisableComparatorShadowTransfer()<br>
1520  * XMC_HRPWM_GetComparatorShadowTransferStatus()<br>
1521  */
XMC_HRPWM_EnableComparatorShadowTransfer(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1522 __STATIC_INLINE void XMC_HRPWM_EnableComparatorShadowTransfer(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1523 {
1524   XMC_ASSERT("XMC_HRPWM_EnableComparatorShadowTransfer:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1525   hrpwm->CSGTRG = mask;
1526 }
1527 
1528 /**
1529  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1530  * @param mask masked values of selected CSG modules. Use the enum type @ref XMC_HRPWM_SHADOW_TX_DAC_t to generate the mask.
1531  * @return None
1532  *
1533  * \par<b>Description </b>
1534  * <br>Cancels the shadow transfer of DSV1 and pulse swallow registers<br>\n
1535  *
1536  * Cancels the shadow transfer of DSV1 and pulse swallow registers by setting CSGTRC.D0SEC bit.
1537  * The transfer request is canceled. Needs to be called before the next shadow transfer trigger.
1538  *
1539  * \par<b>Related APIs: </b><br>
1540  * XMC_HRPWM_EnableComparatorShadowTransfer()<br>
1541  * XMC_HRPWM_GetComparatorShadowTransferStatus()<br>
1542  */
1543 
XMC_HRPWM_DisableComparatorShadowTransfer(XMC_HRPWM_t * const hrpwm,uint32_t mask)1544 __STATIC_INLINE void XMC_HRPWM_DisableComparatorShadowTransfer(XMC_HRPWM_t *const hrpwm, uint32_t mask)
1545 {
1546   XMC_ASSERT("XMC_HRPWM_DisableComparatorShadowTransfer:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1547   hrpwm->CSGTRC = mask;
1548 }
1549 
1550 /**
1551  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1552  * @return uint32_t
1553  *
1554  * \par<b>Description </b>
1555  * <br>Gets the shadow transfer status of DSV1 and pulse swallow registers of all the DACs<br>\n
1556  *
1557  * Gets the shadow transfer status of DSV1 and pulse swallow registers of all the DACs by checking the register CSGTRSG
1558  * The return value is not zero if shadow transfer has been requested, but is still pending completion.
1559  *
1560  * \par<b>Related APIs: </b><br>
1561  * XMC_HRPWM_EnableComparatorShadowTransfer()<br>
1562  * XMC_HRPWM_DisableComparatorShadowTransfer()<br>
1563  */
XMC_HRPWM_GetComparatorShadowTransferStatus(XMC_HRPWM_t * const hrpwm)1564 __STATIC_INLINE uint32_t XMC_HRPWM_GetComparatorShadowTransferStatus(XMC_HRPWM_t *const hrpwm)
1565 {
1566   XMC_ASSERT("XMC_HRPWM_GetComparatorShadowTransferStatus:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1567   return(hrpwm->CSGTRSG & XMC_HRPWM_COMPARATOR_STATUS);
1568 }
1569 
1570 /**
1571  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1572  * @param mask masked values of selected CSG modules. Use the enum type @ref XMC_HRPWM_CSG_PRESCALER_STATUS_t to generate the mask.
1573  * @return None
1574  *
1575  * \par<b>Description </b>
1576  * <br>Clears the prescaler registers of DACs selected by mask<br>\n
1577  *
1578  * Clears the prescaler registers of DACs selected by mask, by setting CSGFCG.PS0CLR bit.
1579  *
1580  * \par<b>Related APIs: </b><br>
1581  * XMC_HRPWM_IsPrescalerRunning()<br>
1582  */
XMC_HRPWM_ClearPreScaler(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1583 __STATIC_INLINE void XMC_HRPWM_ClearPreScaler(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1584 {
1585   XMC_ASSERT("XMC_HRPWM_ClearPreScaler:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1586   hrpwm->CSGFCG |= mask;
1587 }
1588 
1589 /**
1590  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1591  * @param mask masked values of selected CSG modules. Use the enum type @ref XMC_HRPWM_CSG_PRESCALER_STATUS_t to generate the mask.
1592  * @return uint32_t
1593  *
1594  * \par<b>Description </b>
1595  * <br>Checks the prescaler status of DACs selected by mask<br>\n
1596  *
1597  * Checks the prescaler status of DACs selected by mask, by checking  CSGFCG.P0RB bit.
1598  * Returns the bit encoded status information of prescaler.
1599  *
1600  * \par<b>Related APIs: </b><br>
1601  * XMC_HRPWM_ClearPreScaler()<br>
1602  * XMC_HRPWM_StartSlopeGeneration()<br>
1603  */
XMC_HRPWM_IsPrescalerRunning(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1604 __STATIC_INLINE uint32_t XMC_HRPWM_IsPrescalerRunning(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1605 {
1606   XMC_ASSERT("XMC_HRPWM_IsPrescalerRunning:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1607   return (hrpwm->CSGFSG & mask);
1608 }
1609 
1610 /**
1611  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1612  * @param mask masked values of selected CSG modules. Use the enum type @ref XMC_HRPWM_CSG_SWITCH_CMP_INPUT_t to generate the mask.
1613  * @return uint32_t
1614  *
1615  * \par<b>Description </b>
1616  * <br>Returns the bit encoded status of HW pin connected to comparator inverting pin<br>\n
1617  *
1618  * Returns the bit encoded status of HW pin connected to comparator inverting pin by checking CSGTRSG.SW0ST bit.
1619  * The bit position is set to 1 if CINB is connected, else its CINA.
1620  *
1621  * \par<b>Related APIs: </b><br>
1622  * XMC_HRPWM_CSG_SetCMPInput()<br>
1623  */
1624 
XMC_HRPWM_GetCMPInput(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1625 __STATIC_INLINE uint32_t XMC_HRPWM_GetCMPInput(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1626 {
1627   XMC_ASSERT("XMC_HRPWM_GetCMPInput:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1628   return (hrpwm->CSGTRSG & mask);
1629 }
1630 
1631 /**
1632  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1633  * @param slice Slice NO.
1634  * @param power_mode The mode to be put in.
1635  * @return None
1636  *
1637  * \par<b>Description </b>
1638  * <br>Sets the DAC in OFF, Low speed or High speed mode<br>\n
1639  *
1640  * Sets the DAC in OFF, Low speed or High speed mode, by setting CSGCFG.C0PM bits.
1641  *
1642  * \par<b>Related APIs: </b><br>
1643  *
1644  */
XMC_HRPWM_SetCsgPowerMode(XMC_HRPWM_t * const hrpwm,const XMC_HRPWM_CSG_SLICE_t slice,const XMC_HRPWM_CSG_POWER_MODE_t power_mode)1645 __STATIC_INLINE void XMC_HRPWM_SetCsgPowerMode(XMC_HRPWM_t *const hrpwm,
1646                                                 const XMC_HRPWM_CSG_SLICE_t slice,
1647                                                 const XMC_HRPWM_CSG_POWER_MODE_t power_mode)
1648 {
1649   XMC_ASSERT("XMC_HRPWM_SetCsgPowerMode:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1650 
1651   hrpwm->CSGCFG &= ~(3U << (slice * 2U));
1652   hrpwm->CSGCFG |= power_mode << (slice * 2U);
1653 }
1654 
1655 /**
1656  * @param hrpwm Constant pointer to XMC_HRPWM_t, pointing to the HRPWM module base address
1657  * @param mask masked values of selected CSG modules. Use the enum type @ref XMC_HRPWM_CSG_CLK_t to generate the mask.
1658  * @return None
1659  *
1660  * \par<b>Description </b>
1661  * <br>Disables the clock of selected CSG subunits<br>\n
1662  *
1663  * Disables the clock of selected CSG subunits by setting the CSGCFG.C0CD bit.
1664  *
1665  * \par<b>Related APIs: </b><br>
1666  *
1667  */
1668 
XMC_HRPWM_DisableCsgClock(XMC_HRPWM_t * const hrpwm,const uint32_t mask)1669 __STATIC_INLINE void XMC_HRPWM_DisableCsgClock(XMC_HRPWM_t *const hrpwm, const uint32_t mask)
1670 {
1671   XMC_ASSERT("XMC_HRPWM_DisableCsgClock:Invalid module pointer", XMC_HRPWM_CHECK_MODULE_PTR(hrpwm));
1672   hrpwm->CSGCFG |= mask;
1673 }
1674 
1675 /***********************************************************************************************************************
1676  * API PROTOTYPES - HRPWM HRC CHANNEL
1677  **********************************************************************************************************************/
1678 /**
1679  * @param hrc Constant pointer to XMC_HRPWM_HRC_t, pointing to the HRC channel base address
1680  * @param config Pointer to configuration structure.
1681  * @return None
1682  *
1683  * \par<b>Description </b>
1684  * <br>Initializes the HRC channel.<br>\n
1685  *
1686  * Initializes the HRC channel functionality.<br>
1687  * These include:<br>
1688  * 1) Dead time configuration.<br>
1689  * 3) Trap Configuration.<br>
1690  * 4) Shadow transfer configuration.<br>
1691  * 5) Output inversion configuration.<br>
1692  * 6) Passive levels of HRC outputs.<br>
1693  */
1694 
1695 void XMC_HRPWM_HRC_Init(XMC_HRPWM_HRC_t *const hrc, const XMC_HRPWM_HRC_CONFIG_t *const config);
1696 
1697 /**
1698  * @param hrc Constant pointer to XMC_HRPWM_HRC_t, pointing to the HRC channel base address
1699  * @param config Pointer to configuration structure.
1700  * @return None
1701  *
1702  * \par<b>Description </b>
1703  * <br>Initializes the source 0 of HRC channel.<br>\n
1704  *
1705  * Initialize the source 0 functionality of HRC channel.<br>
1706  * This include:<br>
1707  * 1) general configuration for source 0 HRC channel.<br>
1708  * 2) Configuration of which inputs are being used to generate the set and clear for the latch and therefore controlling
1709  *    the generation of the output PWM signal.<br>
1710  * 3) Configuration for which timer from the Capture/Compare Unit is used for the Source Selector 0 and Source Selector 1.<br>
1711  *
1712  * \par<b>Related APIs: </b><br>
1713  * XMC_HRPWM_HRC_ConfigSourceSelect1()<br>
1714  */
1715 
1716 
1717 void XMC_HRPWM_HRC_ConfigSourceSelect0(XMC_HRPWM_HRC_t *const hrc, const XMC_HRPWM_HRC_SRC_CONFIG_t *const config);
1718 
1719 /**
1720  * @param hrc Constant pointer to XMC_HRPWM_HRC_t, pointing to the HRC channel base address
1721  * @param config Pointer to configuration structure.
1722  * @return None
1723  *
1724  * \par<b>Description </b>
1725  * <br>Initializes the source 1 of HRC channel.<br>\n
1726  *
1727  * Initialize the source 1 functionality of HRC channel.<br>\n
1728  * This include:<br>
1729  * 1) general configuration for source 1 HRC channel.<br>
1730  * 2) Configuration of which inputs are being used to generate the set and clear for the latch and therefore controlling
1731  *    the generation of the output PWM signal.<br>
1732  * 3) Configuration for which timer from the Capture/Compare Unit is used for the Source Selector 0 and Source Selector 1.<br>
1733  *
1734  * \par<b>Related APIs: </b><br>
1735  * XMC_HRPWM_HRC_ConfigSourceSelect0()<br>
1736  */
1737 
1738 void XMC_HRPWM_HRC_ConfigSourceSelect1(XMC_HRPWM_HRC_t *const hrc, const XMC_HRPWM_HRC_SRC_CONFIG_t *const config);
1739 
1740 /**
1741  * @param hrc Constant pointer to XMC_HRPWM_HRC_t, pointing to the HRC channel base address
1742  * @param cr1_value high resolution positioning value.
1743  * @return None
1744  *
1745  * \par<b>Description </b>
1746  * <br>Sets the shadow transfer register of high resolution positioning for rising edge<br>\n
1747  *
1748  * Call the shadow transfer update API for transfer to CR1 register.
1749  * A shadow transfer request in corresponding CCU8 slice may also be required.
1750  *
1751  * \par<b>Related APIs: </b><br>
1752  * XMC_HRPWM_EnableHighResolutionShadowTransfer()<br>
1753  * XMC_HRPWM_HRC_SetCompare2()<br>
1754  */
XMC_HRPWM_HRC_SetCompare1(XMC_HRPWM_HRC_t * const hrc,const uint8_t cr1_value)1755 __STATIC_INLINE void XMC_HRPWM_HRC_SetCompare1(XMC_HRPWM_HRC_t *const hrc, const uint8_t cr1_value)
1756 {
1757   XMC_ASSERT("XMC_HRPWM_HRC_SetCompare1:Invalid HRC pointer", XMC_HRPWM_CHECK_HRC_PTR(hrc));
1758   hrc->SCR1 = (uint32_t) cr1_value;
1759 }
1760 
1761 /**
1762  * @param hrc Constant pointer to XMC_HRPWM_HRC_t, pointing to the HRC channel base address
1763  * @param cr2_value high resolution positioning value.
1764  * @return None
1765  *
1766  * \par<b>Description </b>
1767  * <br>Sets the shadow transfer register of high resolution positioning for falling edge<br>\n
1768  *
1769  * Call the shadow transfer update API for transfer to CR2 register.
1770  * A shadow transfer request in corresponding CCU8 slice may also be required.
1771  *
1772  * \par<b>Related APIs: </b><br>
1773  * XMC_HRPWM_EnableHighResolutionShadowTransfer()<br>
1774  * XMC_HRPWM_HRC_SetCompare1()<br>
1775  */
XMC_HRPWM_HRC_SetCompare2(XMC_HRPWM_HRC_t * const hrc,const uint8_t cr2_value)1776 __STATIC_INLINE void XMC_HRPWM_HRC_SetCompare2(XMC_HRPWM_HRC_t *const hrc, const uint8_t cr2_value)
1777 {
1778   XMC_ASSERT("XMC_HRPWM_HRC_SetCompare2:Invalid HRC pointer", XMC_HRPWM_CHECK_HRC_PTR(hrc));
1779   hrc->SCR2 = (uint32_t) cr2_value;
1780 }
1781 
1782 /**
1783  * @param hrc Constant pointer to XMC_HRPWM_HRC_t, pointing to the HRC channel base address
1784  * @param dcr_value Rising edge dead time value.
1785  * @return None
1786  *
1787  * \par<b>Description </b>
1788  * <br>Sets the shadow transfer register of rising edge dead time.<br>\n
1789  *
1790  * Call the shadow transfer update API for transfer to DCR register.
1791  * A shadow transfer request in corresponding CCU8 slice may also be required.
1792  *
1793  * \par<b>Related APIs: </b><br>
1794  * XMC_HRPWM_EnableHighResolutionShadowTransfer()<br>
1795  * XMC_HRPWM_HRC_SetDeadTimeFalling()<br>
1796  */
1797 
XMC_HRPWM_HRC_SetDeadTimeRising(XMC_HRPWM_HRC_t * const hrc,uint16_t dcr_value)1798 __STATIC_INLINE void XMC_HRPWM_HRC_SetDeadTimeRising(XMC_HRPWM_HRC_t *const hrc, uint16_t dcr_value)
1799 {
1800   XMC_ASSERT("XMC_HRPWM_HRC_SetDeadTimeRising:Invalid HRC pointer", XMC_HRPWM_CHECK_HRC_PTR(hrc));
1801   hrc->SDCR = (uint32_t) dcr_value;
1802 }
1803 
1804 /**
1805  * @param hrc Constant pointer to XMC_HRPWM_HRC_t, pointing to the HRC channel base address
1806  * @param dcf_value Falling edge dead time value.
1807  * @return None
1808  *
1809  * \par<b>Description </b>
1810  * <br>Sets the shadow transfer register of falling edge dead time.<br>\n
1811  *
1812  * Call the shadow transfer update API for transfer to DCR register.
1813  * A shadow transfer request in corresponding CCU8 slice may also be required.
1814  *
1815  * \par<b>Related APIs: </b><br>
1816  * XMC_HRPWM_EnableHighResolutionShadowTransfer()<br>
1817  * XMC_HRPWM_HRC_SetDeadTimeRising()<br>
1818  */
XMC_HRPWM_HRC_SetDeadTimeFalling(XMC_HRPWM_HRC_t * const hrc,uint16_t dcf_value)1819 __STATIC_INLINE void XMC_HRPWM_HRC_SetDeadTimeFalling(XMC_HRPWM_HRC_t *const hrc, uint16_t dcf_value)
1820 {
1821   XMC_ASSERT("XMC_HRPWM_HRC_SetDeadTimeFalling:Invalid HRC pointer", XMC_HRPWM_CHECK_HRC_PTR(hrc));
1822   hrc->SDCF = (uint32_t) dcf_value;
1823 }
1824 
1825 /**
1826  * @param hrc Constant pointer to XMC_HRPWM_HRC_t, pointing to the HRC channel base address
1827  * @param source Source connected to high resolution channel.
1828  * @return None
1829  *
1830  * \par<b>Description </b>
1831  * <br>Sets the source to high resolution channel<br>\n
1832  *
1833  * Sets the shadow transfer register deciding the source connected to high resolution channel.
1834  * This also affects the CCU8 timer used for linking shadow transfer trigger.
1835  * Call the shadow transfer update API.
1836  * A shadow transfer request in corresponding CCU8 slice may also be required.
1837  *
1838  * \par<b>Related APIs: </b><br>
1839  * XMC_HRPWM_EnableHighResolutionShadowTransfer()<br>
1840  */
1841 
XMC_HRPWM_HRC_Set_HR_Source(XMC_HRPWM_HRC_t * const hrc,XMC_HRPWM_HRC_SOURCE_t source)1842 __STATIC_INLINE void XMC_HRPWM_HRC_Set_HR_Source(XMC_HRPWM_HRC_t *const hrc, XMC_HRPWM_HRC_SOURCE_t source)
1843 {
1844   XMC_ASSERT("XMC_HRPWM_HRC_Set_HR_Source:Invalid HRC pointer", XMC_HRPWM_CHECK_HRC_PTR(hrc));
1845   hrc->SSC = (uint32_t) source;
1846 }
1847 
1848 /***********************************************************************************************************************
1849  * API PROTOTYPES - HRPWM CSG SLICE
1850  **********************************************************************************************************************/
1851 
1852 /**
1853  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
1854  * @param config Pointer to configuration structure.
1855  * @return None
1856  *
1857  * \par<b>Description </b>
1858  * <br>Initializes the CSG channel.<br>\n
1859  *
1860  * This function is used to initialize the CSG channel.<br>\n
1861  * These include:<br>
1862  * 1) Comparator setup.<br>
1863  * 2) DAC Configuration.<br>
1864  * 3) Slope generation configuration.<br>
1865  */
1866 void XMC_HRPWM_CSG_Init(XMC_HRPWM_CSG_t *const csg, const XMC_HRPWM_CSG_CONFIG_t *const config);
1867 
1868 /**
1869  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
1870  * @param input Input to comparator. Use the enum type @ref XMC_HRPWM_CSG_CMP_INPUT_t to generate the input.
1871  * @return None
1872  *
1873  * \par<b>Description </b>
1874  * <br>Configures the input connection to inverting pin of comparator<br>\n
1875  *
1876  * Selects the HW pin that gets connected to inverting pin of comparator.<br>
1877  * Either CINA or CINB can be set.
1878  * The non-inverting pin is connected to DAC output.
1879  *
1880  * \par<b>Related APIs: </b><br>
1881  * XMC_HRPWM_GetCMPInput()
1882  */
1883 void XMC_HRPWM_CSG_SetCMPInput(XMC_HRPWM_CSG_t *const csg, const XMC_HRPWM_CSG_CMP_INPUT_t input);
1884 
1885 /**
1886  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
1887  * @param config Pointer to configuration structure.
1888  * @return None
1889  *
1890  * \par<b>Description </b>
1891  * <br>Configures the input signal to blank the comparator output<br>\n
1892  *
1893  * Configures the input signal that is used as trigger signal to blank the comparator output.<br>
1894  * It configures the signal source, required edge or level.
1895  * The comparator output is blanked and set to passive level.
1896  *
1897  */
1898 void XMC_HRPWM_CSG_SelBlankingInput(XMC_HRPWM_CSG_t *const csg, const XMC_HRPWM_CSG_INPUT_CONFIG_t *const config);
1899 
1900 /**
1901  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
1902  * @param config Pointer to configuration structure.
1903  * @return None
1904  *
1905  * \par<b>Description </b>
1906  * <br>Configures the input signal to clamp the comparator output<br>\n
1907  *
1908  * Configures the input signal that is used as level signal to clamp the comparator output.<br>
1909  * It configures the signal source and required level.
1910  *
1911  */
1912 void XMC_HRPWM_CSG_SelClampingInput(XMC_HRPWM_CSG_t *const csg, const XMC_HRPWM_CSG_INPUT_CONFIG_t *const config);
1913 
1914 /**
1915  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
1916  * @param config Pointer to configuration structure.
1917  * @return None
1918  *
1919  * \par<b>Description </b>
1920  * <br>Configures the input signal to start the DAC slope generation<br>\n
1921  *
1922  * Configures the input signal that is used as trigger signal to start the slope generation.<br>
1923  * It configures the signal source, required edge or level.
1924  *
1925  * \par<b>Related APIs: </b><br>
1926  * XMC_HRPWM_CSG_StopSlopeGenConfig()<br>
1927  *
1928  */
1929 
1930 void XMC_HRPWM_CSG_StartSlopeGenConfig(XMC_HRPWM_CSG_t *const csg, const XMC_HRPWM_CSG_INPUT_CONFIG_t *const config);
1931 
1932 /**
1933  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
1934  * @param config Pointer to configuration structure.
1935  * @return None
1936  *
1937  * \par<b>Description </b>
1938  * <br>Configures the input signal to stop the DAC slope generation<br>\n
1939  *
1940  * Configures the input that is used as trigger signal to stop the slope generation.<br>
1941  * It configures the signal source, required edge or level.
1942  *
1943  * \par<b>Related APIs: </b><br>
1944  * XMC_HRPWM_CSG_StartSlopeGenConfig()<br>
1945  */
1946 
1947 void XMC_HRPWM_CSG_StopSlopeGenConfig(XMC_HRPWM_CSG_t *const csg, const XMC_HRPWM_CSG_INPUT_CONFIG_t *const config);
1948 
1949 /**
1950  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
1951  * @param config Pointer to configuration structure.
1952  * @return None
1953  *
1954  * \par<b>Description </b>
1955  * <br>Configures the input signal to trigger the DAC conversion<br>\n
1956  *
1957  * Configures the input signal that is used as trigger signal to perform the DAC conversion.<br>
1958  * It configures the signal source, required edge or level.<br>
1959  * This is used when DAC is configured in <b>static mode</b>.
1960  *
1961  */
1962 
1963 void XMC_HRPWM_CSG_TriggerDACConvConfig(XMC_HRPWM_CSG_t *const csg, const XMC_HRPWM_CSG_INPUT_CONFIG_t *const config);
1964 
1965 /**
1966  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
1967  * @param config Pointer to configuration structure.
1968  * @return None
1969  *
1970  * \par<b>Description </b>
1971  * <br>Configure input selection for triggering shadow transfer<br>\n
1972  *
1973  * Configure the signal used to triggering shadow transfer.<br>
1974  * It configures the signal source, required edge or level.
1975  *
1976  */
1977 
1978 void XMC_HRPWM_CSG_TriggerShadowXferConfig(XMC_HRPWM_CSG_t *const csg, const XMC_HRPWM_CSG_INPUT_CONFIG_t *const config);
1979 
1980 /**
1981  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
1982  * @param config Pointer to configuration structure.
1983  * @return None
1984  *
1985  * \par<b>Description </b>
1986  * <br>Configure input selection for switching DAC value between DSV1 and DSV2.<br>\n
1987  *
1988  * Configure the signal used to switch DAC value between DSV1 and DSV2.<br>
1989  * It configures the signal source, required edge or level.
1990  *
1991  */
1992 
1993 
1994 void XMC_HRPWM_CSG_DACRefValSwitchingConfig(XMC_HRPWM_CSG_t *const csg, const XMC_HRPWM_CSG_INPUT_CONFIG_t *const config);
1995 
1996 /**
1997  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
1998  * @param input_clk Clock selection.
1999  * @return None
2000  *
2001  * \par<b>Description </b>
2002  * <br>Select the clock for slope generation<br>\n
2003  *
2004  * Selects the clock source used for slope generation.<br>
2005  * These are : <br>
2006  * module clock      <br>
2007  * external clock A  <br>
2008  * external clock B  <br>
2009  * external clock C  <br>
2010  *
2011  */
2012 
2013 void XMC_HRPWM_CSG_SelSlopeGenClkInput(XMC_HRPWM_CSG_t *const csg, const XMC_HRPWM_CSG_CLK_INPUT_t input_clk);
2014 
2015 /**
2016  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
2017  * @param event Event selected for interrupt.
2018  * @param sr Service request node.
2019  * @return None
2020  *
2021  * \par<b>Description </b>
2022  * <br>Connects the interrupt request to serve node<br>\n
2023  *
2024  * Enables the connection between interrupt request and serve node.<br>
2025  * Each event may be connected to any of four service node available.
2026  * Each event/interrupt needs to be enabled individually.
2027  *
2028  * \par<b>Related APIs: </b><br>
2029  *  XMC_HRPWM_CSG_EnableEvent()<br>
2030  *  XMC_HRPWM_CSG_GetEventStatus()<br>
2031  */
2032 
2033 void XMC_HRPWM_CSG_SetSRNode(XMC_HRPWM_CSG_t *const csg, const XMC_HRPWM_CSG_IRQ_ID_t event,
2034                              const XMC_HRPWM_CSG_IRQ_SR_LINE_t sr);
2035 
2036 /**
2037  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
2038  * @param mask masked values of selected CSG modules. Use the enum type @ref XMC_HRPWM_CSG_IRQ_ID_t to generate the input.
2039  * @return uint32_t
2040  *
2041  * \par<b>Description </b>
2042  * <br>Returns the bit encoded status of selected events<br>\n
2043  *
2044  * Checks the status of selected events. The return value is non-zero is the status is set.
2045  *
2046  * \par<b>Related APIs: </b><br>
2047  *  XMC_HRPWM_CSG_EnableEvent()<br>
2048  *  XMC_HRPWM_CSG_SetSRNode()<br>
2049  *
2050  */
XMC_HRPWM_CSG_GetEventStatus(XMC_HRPWM_CSG_t * const csg,const uint32_t mask)2051 __STATIC_INLINE uint32_t XMC_HRPWM_CSG_GetEventStatus(XMC_HRPWM_CSG_t *const csg, const uint32_t mask)
2052 {
2053   XMC_ASSERT("XMC_HRPWM_CSG_GetEventStatus:Invalid CSG pointer", XMC_HRPWM_CHECK_CSG_PTR(csg));
2054   return (csg->ISTAT & mask);
2055 }
2056 
2057 /**
2058  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
2059  * @param value Value to be written to DSV2 register.
2060  * @return None
2061  *
2062  * \par<b>Description </b>
2063  * <br>Updates the DSV2 register<br>\n
2064  *
2065  * Updates the DSV2 register.<br>
2066  * Note DSV2 register does not have shadow register.
2067  *
2068  * \par<b>Related APIs: </b><br>
2069  * XMC_HRPWM_CSG_UpdateDACRefDSV1()<br>
2070  */
XMC_HRPWM_CSG_UpdateDACRefDSV2(XMC_HRPWM_CSG_t * const csg,uint32_t value)2071 __STATIC_INLINE void XMC_HRPWM_CSG_UpdateDACRefDSV2(XMC_HRPWM_CSG_t *const csg, uint32_t value)
2072 {
2073   XMC_ASSERT("XMC_HRPWM_CSG_UpdateDACRefDSV2:Invalid CSG pointer", XMC_HRPWM_CHECK_CSG_PTR(csg));
2074   csg->DSV2 = value & HRPWM0_CSG_DSV2_DSV2_Msk;
2075 }
2076 
2077 /**
2078  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
2079  * @param value Value to be written to blanking register.
2080  * @return None
2081  *
2082  * \par<b>Description </b>
2083  * <br>Updates the BLV register<br>\n
2084  *
2085  * Updates the blanking register.<br>
2086  * Note BLV register does not have shadow register.
2087  *
2088  */
XMC_HRPWM_CSG_UpdateBlankingValue(XMC_HRPWM_CSG_t * const csg,uint8_t value)2089 __STATIC_INLINE void XMC_HRPWM_CSG_UpdateBlankingValue(XMC_HRPWM_CSG_t *const csg, uint8_t value)
2090 {
2091   XMC_ASSERT("XMC_HRPWM_CSG_UpdateBlankingValue:Invalid CSG pointer", XMC_HRPWM_CHECK_CSG_PTR(csg));
2092   csg->BLV = (uint32_t) value;
2093 }
2094 
2095 /**
2096  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
2097  * @param window Size of filter window.
2098  * @return None
2099  *
2100  * \par<b>Description </b>
2101  * <br>Updates the filter window size<br>\n
2102  *
2103  * Updates the filter window size used for pulse swallowing, in slope generation.<br>
2104  * This value is used in slope generation when filter window is enabled.
2105  * A certain no of clock pulses in the filter window are swallowed and applied to slope generation.
2106  * The pulse swallowed are determined by "Pulse swallow value"
2107  *
2108  * \par<b>Related APIs: </b><br>
2109  * XMC_HRPWM_CSG_UpdatePulseClk()<br>
2110  */
2111 
XMC_HRPWM_CSG_UpdateFilterWindow(XMC_HRPWM_CSG_t * const csg,XMC_HRPWM_CSG_CMP_FILTER_WINDOW_t window)2112 __STATIC_INLINE void XMC_HRPWM_CSG_UpdateFilterWindow(XMC_HRPWM_CSG_t *const csg, XMC_HRPWM_CSG_CMP_FILTER_WINDOW_t window)
2113 {
2114   XMC_ASSERT("XMC_HRPWM_CSG_UpdateFilterWindow:Invalid CSG pointer", XMC_HRPWM_CHECK_CSG_PTR(csg));
2115   csg->CC &= ~(HRPWM0_CSG_CC_COFM_Msk);
2116   csg->CC |= (uint32_t) window << HRPWM0_CSG_CC_COFM_Pos;
2117 }
2118 
2119 /**
2120  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
2121  * @param value No of clock pulses to be swallowed in the filter window.
2122  * @return None
2123  *
2124  * \par<b>Description </b>
2125  * <br>Updates the no of clock pulses to be swallowed in the filter window<br>\n
2126  *
2127  * Update the pulse swallow value.<br>
2128  * This value is used in slope generation when filter window is enabled for slope generation.
2129  * No of clock pulse swallow is determined by this value.
2130  *
2131  * \par<b>Related APIs: </b><br>
2132  * XMC_HRPWM_CSG_UpdateFilterWindow()<br>
2133  */
2134 
XMC_HRPWM_CSG_UpdatePulseClk(XMC_HRPWM_CSG_t * const csg,uint32_t value)2135 __STATIC_INLINE void XMC_HRPWM_CSG_UpdatePulseClk(XMC_HRPWM_CSG_t *const csg, uint32_t value)
2136 {
2137   XMC_ASSERT("XMC_HRPWM_CSG_UpdatePulseClk:Invalid CSG pointer", XMC_HRPWM_CHECK_CSG_PTR(csg));
2138   csg->SPC = value & HRPWM0_CSG_SPC_SPSWV_Msk;
2139 }
2140 
2141 /**
2142  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
2143  * @param value Value to be written to DSV1 shadow register.
2144  * @return None
2145  *
2146  * \par<b>Description </b>
2147  * <br>Updates the DSV1 shadow register<br>\n
2148  *
2149  * Update the DSV1 shadow register.<br>
2150  * Call the shadow transfer update API.
2151  * A shadow transfer request in corresponding CCU8 slice may also be required.
2152  *
2153  * \par<b>Related APIs: </b><br>
2154  * XMC_HRPWM_EnableHighResolutionShadowTransfer()<br>
2155  * XMC_HRPWM_CSG_UpdateDACRefDSV2()<br>
2156  *
2157  */
XMC_HRPWM_CSG_UpdateDACRefDSV1(XMC_HRPWM_CSG_t * const csg,uint32_t value)2158 __STATIC_INLINE void XMC_HRPWM_CSG_UpdateDACRefDSV1(XMC_HRPWM_CSG_t *const csg, uint32_t value)
2159 {
2160   XMC_ASSERT("XMC_HRPWM_CSG_UpdateDACRefDSV1:Invalid CSG pointer", XMC_HRPWM_CHECK_CSG_PTR(csg));
2161   csg->SDSV1 = value & HRPWM0_CSG_SDSV1_SDSV1_Msk;
2162 }
2163 
2164 /**
2165  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
2166  * @param gain Gain value.
2167  * @return None
2168  *
2169  * \par<b>Description </b>
2170  * <br>Updates the gain value of slope generation<br>\n
2171  *
2172  * Updates the gain value of slope generation by setting SC.GCFG bits.
2173  * The value by which DAC increments/decrements is determined by the step gain.
2174  *
2175  * \par<b>Related APIs: </b><br>
2176  * XMC_HRPWM_CSG_UpdateDACPrescaler()<br>
2177  *
2178  */
XMC_HRPWM_CSG_UpdateDACStepGain(XMC_HRPWM_CSG_t * const csg,XMC_HRPWM_CSG_SLOPE_STEP_GAIN_t gain)2179 __STATIC_INLINE void XMC_HRPWM_CSG_UpdateDACStepGain(XMC_HRPWM_CSG_t *const csg, XMC_HRPWM_CSG_SLOPE_STEP_GAIN_t gain)
2180 {
2181   XMC_ASSERT("XMC_HRPWM_CSG_UpdateDACStepGain:Invalid CSG pointer", XMC_HRPWM_CHECK_CSG_PTR(csg));
2182   csg->SC &= ~(HRPWM0_CSG_SC_GCFG_Msk);
2183   csg->SC |= (uint32_t) gain << HRPWM0_CSG_SC_GCFG_Pos;
2184 }
2185 
2186 /**
2187  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
2188  * @param div_value Prescaler value.
2189  * @return None
2190  *
2191  * \par<b>Description </b>
2192  * <br>Updates the prescaler value of slope generation<br>\n
2193  *
2194  * Updates the prescaler value of slope generation by setting SC.PSV
2195  * The rate of DAC value update is determined by prescaler.
2196  *
2197  * \par<b>Related APIs: </b><br>
2198  * XMC_HRPWM_CSG_UpdateDACStepGain()<br>
2199  *
2200  */
2201 
XMC_HRPWM_CSG_UpdateDACPrescaler(XMC_HRPWM_CSG_t * const csg,XMC_HRPWM_CSG_PRESCALER_DIVISION_t div_value)2202 __STATIC_INLINE void XMC_HRPWM_CSG_UpdateDACPrescaler(XMC_HRPWM_CSG_t *const csg, XMC_HRPWM_CSG_PRESCALER_DIVISION_t div_value)
2203 {
2204   XMC_ASSERT("XMC_HRPWM_CSG_UpdateDACPrescaler:Invalid CSG pointer", XMC_HRPWM_CHECK_CSG_PTR(csg));
2205   csg->SC &= ~(HRPWM0_CSG_SC_PSV_Msk);
2206   csg->SC |= (uint32_t) div_value << HRPWM0_CSG_SC_PSV_Pos;
2207 }
2208 
2209 /**
2210  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
2211  * @param event Event selected for interrupt.
2212  * @return None
2213  *
2214  * \par<b>Description </b>
2215  * <br>Enables the interrupt<br>\n
2216  *
2217  * Enables the selected interrupt request which may be forwarded to service node.
2218  * The enabled event may be connected to any of the four service nodes.
2219  *
2220  * \par<b>Related APIs: </b><br>
2221  *  XMC_HRPWM_CSG_DisableEvent()<br>
2222  *  XMC_HRPWM_CSG_GetEventStatus()<br>
2223  *  XMC_HRPWM_CSG_SetSRNode()<br>
2224  *
2225  */
2226 
XMC_HRPWM_CSG_EnableEvent(XMC_HRPWM_CSG_t * const csg,XMC_HRPWM_CSG_IRQ_ID_t event)2227 __STATIC_INLINE void XMC_HRPWM_CSG_EnableEvent(XMC_HRPWM_CSG_t *const csg, XMC_HRPWM_CSG_IRQ_ID_t event)
2228 {
2229   XMC_ASSERT("XMC_HRPWM_CSG_EnableEvent:Invalid CSG pointer", XMC_HRPWM_CHECK_CSG_PTR(csg));
2230   csg->SRE |= event;
2231 }
2232 
2233 /**
2234  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
2235  * @param event Event selected for interrupt.
2236  * @return None
2237  *
2238  * \par<b>Description </b>
2239  * <br>Disables the interrupt<br>\n
2240  *
2241  * Disables the selected interrupt request which may be forwarded to service node.
2242  *
2243  * \par<b>Related APIs: </b><br>
2244  *  XMC_HRPWM_CSG_EnableEvent()<br>
2245  *  XMC_HRPWM_CSG_GetEventStatus()<br>
2246  *  XMC_HRPWM_CSG_SetSRNode()<br>
2247  *
2248  */
2249 
XMC_HRPWM_CSG_DisableEvent(XMC_HRPWM_CSG_t * const csg,XMC_HRPWM_CSG_IRQ_ID_t event)2250 __STATIC_INLINE void XMC_HRPWM_CSG_DisableEvent(XMC_HRPWM_CSG_t *const csg, XMC_HRPWM_CSG_IRQ_ID_t event)
2251 {
2252   XMC_ASSERT("XMC_HRPWM_CSG_DisableEvent:Invalid CSG pointer", XMC_HRPWM_CHECK_CSG_PTR(csg));
2253   csg->SRE &= ~event;
2254 }
2255 
2256 /**
2257  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
2258  * @param event Event selected for software trigger.
2259  * @return None
2260  *
2261  * \par<b>Description </b>
2262  * <br>Software request for selected event<br>\n
2263  *
2264  * Perform a software request for selected event.This overrides any hardware trigger.
2265  *
2266  * \par<b>Related APIs: </b><br>
2267  *  XMC_HRPWM_CSG_EnableEvent()<br>
2268  *  XMC_HRPWM_CSG_GetEventStatus()<br>
2269  *  XMC_HRPWM_CSG_SetSRNode()<br>
2270  *  XMC_HRPWM_CSG_ClrEventSW()<br>
2271  *
2272  */
2273 
XMC_HRPWM_CSG_SetEventSW(XMC_HRPWM_CSG_t * const csg,XMC_HRPWM_CSG_IRQ_ID_t event)2274 __STATIC_INLINE void XMC_HRPWM_CSG_SetEventSW(XMC_HRPWM_CSG_t *const csg, XMC_HRPWM_CSG_IRQ_ID_t event)
2275 {
2276   XMC_ASSERT("XMC_HRPWM_CSG_SetEventSW:Invalid CSG pointer", XMC_HRPWM_CHECK_CSG_PTR(csg));
2277   csg->SWS = event;
2278 }
2279 
2280 /**
2281  * @param csg Constant pointer to XMC_HRPWM_CSG_t, pointing to the CSG channel base address
2282  * @param event Event selected for software trigger.
2283  * @return None
2284  *
2285  * \par<b>Description </b>
2286  * <br>Cancel software request for selected event<br>\n
2287  *
2288  * Cancel the Event trigger request performed via software.<br>
2289  *
2290  * \par<b>Related APIs: </b><br>
2291  *  XMC_HRPWM_CSG_EnableEvent()<br>
2292  *  XMC_HRPWM_CSG_GetEventStatus()<br>
2293  *  XMC_HRPWM_CSG_SetSRNode()<br>
2294  *  XMC_HRPWM_CSG_SetEventSW()<br>
2295  *
2296  */
XMC_HRPWM_CSG_ClrEventSW(XMC_HRPWM_CSG_t * const csg,XMC_HRPWM_CSG_IRQ_ID_t event)2297 __STATIC_INLINE void XMC_HRPWM_CSG_ClrEventSW(XMC_HRPWM_CSG_t *const csg, XMC_HRPWM_CSG_IRQ_ID_t event)
2298 {
2299   XMC_ASSERT("XMC_HRPWM_CSG_ClrEventSW:Invalid CSG pointer", XMC_HRPWM_CHECK_CSG_PTR(csg));
2300   csg->SWC = event;
2301 }
2302 
2303 /**
2304  * @}
2305  */
2306 
2307 /**
2308  * @}
2309  */
2310 
2311 #endif  /* #if defined(HRPWM0) */
2312 
2313 #ifdef __cplusplus
2314 }
2315 #endif
2316 
2317 #endif /* HRPWM_H */
2318