Lines Matching refs:epwm

32 	EPWM_T *epwm;  member
68 EPWM_T *epwm = cfg->epwm; in pwm_numaker_configure() local
71 EPWM_ForceStop(epwm, NUMAKER_PWM_CHANNEL_MASK); in pwm_numaker_configure()
74 epwm->POLCTL &= ~(NUMAKER_PWM_CHANNEL_MASK << EPWM_POLCTL_PINV0_Pos); in pwm_numaker_configure()
83 EPWM_T *epwm = cfg->epwm; in pwm_numaker_set_cycles() local
86 LOG_DBG("Channel=0x%x, CAPIEN=0x%x, CAPIF=0x%x", channel, epwm->CAPIEN, in pwm_numaker_set_cycles()
87 epwm->CAPIF); in pwm_numaker_set_cycles()
91 epwm->POLCTL |= BIT(EPWM_POLCTL_PINV0_Pos + channel); in pwm_numaker_set_cycles()
93 epwm->POLCTL &= ~BIT(EPWM_POLCTL_PINV0_Pos + channel); in pwm_numaker_set_cycles()
98 EPWM_Stop(epwm, channel_mask); in pwm_numaker_set_cycles()
99 EPWM_ForceStop(epwm, channel_mask); in pwm_numaker_set_cycles()
100 EPWM_DisableOutput(epwm, channel_mask); in pwm_numaker_set_cycles()
105 EPWM_ConfigOutputChannel(epwm, channel, data->cycles_per_sec / period_cycles, in pwm_numaker_set_cycles()
109 EPWM_EnableOutput(epwm, channel_mask); in pwm_numaker_set_cycles()
112 EPWM_Start(epwm, channel_mask); in pwm_numaker_set_cycles()
116 LOG_DBG("CTL1=0x%x, POEN=0x%x, CNTEN=0x%x", epwm->CTL1, epwm->POEN, epwm->CNTEN); in pwm_numaker_set_cycles()
117 LOG_DBG("Channel=0x%x, CAPIEN=0x%x, CAPIF=0x%x", channel, epwm->CAPIEN, epwm->CAPIF); in pwm_numaker_set_cycles()
193 EPWM_T *epwm = cfg->epwm; in pwm_numaker_enable_capture() local
213 EPWM_ConfigCaptureChannel(epwm, channel, unit_time_nsec, 0); in pwm_numaker_enable_capture()
216 EPWM_EnableCapture(epwm, channel_mask); in pwm_numaker_enable_capture()
219 EPWM_Start(epwm, channel_mask); in pwm_numaker_enable_capture()
221 EPWM_ClearCaptureIntFlag(epwm, channel, in pwm_numaker_enable_capture()
225 EPWM_EnableCaptureInt(epwm, channel, data->capture[pair].curr_edge_mode); in pwm_numaker_enable_capture()
227 LOG_DBG("Channel=0x%x, CAPIEN=0x%x, CAPIF=0x%x", channel, epwm->CAPIEN, in pwm_numaker_enable_capture()
228 epwm->CAPIF); in pwm_numaker_enable_capture()
237 EPWM_T *epwm = cfg->epwm; in pwm_numaker_disable_capture() local
243 EPWM_Stop(epwm, channel_mask); in pwm_numaker_disable_capture()
244 EPWM_ForceStop(epwm, channel_mask); in pwm_numaker_disable_capture()
245 EPWM_DisableCapture(epwm, channel_mask); in pwm_numaker_disable_capture()
246 EPWM_DisableCaptureInt(epwm, channel, in pwm_numaker_disable_capture()
248 EPWM_ClearCaptureIntFlag(epwm, channel, in pwm_numaker_disable_capture()
250 LOG_DBG("CAPIEN = 0x%x\n", epwm->CAPIEN); in pwm_numaker_disable_capture()
258 static int pwm_numaker_get_cap_cycle(EPWM_T *epwm, uint32_t channel, uint32_t curr_edge, in pwm_numaker_get_cap_cycle() argument
272 EPWM_ClearPeriodIntFlag(epwm, channel); in pwm_numaker_get_cap_cycle()
279 EPWM_GET_CAPTURE_RISING_DATA(epwm, channel), in pwm_numaker_get_cap_cycle()
280 EPWM_GET_CAPTURE_FALLING_DATA(epwm, channel), epwm->CNT[channel]); in pwm_numaker_get_cap_cycle()
282 ? EPWM_GET_CAPTURE_FALLING_DATA(epwm, channel) in pwm_numaker_get_cap_cycle()
283 : (uint16_t)EPWM_GET_CAPTURE_RISING_DATA(epwm, channel); in pwm_numaker_get_cap_cycle()
286 while ((epwm->CAPIF & next_if_mask) == 0) { in pwm_numaker_get_cap_cycle()
287 if (EPWM_GetPeriodIntFlag(epwm, channel)) { in pwm_numaker_get_cap_cycle()
288 EPWM_ClearPeriodIntFlag(epwm, channel); in pwm_numaker_get_cap_cycle()
298 EPWM_ClearCaptureIntFlag(epwm, channel, in pwm_numaker_get_cap_cycle()
303 ? (uint16_t)EPWM_GET_CAPTURE_FALLING_DATA(epwm, channel) in pwm_numaker_get_cap_cycle()
304 : (uint16_t)EPWM_GET_CAPTURE_RISING_DATA(epwm, channel); in pwm_numaker_get_cap_cycle()
308 *cycles, period_reloads, epwm->CAPIF, curr_cnt, next_cnt); in pwm_numaker_get_cap_cycle()
314 static void pwm_numaker_channel_cap(const struct device *dev, EPWM_T *epwm, uint32_t channel) in pwm_numaker_channel_cap() argument
321 EPWM_DisableCaptureInt(epwm, channel, EPWM_CAPTURE_INT_RISING_LATCH | in pwm_numaker_channel_cap()
328 epwm, channel, data->capture[channel].curr_edge_mode, in pwm_numaker_channel_cap()
339 EPWM_DisableCaptureInt(epwm, channel, EPWM_CAPTURE_INT_RISING_LATCH | in pwm_numaker_channel_cap()
343 EPWM_ClearCaptureIntFlag(epwm, channel, EPWM_CAPTURE_INT_FALLING_LATCH | in pwm_numaker_channel_cap()
345 EPWM_EnableCaptureInt(epwm, channel, data->capture[channel].curr_edge_mode); in pwm_numaker_channel_cap()
354 EPWM_T *epwm = cfg->epwm; in pwm_numaker_isr() local
366 int_status = epwm->AINTSTS & int_mask; in pwm_numaker_isr()
369 epwm->AINTSTS = int_status; in pwm_numaker_isr()
373 cap_intsts = epwm->CAPIF & cap_int_mask; in pwm_numaker_isr()
379 st_channel, epwm->CAPIEN, epwm->CAPIF, cap_int_mask); in pwm_numaker_isr()
382 epwm->CAPIF = cap_intsts; in pwm_numaker_isr()
393 pwm_numaker_channel_cap(dev, epwm, i); in pwm_numaker_isr()
430 static int pwm_numaker_clk_get_rate(EPWM_T *epwm, uint32_t *rate) in pwm_numaker_clk_get_rate() argument
435 if (epwm == EPWM0) { in pwm_numaker_clk_get_rate()
437 } else if (epwm == EPWM1) { in pwm_numaker_clk_get_rate()
450 if (epwm == EPWM0) { in pwm_numaker_clk_get_rate()
464 EPWM_T *epwm = cfg->epwm; in pwm_numaker_init() local
498 err = pwm_numaker_clk_get_rate(epwm, &clock_freq); in pwm_numaker_init()
562 .epwm = (EPWM_T *)DT_INST_REG_ADDR(inst), \