PWM_CCU4: PWM_CCU4.h Source File

PWM CCU4

PWM_CCU4.h
Go to the documentation of this file.
1 
67 #ifndef PWM_CCU4_H_
68 #define PWM_CCU4_H_
69 
70 /***********************************************************************************************************************
71  * HEADER FILES
72  **********************************************************************************************************************/
73 #include <xmc_gpio.h>
74 #include "pwm_ccu4_conf.h"
75 
76 #if (!((XMC_LIB_MAJOR_VERSION == 2U) && \
77  (XMC_LIB_MINOR_VERSION >= 0U) && \
78  (XMC_LIB_PATCH_VERSION >= 0U)))
79 #error "PWM_CCU4 requires XMC Peripheral Library v2.0.0 or higher"
80 #endif
81 
82 /**********************************************************************************************************************
83 * MACROS
84 **********************************************************************************************************************/
85 
86 #define PWM_CCU4_MAX_TIMER_COUNT (65535U)
87 
88 #define PWM_CCU4_DUTY_FULL_SCALE (10000U) /*100% * 100*/
89 #define PWM_CCU4_DUTY_SCALE (100U) /*100*/
90 
91 #define PWM_CCU4_SYM_DUTY_MAX (10000U) /*duty Max*/
92 #define PWM_CCU4_SYM_DUTY_MIN (0U) /*duty Min*/
93 
94 /**********************************************************************************************************************
95 * ENUMS
96 **********************************************************************************************************************/
97 
106 typedef enum PWM_CCU4_STATUS
107 {
112 
117 
123 
124 
128 typedef enum PWM_CCU4_STATE
129 {
136 
142 
148 
154 
156 
161 /**********************************************************************************************************************
162 * DATA STRUCTURES
163 **********************************************************************************************************************/
171 typedef struct PWM_CCU4_ConfigType
172 {
173  const bool start_control;
174  const uint16_t period_value;
175  const uint16_t compare_value;
177  const bool int_per_match;
178  const bool int_cmp_match_up;
179  const bool int_cmp_match_down;
180  const bool int_one_match_down;
181  const bool int_e0;
182  const bool int_e1;
183  const bool int_e2;
185  const XMC_CCU4_SLICE_SR_ID_t sr_per_match;
186  const XMC_CCU4_SLICE_SR_ID_t sr_cmp_match_up;
187  const XMC_CCU4_SLICE_SR_ID_t sr_cmp_match_down;
188  const XMC_CCU4_SLICE_SR_ID_t sr_one_match_down;
189  const XMC_CCU4_SLICE_SR_ID_t sr_e0;
190  const XMC_CCU4_SLICE_SR_ID_t sr_e1;
191  const XMC_CCU4_SLICE_SR_ID_t sr_e2;
193  const XMC_CCU4_SLICE_EVENT_CONFIG_t *const event0_config_ptr;
194  const XMC_CCU4_SLICE_EVENT_CONFIG_t *const event1_config_ptr;
195  const XMC_CCU4_SLICE_EVENT_CONFIG_t *const event2_config_ptr;
197  const XMC_CCU4_SLICE_EVENT_t ext_start_event;
198  const XMC_CCU4_SLICE_START_MODE_t ext_start_mode;
200  const XMC_CCU4_SLICE_EVENT_t ext_stop_event;
201  const XMC_CCU4_SLICE_END_MODE_t ext_stop_mode;
203  const XMC_CCU4_SLICE_EVENT_t ext_count_dir_event;
205  const XMC_CCU4_SLICE_EVENT_t ext_gate_event;
207  const XMC_CCU4_SLICE_EVENT_t ext_count_event;
209  const XMC_CCU4_SLICE_EVENT_t ext_load_event;
211  const XMC_CCU4_SLICE_EVENT_t ext_mod_event;
212  const XMC_CCU4_SLICE_MODULATION_MODE_t ext_mod_mode;
213  const bool ext_mod_sync;
215  const XMC_CCU4_SLICE_EVENT_t ext_override_edge_event;
217  const XMC_CCU4_SLICE_EVENT_t ext_override_level_event;
219  const bool ext_trap_enable;
220  const XMC_CCU4_SLICE_EVENT_t ext_trap_event;
221  const bool ext_trap_sync;
222  const XMC_CCU4_SLICE_TRAP_EXIT_MODE_t ext_trap_exit;
224  const XMC_CCU4_MULTI_CHANNEL_SHADOW_TRANSFER_t mcm_shadow_txfr_mode;
226 #if (UC_SERIES == XMC14)/*below feature available in XMC14xx devices */
227  const XMC_CCU4_SLICE_SHADOW_TRANSFER_MODE_t shadow_transfer_mode;
228  const uint32_t immediate_write;
229  const uint32_t automatic_shadow_transfer;
231 #endif
232 
233  const XMC_CCU4_SLICE_COMPARE_CONFIG_t *const ccu4_cc4_slice_timer_ptr;
235  const bool gpio_ch_out_enable;
236  XMC_GPIO_PORT_t *const gpio_ch_out_ptr;
237  const uint8_t gpio_ch_out_pin;
238  const XMC_GPIO_CONFIG_t *const gpio_ch_out_config_ptr;
240  GLOBAL_CCU4_t *const global_ccu4_handle;
243 
247 typedef struct PWM_CCU4_HandleType
248 {
250  XMC_CCU4_MODULE_t *const ccu4_module_ptr;
251  XMC_CCU4_SLICE_t *const ccu4_slice_ptr;
252  const uint8_t kernel_number;
253  const uint8_t slice_number;
254  const uint32_t shadow_txfr_msk;
255  const uint32_t dither_shadow_txfr_msk;
256  const uint32_t prescaler_shadow_txfr_msk;
259  uint32_t frequency_tclk;
260  uint32_t sym_duty;
261 } PWM_CCU4_t;
262 
272 /***********************************************************************************************************************
273  * API Prototypes
274  **********************************************************************************************************************/
275 /* Support for C++ */
276 #ifdef __cplusplus
277 extern "C" {
278 #endif
279 
302 DAVE_APP_VERSION_t PWM_CCU4_GetAppVersion(void);
303 
325 PWM_CCU4_STATUS_t PWM_CCU4_Init(PWM_CCU4_t* const handle_ptr);
326 
352  PWM_CCU4_STATUS_t PWM_CCU4_Start(PWM_CCU4_t* const handle_ptr);
353 
375  PWM_CCU4_STATUS_t PWM_CCU4_Stop(PWM_CCU4_t* const handle_ptr);
376 
398  uint32_t PWM_CCU4_GetTimerValue(PWM_CCU4_t* const handle_ptr);
399 
421  bool PWM_CCU4_GetTimerStatus(PWM_CCU4_t* const handle_ptr);
422 
446  PWM_CCU4_STATUS_t PWM_CCU4_SetFreq(PWM_CCU4_t* const handle_ptr, uint32_t pwm_freq_hz);
447 
473  PWM_CCU4_STATUS_t PWM_CCU4_SetDutyCycle(PWM_CCU4_t* const handle_ptr, uint32_t duty_cycle);
474 
475 
502  PWM_CCU4_STATUS_t PWM_CCU4_SetFreqAndDutyCycle(PWM_CCU4_t* const handle_ptr, uint32_t pwm_freq_hz, uint32_t duty);
503 
530  void PWM_CCU4_SetDither(PWM_CCU4_t* const handle_ptr, bool dither_period, bool dither_comp, uint8_t dither_value);
531 
552  void PWM_CCU4_ClearTrap(PWM_CCU4_t* const handle_ptr);
553 
579  bool PWM_CCU4_GetInterruptStatus(PWM_CCU4_t* const handle_ptr, XMC_CCU4_SLICE_IRQ_ID_t pwm_interrupt);
580 
603  void PWM_CCU4_ClearEvent(PWM_CCU4_t* const handle_ptr, XMC_CCU4_SLICE_IRQ_ID_t pwm_interrupt);
604 
605 
606 #include "pwm_ccu4_extern.h"
607 
611 #ifdef __cplusplus
612 }
613 #endif
614 
615 #endif /* PWM_CCU4_H_ */
616