Lines Matching refs:channel
90 #define MAIN_GRTC_CC_CHANNEL (m_cb.channel_data[0].channel)
151 static bool is_channel_used(uint8_t channel) in is_channel_used() argument
153 return (GRTC_CHANNEL_TO_BITMASK(channel) & used_channels_mask_get()); in is_channel_used()
156 static bool is_channel_allocated(uint8_t channel) in is_channel_allocated() argument
158 return (GRTC_CHANNEL_TO_BITMASK(channel) & allocated_channels_mask_get()); in is_channel_allocated()
161 static void channel_used_mark(uint8_t channel) in channel_used_mark() argument
163 m_cb.used_channels |= GRTC_CHANNEL_TO_BITMASK(channel); in channel_used_mark()
166 static void channel_used_unmark(uint8_t channel) in channel_used_unmark() argument
168 m_cb.used_channels &= ~GRTC_CHANNEL_TO_BITMASK(channel); in channel_used_unmark()
171 static bool is_channel_available(uint8_t channel) in is_channel_available() argument
173 return (GRTC_CHANNEL_TO_BITMASK(channel) & NRFX_GRTC_CONFIG_ALLOWED_CC_CHANNELS_MASK); in is_channel_available()
176 static nrfx_err_t syscounter_check(uint8_t channel) in syscounter_check() argument
178 if (!is_channel_available(channel)) in syscounter_check()
182 if (!is_channel_allocated(channel)) in syscounter_check()
200 static uint8_t get_ch_data_index_for_channel(uint8_t channel) in get_ch_data_index_for_channel() argument
205 for (idx = 0; channel != NRF_CTZ(ch_mask); idx++) in get_ch_data_index_for_channel()
215 uint8_t ch_data_idx = get_ch_data_index_for_channel(p_chan_data->channel); in cc_channel_prepare()
217 nrfy_grtc_sys_counter_compare_event_disable(NRF_GRTC, p_chan_data->channel); in cc_channel_prepare()
221 m_cb.channel_data[ch_data_idx].channel = p_chan_data->channel; in cc_channel_prepare()
222 channel_used_mark(p_chan_data->channel); in cc_channel_prepare()
325 nrfx_err_t nrfx_grtc_channel_free(uint8_t channel) in nrfx_grtc_channel_free() argument
327 NRFX_ASSERT(channel < NRF_GRTC_SYSCOUNTER_CC_COUNT); in nrfx_grtc_channel_free()
330 channel_used_unmark(channel); in nrfx_grtc_channel_free()
331 if (!is_channel_available(channel)) in nrfx_grtc_channel_free()
340 err_code = nrfx_flag32_free(&m_cb.available_channels, channel); in nrfx_grtc_channel_free()
349 NRFX_LOG_INFO("GRTC channel %u freed.", channel); in nrfx_grtc_channel_free()
353 bool nrfx_grtc_is_channel_used(uint8_t channel) in nrfx_grtc_is_channel_used() argument
355 return is_channel_used(channel); in nrfx_grtc_is_channel_used()
397 m_cb.channel_data[i].channel = get_channel_for_ch_data_idx(i); in nrfx_grtc_init()
515 p_chan_data->channel = GRTC_RTCOUNTER_COMPARE_CHANNEL; in nrfx_grtc_rtcounter_cc_absolute_set()
539 NRFX_ASSERT(m_cb.channel_data[0].channel == MAIN_GRTC_CC_CHANNEL); in nrfx_grtc_syscounter_start()
544 err_code = nrfx_flag32_alloc(&init_mask, &m_cb.channel_data[0].channel); in nrfx_grtc_syscounter_start()
556 NRFX_LOG_INFO("GRTC channel %u allocated.", m_cb.channel_data[0].channel); in nrfx_grtc_syscounter_start()
694 nrfx_err_t nrfx_grtc_syscounter_cc_disable(uint8_t channel) in nrfx_grtc_syscounter_cc_disable() argument
697 uint32_t int_mask = NRF_GRTC_CHANNEL_INT_MASK(channel); in nrfx_grtc_syscounter_cc_disable()
698 nrfx_err_t err_code = syscounter_check(channel); in nrfx_grtc_syscounter_cc_disable()
706 if (!is_channel_used(channel)) in nrfx_grtc_syscounter_cc_disable()
714 channel_used_unmark(channel); in nrfx_grtc_syscounter_cc_disable()
716 nrfy_grtc_sys_counter_compare_event_disable(NRF_GRTC, channel); in nrfx_grtc_syscounter_cc_disable()
721 if (nrfy_grtc_sys_counter_compare_event_check(NRF_GRTC, channel)) in nrfx_grtc_syscounter_cc_disable()
723 nrfy_grtc_sys_counter_compare_event_clear(NRF_GRTC, channel); in nrfx_grtc_syscounter_cc_disable()
731 NRFX_LOG_INFO("GRTC SYSCOUNTER compare for channel %u disabled.", (uint32_t)channel); in nrfx_grtc_syscounter_cc_disable()
741 nrfx_err_t err_code = syscounter_check(p_chan_data->channel); in nrfx_grtc_syscounter_cc_absolute_set()
752 nrfy_grtc_sys_counter_compare_event_clear(NRF_GRTC, p_chan_data->channel); in nrfx_grtc_syscounter_cc_absolute_set()
753 nrfy_grtc_sys_counter_cc_set(NRF_GRTC, p_chan_data->channel, val); in nrfx_grtc_syscounter_cc_absolute_set()
758 nrfy_grtc_int_enable(NRF_GRTC, GRTC_CHANNEL_TO_BITMASK(p_chan_data->channel)); in nrfx_grtc_syscounter_cc_absolute_set()
762 (uint32_t)p_chan_data->channel, in nrfx_grtc_syscounter_cc_absolute_set()
763 (uint32_t)nrfy_grtc_sys_counter_cc_get(NRF_GRTC, p_chan_data->channel)); in nrfx_grtc_syscounter_cc_absolute_set()
774 nrfx_err_t err_code = syscounter_check(p_chan_data->channel); in nrfx_grtc_syscounter_cc_relative_set()
785 nrfy_grtc_sys_counter_compare_event_clear(NRF_GRTC, p_chan_data->channel); in nrfx_grtc_syscounter_cc_relative_set()
788 p_chan_data->channel, in nrfx_grtc_syscounter_cc_relative_set()
796 nrfy_grtc_int_enable(NRF_GRTC, GRTC_CHANNEL_TO_BITMASK(p_chan_data->channel)); in nrfx_grtc_syscounter_cc_relative_set()
800 (uint32_t)p_chan_data->channel, in nrfx_grtc_syscounter_cc_relative_set()
805 nrfx_err_t nrfx_grtc_syscounter_cc_int_disable(uint8_t channel) in nrfx_grtc_syscounter_cc_int_disable() argument
808 nrfx_err_t err_code = syscounter_check(channel); in nrfx_grtc_syscounter_cc_int_disable()
816 if (!is_channel_used(channel)) in nrfx_grtc_syscounter_cc_int_disable()
825 nrfy_grtc_int_disable(NRF_GRTC, NRF_GRTC_CHANNEL_INT_MASK(channel)); in nrfx_grtc_syscounter_cc_int_disable()
826 NRFX_LOG_INFO("GRTC SYSCOUNTER compare interrupt for channel %u disabled.", (uint32_t)channel); in nrfx_grtc_syscounter_cc_int_disable()
830 nrfx_err_t nrfx_grtc_syscounter_cc_int_enable(uint8_t channel) in nrfx_grtc_syscounter_cc_int_enable() argument
833 nrfx_err_t err_code = syscounter_check(channel); in nrfx_grtc_syscounter_cc_int_enable()
841 channel_used_mark(channel); in nrfx_grtc_syscounter_cc_int_enable()
842 nrfy_grtc_int_enable(NRF_GRTC, GRTC_CHANNEL_TO_BITMASK(channel)); in nrfx_grtc_syscounter_cc_int_enable()
843 NRFX_LOG_INFO("GRTC SYSCOUNTER compare interrupt for channel %u enabled.", (uint32_t)channel); in nrfx_grtc_syscounter_cc_int_enable()
847 bool nrfx_grtc_syscounter_cc_int_enable_check(uint8_t channel) in nrfx_grtc_syscounter_cc_int_enable_check() argument
850 NRFX_ASSERT(channel < NRF_GRTC_SYSCOUNTER_CC_COUNT); in nrfx_grtc_syscounter_cc_int_enable_check()
851 return nrfy_grtc_int_enable_check(NRF_GRTC, GRTC_CHANNEL_TO_BITMASK(channel)); in nrfx_grtc_syscounter_cc_int_enable_check()
854 nrfx_err_t nrfx_grtc_syscounter_capture(uint8_t channel) in nrfx_grtc_syscounter_capture() argument
857 nrfx_err_t err_code = syscounter_check(channel); in nrfx_grtc_syscounter_capture()
865 channel_used_mark(channel); in nrfx_grtc_syscounter_capture()
866 nrfy_grtc_task_trigger(NRF_GRTC, nrfy_grtc_sys_counter_capture_task_get(channel)); in nrfx_grtc_syscounter_capture()
868 NRFX_LOG_INFO("GRTC SYSCOUNTER capture for channel %u triggered.", (uint32_t)channel); in nrfx_grtc_syscounter_capture()
872 nrfx_err_t nrfx_grtc_syscounter_cc_value_read(uint8_t channel, uint64_t * p_val) in nrfx_grtc_syscounter_cc_value_read() argument
876 nrfx_err_t err_code = syscounter_check(channel); in nrfx_grtc_syscounter_cc_value_read()
884 if (!is_channel_used(channel)) in nrfx_grtc_syscounter_cc_value_read()
893 *p_val = nrfy_grtc_sys_counter_cc_get(NRF_GRTC, channel); in nrfx_grtc_syscounter_cc_value_read()
895 NRFX_LOG_INFO("GRTC SYSCOUNTER capture for channel %u read: %llu.", (uint32_t)channel, *p_val); in nrfx_grtc_syscounter_cc_value_read()
912 uint8_t channel = m_cb.channel_data[i].channel; in grtc_irq_handler() local
914 event = nrfy_grtc_sys_counter_compare_event_get(channel); in grtc_irq_handler()
917 NRFX_LOG_INFO("Event: NRF_GRTC_EVENT_COMPARE_%d.", channel); in grtc_irq_handler()
920 m_cb.channel_data[i].handler((int32_t)channel, in grtc_irq_handler()
921 nrfy_grtc_sys_counter_cc_get(NRF_GRTC, channel), in grtc_irq_handler()