38#define PWM_CLK_DIV_CAL(div) (2 * (div + 1))
39#define PWM_FREQ_MAX_CAL(pwm_clk, dutycycle_acc) \
40 (pwm_clk / (dutycycle_acc * (0 + 1)) / 2)
41#define PWM_FREQ_CAL(pwm_clk, dutycycle_acc, period) \
42 (pwm_clk / (dutycycle_acc * (period + 1)) / 2)
44#define PWM_UP_UPDATE_ENABLE (1UL)
45#define PWM_UP_UPDATE_DISABLE (0UL)
47#define PWM_EN_ENABLE (0x01UL)
48#define PWM_EN_DISABLE (0x00UL)
49#define PWM_EN_ALL_ENABLE (0x01UL)
50#define PWM_EN_ALL_DISABLE (0x00UL)
51#define PWM_EN_SLEEP_EN_ENABLE (0x01UL)
52#define PWM_EN_SLEEP_EN_DISABLE (0x00UL)
54#define PWM_EN_MODE_ACC_65535 (0x02UL)
56#define PWM_COMP_TIME_PWMCOMPTIME_Pos (0x00UL)
57#define PWM_COMP_TIME_PWMCOMPTIME_Msk (0xFFUL)
58#define PWM_COMP_TIME_PWMCOMPTIME_VAL_1CLK (0x00UL)
59#define PWM_COMP_TIME_PWMCOMPTIME_VAL_2CLK (0x01UL)
60#define PWM_COMP_TIME_PWMCOMPTIME_VAL_3CLK (0x02UL)
61#define PWM_COMP_TIME_PWMCOMPTIME_VAL_4CLK (0x03UL)
62#define PWM_COMP_TIME_PWMCOMPTIME_VAL_5CLK (0x04UL)
63#define PWM_COMP_TIME_PWMCOMPTIME_VAL_6CLK (0x05UL)
64#define PWM_COMP_TIME_PWMCOMPTIME_VAL_7CLK (0x06UL)
65#define PWM_COMP_TIME_PWMCOMPTIME_VAL_8CLK (0x07UL)
67#define PWM_BRK_BRK_CLEAR_EXIT (0x01UL)
69#define PWM_BRK_DBC_EN_ENABLE (0x01UL)
70#define PWM_BRK_DBC_EN_DISABLE (0x00UL)
72#define PWM_BRK_DBC_STEP1 (0x01UL)
73#define PWM_BRK_DBC_STEP2 (0x02UL)
74#define PWM_BRK_DBC_STEP3 (0x03UL)
75#define PWM_BRK_DBC_STEP4 (0x04UL)
76#define PWM_BRK_DBC_STEP5 (0x05UL)
77#define PWM_BRK_DBC_STEP6 (0x06UL)
78#define PWM_BRK_DBC_STEP7 (0x07UL)
79#define PWM_BRK_DBC_STEP8 (0x08UL)
80#define PWM_BRK_DBC_STEP9 (0x09UL)
81#define PWM_BRK_DBC_STEP10 (0x0AUL)
83#define PWM_BRK0_INV_ENABLE (0x01UL)
84#define PWM_BRK0_INV_DISABLE (0x00UL)
85#define PWM_BRK1_INV_ENABLE (0x02UL)
86#define PWM_BRK1_INV_DISABLE (0x00UL)
87#define PWM_BRK2_INV_ENABLE (0x04UL)
88#define PWM_BRK2_INV_DISABLE (0x00UL)
90#define PWM_BRK0_MASK_ENABLE (0x01UL)
91#define PWM_BRK0_MASK_DISABLE (0x00UL)
92#define PWM_BRK1_MASK_ENABLE (0x02UL)
93#define PWM_BRK1_MASK_DISABLE (0x00UL)
94#define PWM_BRK2_MASK_ENABLE (0x04UL)
95#define PWM_BRK2_MASK_DISABLE (0x00UL)
97#define PWM_BRK0_ENABLE_ENABLE (0x01UL)
98#define PWM_BRK0_ENABLE_DISABLE (0x00UL)
99#define PWM_BRK1_ENABLE_ENABLE (0x02UL)
100#define PWM_BRK1_ENABLE_DISABLE (0x00UL)
101#define PWM_BRK2_ENABLE_ENABLE (0x04UL)
102#define PWM_BRK2_ENABLE_DISABLE (0x00UL)
104#define PWM_CAPTURE_UPD0_EN_ENABLE (0x01UL)
105#define PWM_CAPTURE_UPD1_EN_ENABLE (0x02UL)
106#define PWM_CAPTURE_UPD2_EN_ENABLE (0x04UL)
108#define PWM_CAPTURE_PSC_1 (0x00UL)
109#define PWM_CAPTURE_PSC_2 (0x01UL)
110#define PWM_CAPTURE_PSC_3 (0x02UL)
112#define PWM_CAPTURE_MODE_RISE (0x00UL)
113#define PWM_CAPTURE_MODE_FALL (0x01UL)
114#define PWM_CAPTURE_MODE_BOTH (0x02UL)
116#define PWM_CAPTURE_DBC_STEP0 (0x00UL)
117#define PWM_CAPTURE_DBC_STEP1 (0x01UL)
118#define PWM_CAPTURE_DBC_STEP2 (0x02UL)
119#define PWM_CAPTURE_DBC_STEP3 (0x03UL)
120#define PWM_CAPTURE_DBC_STEP4 (0x04UL)
121#define PWM_CAPTURE_DBC_STEP5 (0x05UL)
122#define PWM_CAPTURE_DBC_STEP6 (0x06UL)
123#define PWM_CAPTURE_DBC_STEP7 (0x07UL)
124#define PWM_CAPTURE_DBC_STEP8 (0x08UL)
125#define PWM_CAPTURE_DBC_STEP9 (0x09UL)
126#define PWM_CAPTURE_DBC_STEP10 (0x0AUL)
127#define PWM_CAPTURE_DBC_STEP11 (0x0BUL)
128#define PWM_CAPTURE_DBC_STEP12 (0x0CUL)
130#define PWM_CAPTURE_SIG_SEL_PWM_CAPTURE0 (0x00UL)
131#define PWM_CAPTURE_SIG_SEL_PWM_CAPTURE1 (0x01UL)
132#define PWM_CAPTURE_SIG_SEL_PWM_CAPTURE2 (0x02UL)
133#define PWM_CAPTURE_SIG_SEL_PWM_BRK0 (0x03UL)
134#define PWM_CAPTURE_SIG_SEL_PWM_BRK1 (0x04UL)
135#define PWM_CAPTURE_SIG_SEL_PWM_BRK2 (0x05UL)
137#define PWM_CAPTURE_CLK_DIV_VAL_0 (0x00UL)
138#define PWM_CAPTURE_CLK_DIV_VAL_2 (0x01UL)
139#define PWM_CAPTURE_CLK_DIV_VAL_3 (0x02UL)
140#define PWM_CAPTURE_CLK_DIV_VAL_4 (0x03UL)
141#define PWM_CAPTURE_CLK_DIV_VAL_5 (0x04UL)
142#define PWM_CAPTURE_CLK_DIV_VAL_6 (0x05UL)
143#define PWM_CAPTURE_CLK_DIV_VAL_7 (0x06UL)
144#define PWM_CAPTURE_CLK_DIV_VAL_8 (0x07UL)
145#define PWM_CAPTURE_CLK_DIV_VAL_9 (0x08UL)
146#define PWM_CAPTURE_CLK_DIV_VAL_10 (0x09UL)
147#define PWM_CAPTURE_CLK_DIV_VAL_11 (0x0AUL)
148#define PWM_CAPTURE_CLK_DIV_VAL_12 (0x0BUL)
149#define PWM_CAPTURE_CLK_DIV_VAL_13 (0x0CUL)
151#define PWM_CAPTURE_ENABLE (0x01UL)
152#define PWM_CAPTURE_DISABLE (0x00UL)
154#define PWM_CAPTURE_DBC_ENABLE (0x01UL)
155#define PWM_CAPTURE_DBC_DISABLE (0x00UL)
157#define PWM_CAPTURE_COMMON_CNT_ENABLE (0x01UL)
158#define PWM_CAPTURE_COMMON_CNT_DISABLE (0x00UL)
160#define PWM_CAPTURE_UPD_EN_ENABLE (0x01UL)
161#define PWM_CAPTURE_UPD_EN_DISABLE (0x00UL)
163#define PWM_SIGNAL_CAPTURE0_GPIO3 GPIO_3
164#define PWM_SIGNAL_CAPTURE1_GPIO8 GPIO_8
165#define PWM_SIGNAL_CAPTURE2_GPIO9 GPIO_9
166#define PWM_SIGNAL_BRK0_GPIO4 GPIO_4
167#define PWM_SIGNAL_BRK1_GPIO5 GPIO_5
168#define PWM_SIGNAL_BRK2_GPIO6 GPIO_6
174#define PWM_BRK_SYNC_VALID 1
175#define PWM_BRK_SYNC_INVALID 0
177#define PWM_BRK0_HIGH_LEVEL PWM_BRK0_INV_DISABLE
178#define PWM_BRK0_LOW_LEVEL PWM_BRK0_INV_ENABLE
179#define PWM_BRK1_HIGH_LEVEL PWM_BRK1_INV_DISABLE
180#define PWM_BRK1_LOW_LEVEL PWM_BRK1_INV_ENABLE
181#define PWM_BRK2_HIGH_LEVEL PWM_BRK2_INV_DISABLE
182#define PWM_BRK2_LOW_LEVEL PWM_BRK2_INV_ENABLE
184#define PWM_ICSIG_CAPTURE0 PWM_CAPTURE_SIG_SEL_PWM_CAPTURE0
185#define PWM_ICSIG_CAPTURE1 PWM_CAPTURE_SIG_SEL_PWM_CAPTURE1
186#define PWM_ICSIG_CAPTURE2 PWM_CAPTURE_SIG_SEL_PWM_CAPTURE2
188#define PWM_ALL_ENABLE PWM_EN_ALL_ENABLE
189#define PWM_ALL_DISABLE PWM_EN_ALL_DISABLE
191#define PWM_SLEEP_COUNT_DIRECTION_UP (0x01UL)
192#define PWM_SLEEP_COUNT_DIRECTION_DOWN (0x00UL)
194#define PWM_SLEEP_ENABLE PWM_SLEEP_EN_ENABLE
195#define PWM_SLEEP_DISABLE PWM_SLEEP_EN_DISABLE
197#define PWM_EN_SEL_SELF (0x00UL)
198#define PWM_EN_SEL_ALL (0x01UL)
200#define PWM_BRK_MODE_HARDWARE (0x00UL)
201#define PWM_BRK_MODE_SOFTWARE (0x01UL)
203#define PWM_TIMER_MODE_USER_DEFINED (0x01UL)
204#define PWM_TIMER_MODE_FREE_RUNNING (0x00UL)
PWM_ClkSrc_TypeDef SrcClk
uint8_t timer_0to100_pwm_en
PWM_ClkDiv_TypeDef clk_div
PWM_ClkSrc_TypeDef src_clk
uint8_t timer_int_mask_en
uint8_t xc_pwm_brake_signal_valid_get(void)
void xc_pwm_brake_signal_mask_set(uint32_t mask)
void xc_pwm_capture_enable(uint8_t ch)
void xc_pwm_brake_recovery_mode_set(uint32_t mode)
void xc_pwm_stop_all(void)
void xc_pwm_timer_set_dutycycle(uint8_t reg_idx, double dutycycle)
void xc_pwm_capture_debounce_disable(uint8_t ch, uint32_t step)
void xc_pwm_brake_enable(uint8_t reg_idx)
void xc_pwm_timer_set_high_cnt(uint8_t reg_idx, uint16_t high_cnt)
enum pwm_timer_number ePWM_Timer_Num
void xc_pwm_dutycycle_set(uint8_t reg_idx, uint32_t dutycycle_acc, uint32_t dutycycle)
void xc_pwm_brake_disable(uint8_t reg_idx)
void xc_pwm_capture_disable_it(uint8_t ch)
void xc_pwm_stop(uint8_t reg_idx)
void xc_pwm_start_all(void)
void xc_pwm_lowpower_disable(uint8_t reg_idx)
void xc_pwm_timer_init(uint8_t reg_idx, PWM_Timer_InitCfg_t *init_cfg)
void xc_pwm_init(uint8_t reg_idx, PWM_InitCfg_t *pwm_cfg)
void xc_pwm_capture_debounce_enable(uint8_t ch, uint32_t step)
void xc_pwm_timer_set_low_cnt(uint8_t reg_idx, uint16_t high_cnt)
void xc_pwm_lowpower_countdirection_set(uint8_t reg_idx, uint32_t direction)
void xc_pwm_capture_enable_it(uint8_t ch)
void xc_pwm_brake_debounce_set(uint32_t debounce, uint32_t step)
void xc_pwm_brake_signal_trigger_level_set(uint32_t invert)
void xc_pwm_capture_counter_disable(uint8_t ch)
void xc_pwm_timer_start(uint8_t reg_idx)
void xc_pwm_capture_psc_set(uint8_t ch, uint32_t psc)
void xc_pwm_timer_deinit(uint8_t reg_idx)
void xc_pwm_brake_clear(void)
uint8_t pwm_capture_ch1_callback(void *context)
uint8_t(* pwm_handler_callback)(void *context)
uint8_t pwm_capture_ch2_callback(void *context)
void xc_pwm_capture_edge_set(uint8_t ch, uint32_t edge)
uint8_t xc_pwm_brake_recovery_mode_get(void)
void xc_pwm_lowpower_enable(uint8_t reg_idx)
void xc_pwm_start(uint8_t reg_idx)
void xc_pwm_capture_counter_enable(uint8_t ch)
uint8_t pwm_capture_ch0_callback(void *context)
void xc_pwm_capture_signal_set(uint8_t ch, uint32_t signal)
void xc_pwm_timer_set_freq(uint8_t reg_idx, uint32_t freq)
uint16_t xc_pwm_capture_val_get(uint8_t ch)
void xc_pwm_timer_stop(uint8_t reg_idx)
void xc_pwm_capture_disable(uint8_t ch)
void pwm_pin_set(uint8_t reg_idx, PWM_InitCfg_t *pwm_cfg)