Lines Matching refs:chan

70 #define IS_CHANNEL_ALLOWED_ASSERT(chan)                                                            \  argument
71 __ASSERT_NO_MSG((NRFX_GRTC_CONFIG_ALLOWED_CC_CHANNELS_MASK & (1UL << (chan))) && \
72 ((chan) != system_clock_channel_data.channel))
86 static inline int get_comparator(uint32_t chan, uint64_t *cc) in get_comparator() argument
90 result = nrfx_grtc_syscounter_cc_value_read(chan, cc); in get_comparator()
123 static bool compare_int_lock(int32_t chan) in compare_int_lock() argument
125 atomic_val_t prev = atomic_and(&int_mask, ~BIT(chan)); in compare_int_lock()
127 nrfx_grtc_syscounter_cc_int_disable(chan); in compare_int_lock()
129 return prev & BIT(chan); in compare_int_lock()
132 static void compare_int_unlock(int32_t chan, bool key) in compare_int_unlock() argument
135 atomic_or(&int_mask, BIT(chan)); in compare_int_unlock()
136 nrfx_grtc_syscounter_cc_int_enable(chan); in compare_int_unlock()
167 uint8_t chan; in z_nrf_grtc_timer_chan_alloc() local
174 err_code = nrfx_grtc_channel_alloc(&chan); in z_nrf_grtc_timer_chan_alloc()
179 return (int32_t)chan; in z_nrf_grtc_timer_chan_alloc()
182 void z_nrf_grtc_timer_chan_free(int32_t chan) in z_nrf_grtc_timer_chan_free() argument
184 IS_CHANNEL_ALLOWED_ASSERT(chan); in z_nrf_grtc_timer_chan_free()
185 nrfx_err_t err_code = nrfx_grtc_channel_free(chan); in z_nrf_grtc_timer_chan_free()
192 bool z_nrf_grtc_timer_compare_evt_check(int32_t chan) in z_nrf_grtc_timer_compare_evt_check() argument
194 IS_CHANNEL_ALLOWED_ASSERT(chan); in z_nrf_grtc_timer_compare_evt_check()
196 uint32_t event_address = nrfx_grtc_event_compare_address_get(chan); in z_nrf_grtc_timer_compare_evt_check()
201 uint32_t z_nrf_grtc_timer_compare_evt_address_get(int32_t chan) in z_nrf_grtc_timer_compare_evt_address_get() argument
203 IS_CHANNEL_ALLOWED_ASSERT(chan); in z_nrf_grtc_timer_compare_evt_address_get()
205 return nrfx_grtc_event_compare_address_get(chan); in z_nrf_grtc_timer_compare_evt_address_get()
208 uint32_t z_nrf_grtc_timer_capture_task_address_get(int32_t chan) in z_nrf_grtc_timer_capture_task_address_get() argument
210 IS_CHANNEL_ALLOWED_ASSERT(chan); in z_nrf_grtc_timer_capture_task_address_get()
212 return nrfx_grtc_capture_task_address_get(chan); in z_nrf_grtc_timer_capture_task_address_get()
220 bool z_nrf_grtc_timer_compare_int_lock(int32_t chan) in z_nrf_grtc_timer_compare_int_lock() argument
222 IS_CHANNEL_ALLOWED_ASSERT(chan); in z_nrf_grtc_timer_compare_int_lock()
224 return compare_int_lock(chan); in z_nrf_grtc_timer_compare_int_lock()
227 void z_nrf_grtc_timer_compare_int_unlock(int32_t chan, bool key) in z_nrf_grtc_timer_compare_int_unlock() argument
229 IS_CHANNEL_ALLOWED_ASSERT(chan); in z_nrf_grtc_timer_compare_int_unlock()
231 compare_int_unlock(chan, key); in z_nrf_grtc_timer_compare_int_unlock()
234 int z_nrf_grtc_timer_compare_read(int32_t chan, uint64_t *val) in z_nrf_grtc_timer_compare_read() argument
236 IS_CHANNEL_ALLOWED_ASSERT(chan); in z_nrf_grtc_timer_compare_read()
238 return get_comparator(chan, val); in z_nrf_grtc_timer_compare_read()
241 static int compare_set_nolocks(int32_t chan, uint64_t target_time, in compare_set_nolocks() argument
250 .channel = chan, in compare_set_nolocks()
259 static int compare_set(int32_t chan, uint64_t target_time, in compare_set() argument
262 bool key = compare_int_lock(chan); in compare_set()
263 int ret = compare_set_nolocks(chan, target_time, handler, user_data); in compare_set()
265 compare_int_unlock(chan, key); in compare_set()
270 int z_nrf_grtc_timer_set(int32_t chan, uint64_t target_time, in z_nrf_grtc_timer_set() argument
273 IS_CHANNEL_ALLOWED_ASSERT(chan); in z_nrf_grtc_timer_set()
275 return compare_set(chan, target_time, (nrfx_grtc_cc_handler_t)handler, user_data); in z_nrf_grtc_timer_set()
278 void z_nrf_grtc_timer_abort(int32_t chan) in z_nrf_grtc_timer_abort() argument
280 IS_CHANNEL_ALLOWED_ASSERT(chan); in z_nrf_grtc_timer_abort()
282 bool key = compare_int_lock(chan); in z_nrf_grtc_timer_abort()
283 (void)nrfx_grtc_syscounter_cc_disable(chan); in z_nrf_grtc_timer_abort()
284 compare_int_unlock(chan, key); in z_nrf_grtc_timer_abort()
316 int z_nrf_grtc_timer_capture_prepare(int32_t chan) in z_nrf_grtc_timer_capture_prepare() argument
321 .channel = chan, in z_nrf_grtc_timer_capture_prepare()
325 IS_CHANNEL_ALLOWED_ASSERT(chan); in z_nrf_grtc_timer_capture_prepare()
340 int z_nrf_grtc_timer_capture_read(int32_t chan, uint64_t *captured_time) in z_nrf_grtc_timer_capture_read() argument
349 IS_CHANNEL_ALLOWED_ASSERT(chan); in z_nrf_grtc_timer_capture_read()
352 if (NRF_GRTC->CC[chan].CCEN == GRTC_CC_CCEN_ACTIVE_Enable) { in z_nrf_grtc_timer_capture_read()
358 result = nrfx_grtc_syscounter_cc_value_read(chan, &capt_time); in z_nrf_grtc_timer_capture_read()
379 uint32_t chan; in z_nrf_grtc_wakeup_prepare() local
410 grtc_chan_mask > 0; grtc_chan_mask &= ~BIT(chan)) { in z_nrf_grtc_wakeup_prepare()
412 chan = u32_count_trailing_zeros(grtc_chan_mask); in z_nrf_grtc_wakeup_prepare()
413 if (chan != systemoff_channel) { in z_nrf_grtc_wakeup_prepare()
414 nrfx_grtc_syscounter_cc_disable(chan); in z_nrf_grtc_wakeup_prepare()