Lines Matching refs:channel

86 static int pwm_nxp_s32_set_cycles_internal_timebase(uint8_t instance, uint32_t channel,  in pwm_nxp_s32_set_cycles_internal_timebase()  argument
97 if (Emios_Pwm_Ip_GetPeriod(instance, channel) != period_cycles) { in pwm_nxp_s32_set_cycles_internal_timebase()
98 Emios_Pwm_Ip_SetPeriod(instance, channel, period_cycles); in pwm_nxp_s32_set_cycles_internal_timebase()
102 if (Emios_Pwm_Ip_GetDutyCycle(instance, channel) != pulse_cycles) { in pwm_nxp_s32_set_cycles_internal_timebase()
104 if (Emios_Pwm_Ip_SetDutyCycle(instance, channel, pulse_cycles)) { in pwm_nxp_s32_set_cycles_internal_timebase()
112 Emios_Pwm_Ip_ForceMatchTrailingEdge(instance, channel, true); in pwm_nxp_s32_set_cycles_internal_timebase()
120 static int pwm_nxp_s32_set_cycles_external_timebase(uint8_t instance, uint32_t channel, in pwm_nxp_s32_set_cycles_external_timebase() argument
131 if (Emios_Pwm_Ip_GetPeriod(instance, channel) != period_cycles) { in pwm_nxp_s32_set_cycles_external_timebase()
136 master_channel = Emios_Pwm_Ip_GetMasterBusChannel(instance, channel); in pwm_nxp_s32_set_cycles_external_timebase()
144 if (Emios_Pwm_Ip_GetDutyCycle(instance, channel) != pulse_cycles) { in pwm_nxp_s32_set_cycles_external_timebase()
145 if (Emios_Pwm_Ip_SetDutyCycle(instance, channel, pulse_cycles)) { in pwm_nxp_s32_set_cycles_external_timebase()
155 static int pwm_nxp_s32_set_cycles(const struct device *dev, uint32_t channel, in pwm_nxp_s32_set_cycles() argument
165 if (channel >= EMIOS_PWM_IP_CHANNEL_COUNT) { in pwm_nxp_s32_set_cycles()
166 LOG_ERR("invalid channel %d", channel); in pwm_nxp_s32_set_cycles()
170 if (eMios_Pwm_Ip_IndexInChState[config->instance][channel] >= in pwm_nxp_s32_set_cycles()
172 LOG_ERR("Channel %d is not configured for PWM", channel); in pwm_nxp_s32_set_cycles()
176 logic_ch = eMios_Pwm_Ip_IndexInChState[config->instance][channel] - data->start_pwm_ch; in pwm_nxp_s32_set_cycles()
187 return pwm_nxp_s32_set_cycles_internal_timebase(config->instance, channel, in pwm_nxp_s32_set_cycles()
199 return pwm_nxp_s32_set_cycles_external_timebase(config->instance, channel, in pwm_nxp_s32_set_cycles()
206 if ((Emios_Pwm_Ip_GetPhaseShift(config->instance, channel) + in pwm_nxp_s32_set_cycles()
212 return pwm_nxp_s32_set_cycles_external_timebase(config->instance, channel, in pwm_nxp_s32_set_cycles()
257 uint32_t channel, in pwm_nxp_s32_capture_configure() argument
265 if (channel >= EMIOS_ICU_IP_NUM_OF_CHANNELS) { in pwm_nxp_s32_capture_configure()
266 LOG_ERR("Invalid channel %d", channel); in pwm_nxp_s32_capture_configure()
275 if (eMios_Icu_Ip_IndexInChState[config->instance][channel] >= in pwm_nxp_s32_capture_configure()
277 LOG_ERR("Channel %d is not configured for PWM", channel); in pwm_nxp_s32_capture_configure()
282 if (config->base->CH.UC[channel].C & eMIOS_C_FEN_MASK) { in pwm_nxp_s32_capture_configure()
283 LOG_ERR("Channel %d is busy", channel); in pwm_nxp_s32_capture_configure()
287 data->capture[channel].continuous = (flags & PWM_CAPTURE_MODE_MASK); in pwm_nxp_s32_capture_configure()
288 data->capture[channel].inverted = (flags & PWM_POLARITY_MASK); in pwm_nxp_s32_capture_configure()
289 data->capture[channel].pulse_capture = (flags & PWM_CAPTURE_TYPE_PULSE); in pwm_nxp_s32_capture_configure()
290 data->capture[channel].period_capture = (flags & PWM_CAPTURE_TYPE_PERIOD); in pwm_nxp_s32_capture_configure()
291 data->capture[channel].callback = cb; in pwm_nxp_s32_capture_configure()
292 data->capture[channel].user_data = user_data; in pwm_nxp_s32_capture_configure()
297 static int pwm_nxp_s32_capture_enable(const struct device *dev, uint32_t channel) in pwm_nxp_s32_capture_enable() argument
305 if (channel >= EMIOS_ICU_IP_NUM_OF_CHANNELS) { in pwm_nxp_s32_capture_enable()
306 LOG_ERR("Invalid channel %d", channel); in pwm_nxp_s32_capture_enable()
310 if (eMios_Icu_Ip_IndexInChState[config->instance][channel] >= in pwm_nxp_s32_capture_enable()
312 LOG_ERR("Channel %d is not configured for PWM", channel); in pwm_nxp_s32_capture_enable()
316 if (!data->capture[channel].callback) { in pwm_nxp_s32_capture_enable()
322 if (config->base->CH.UC[channel].C & eMIOS_C_FEN_MASK) { in pwm_nxp_s32_capture_enable()
323 LOG_ERR("Channel %d is busy", channel); in pwm_nxp_s32_capture_enable()
328 if (data->capture[channel].period_capture && !data->capture[channel].pulse_capture) { in pwm_nxp_s32_capture_enable()
336 Emios_Icu_Ip_SetActivation(config->instance, channel, edge); in pwm_nxp_s32_capture_enable()
338 Emios_Icu_Ip_EnableNotification(config->instance, channel); in pwm_nxp_s32_capture_enable()
340 Emios_Icu_Ip_StartTimestamp(config->instance, channel, in pwm_nxp_s32_capture_enable()
341 data->capture[channel].edge_buff, in pwm_nxp_s32_capture_enable()
347 static int pwm_nxp_s32_capture_disable(const struct device *dev, uint32_t channel) in pwm_nxp_s32_capture_disable() argument
351 if (channel >= EMIOS_ICU_IP_NUM_OF_CHANNELS) { in pwm_nxp_s32_capture_disable()
352 LOG_ERR("Invalid channel %d", channel); in pwm_nxp_s32_capture_disable()
356 if (eMios_Icu_Ip_IndexInChState[config->instance][channel] >= in pwm_nxp_s32_capture_disable()
358 LOG_ERR("Channel %d is not configured for PWM", channel); in pwm_nxp_s32_capture_disable()
362 Emios_Icu_Ip_StopTimestamp(config->instance, channel); in pwm_nxp_s32_capture_disable()
367 static int pwm_nxp_s32_get_master_bus(const struct device *dev, uint32_t channel) in pwm_nxp_s32_get_master_bus() argument
372 bus_select = (config->base->CH.UC[channel].C & eMIOS_C_BSL_MASK) >> eMIOS_C_BSL_SHIFT; in pwm_nxp_s32_get_master_bus()
379 master_bus = (channel < 8U) ? 0U : ((channel < 16U) ? 8U : 16U); in pwm_nxp_s32_get_master_bus()
386 master_bus = channel; in pwm_nxp_s32_get_master_bus()
395 uint32_t channel, in pwm_nxp_s32_get_cycles_per_sec() argument
405 if (eMios_Pwm_Ip_IndexInChState[config->instance][channel] < in pwm_nxp_s32_get_cycles_per_sec()
407 master_bus = Emios_Pwm_Ip_GetMasterBusChannel(config->instance, channel); in pwm_nxp_s32_get_cycles_per_sec()
412 if (eMios_Icu_Ip_IndexInChState[config->instance][channel] < in pwm_nxp_s32_get_cycles_per_sec()
414 master_bus = pwm_nxp_s32_get_master_bus(dev, channel); in pwm_nxp_s32_get_cycles_per_sec()
419 LOG_ERR("Channel %d is not configured for PWM", channel); in pwm_nxp_s32_get_cycles_per_sec()
483 static void pwm_nxp_s32_capture_callback(const struct device *dev, uint32_t channel) in pwm_nxp_s32_capture_callback() argument
490 if (data->capture[channel].period_capture && !data->capture[channel].pulse_capture) { in pwm_nxp_s32_capture_callback()
491 period = pwm_nxp_s32_capture_calc(data->capture[channel].edge_buff[0], in pwm_nxp_s32_capture_callback()
492 data->capture[channel].edge_buff[1]); in pwm_nxp_s32_capture_callback()
494 if (data->capture[channel].pulse_capture) { in pwm_nxp_s32_capture_callback()
495 pulse = pwm_nxp_s32_pulse_calc(data->capture[channel].inverted, in pwm_nxp_s32_capture_callback()
496 data->capture[channel].edge_buff, in pwm_nxp_s32_capture_callback()
498 channel)); in pwm_nxp_s32_capture_callback()
501 if (data->capture[channel].period_capture) { in pwm_nxp_s32_capture_callback()
502 period = pwm_nxp_s32_capture_calc(data->capture[channel].edge_buff[0], in pwm_nxp_s32_capture_callback()
503 data->capture[channel].edge_buff[2]); in pwm_nxp_s32_capture_callback()
507 if (!data->capture[channel].continuous) { in pwm_nxp_s32_capture_callback()
508 Emios_Icu_Ip_StopTimestamp(config->instance, channel); in pwm_nxp_s32_capture_callback()
511 data->capture[channel].callback(dev, channel, period, pulse, 0, in pwm_nxp_s32_capture_callback()
512 data->capture[channel].user_data); in pwm_nxp_s32_capture_callback()
592 BUILD_ASSERT(BIT(DT_PROP(node_id, channel)) & \
670 BIT(DT_PROP(node_id, channel)) & DT_PROP(DT_GPARENT(node_id), internal_cnt),\
716 .ChannelId = DT_PROP(node_id, channel), \
773 void EMIOS_PWM_CAPTURE_CB(n, DT_PROP(node_id, channel))(void) \
775 pwm_nxp_s32_capture_callback(DEVICE_DT_INST_GET(n), DT_PROP(node_id, channel)); \
781 .hwChannel = DT_PROP(node_id, channel), \
801 .eMiosChannelNotification = EMIOS_PWM_CAPTURE_CB(n, DT_PROP(node_id, channel)), \