35#ifndef NRF_802154_UTILS_H__
36#define NRF_802154_UTILS_H__
41#include <lib/nrfx_coredep.h>
43#ifdef __STATIC_INLINE__
44#undef __STATIC_INLINE__
47#ifdef NRF_802154_UTILS_DECLARE_ONLY
48#define __STATIC_INLINE__
50#define __STATIC_INLINE__ __STATIC_INLINE
61#define NRF_802154_RTC_FREQUENCY 32768UL
64#define NRF_802154_US_PER_S 1000000ULL
67#define NRF_802154_US_PER_TICK NRF_802154_RTC_TICKS_TO_US(1)
70#define NRF_802154_FREQUENCY_US_PER_S_GCD_BITS 6
73#define NRF_802154_DIVIDE_AND_CEIL(A, B) (((A) + (B)-1) / (B))
76#define NRF_802154_RTC_TICKS_TO_US(ticks) \
77 NRF_802154_DIVIDE_AND_CEIL( \
78 (ticks) * (NRF_802154_US_PER_S >> NRF_802154_FREQUENCY_US_PER_S_GCD_BITS), \
79 (NRF_802154_RTC_FREQUENCY >> NRF_802154_FREQUENCY_US_PER_S_GCD_BITS))
125#ifndef NRF_802154_UTILS_DECLARE_ONLY
129 nrfx_coredep_delay_us(time_in_us);
136 mcu_cs = __get_PRIMASK();
144 __set_PRIMASK(mcu_cs);
186 t1 = ((time >> 13) * 0x8637bd0) >> 28;
188 t1 = time - t1 * 15625;
213 u1 = (t1 * 0x431bde82d7b);
214 u1 += 0x7fffffffffff;
__STATIC_INLINE nrf_802154_mcu_critical_state_t nrf_802154_mcu_critical_enter(void)
Enters critical section on MCU level.
Definition nrf_802154_utils.h:132
__STATIC_INLINE void nrf_802154_mcu_critical_exit(nrf_802154_mcu_critical_state_t mcu_cs)
Exits critical section on MCU level.
Definition nrf_802154_utils.h:142
__STATIC_INLINE uint64_t NRF_802154_US_TO_RTC_TICKS(uint64_t time)
Convert microseconds to RTC ticks.
Definition nrf_802154_utils.h:147
__STATIC_INLINE void nrf_802154_delay_us(uint32_t time_in_us)
Active waiting for given number of microseconds.
Definition nrf_802154_utils.h:127
uint32_t nrf_802154_mcu_critical_state_t
Type holding MCU critical section state.
Definition nrf_802154_utils.h:86
#define NRF_802154_ASSERT(condition)
Definition nrf_802154_assert.h:45