41 #ifndef RTIMER_ARCH_H_
42 #define RTIMER_ARCH_H_
46 #ifdef RTIMER_CONF_SECOND
47 # define RTIMER_ARCH_SECOND RTIMER_CONF_SECOND
50 # if JN516X_EXTERNAL_CRYSTAL_OSCILLATOR
51 # define RTIMER_ARCH_SECOND 32768
53 # define RTIMER_ARCH_SECOND 32000
57 # define RTIMER_ARCH_SECOND (F_CPU / 2)
62 #define US_TO_RTIMERTICKS(US) ((US) >= 0 ? \
63 (((int32_t)(US) * (RTIMER_ARCH_SECOND) + 500000) / 1000000L) : \
64 ((int32_t)(US) * (RTIMER_ARCH_SECOND) - 500000) / 1000000L)
66 #define RTIMERTICKS_TO_US(T) ((T) >= 0 ? \
67 (((int32_t)(T) * 1000000L + ((RTIMER_ARCH_SECOND) / 2)) / (RTIMER_ARCH_SECOND)) : \
68 ((int32_t)(T) * 1000000L - ((RTIMER_ARCH_SECOND) / 2)) / (RTIMER_ARCH_SECOND))
72 #define RTIMERTICKS_TO_US_64(T) ((uint32_t)(((uint64_t)(T) * 1000000 + ((RTIMER_ARCH_SECOND) / 2)) / (RTIMER_ARCH_SECOND)))
76 #define US_TO_RTIMERTICKS(D) ((int64_t)(D) << 4)
77 #define RTIMERTICKS_TO_US(T) ((int64_t)(T) >> 4)
78 #define RTIMERTICKS_TO_US_64(T) RTIMERTICKS_TO_US(T)
84 rtimer_clock_t rtimer_arch_time_to_rtimer(
void);
86 void rtimer_arch_reinit(rtimer_clock_t sleep_start, rtimer_clock_t wakeup_time);
88 void clock_arch_init(
int is_reinitialization);
90 void clock_arch_calibrate(
void);
92 void clock_arch_reinit(
void);
94 void clock_arch_schedule_interrupt(clock_time_t time_to_etimer, rtimer_clock_t ticks_to_rtimer);
96 clock_t clock_arch_time_to_etimer(
void);
99 #define JN516X_MIN_SLEEP_TIME (RTIMER_SECOND / 50)
101 #define JN516X_MAX_SLEEP_TIME RTIMER_SECOND
103 #define JN516X_SLEEP_GUARD_TIME (RTIMER_ARCH_SECOND / 100)
105 #define WAKEUP_TIMER E_AHI_WAKE_TIMER_0
106 #define WAKEUP_TIMER_MASK E_AHI_SYSCTRL_WK0_MASK
108 #define TICK_TIMER E_AHI_WAKE_TIMER_1
109 #define TICK_TIMER_MASK E_AHI_SYSCTRL_WK1_MASK
111 #define WAIT_FOR_EDGE(edge_t) do { \
112 uint64_t start_t = u64AHI_WakeTimerReadLarge(TICK_TIMER); \
114 edge_t = u64AHI_WakeTimerReadLarge(TICK_TIMER); \
115 } while(edge_t == start_t); \
Header file for the real-time timer module.
rtimer_clock_t rtimer_arch_now(void)
Returns the current real-time clock time.