49 #define soc_rtc_isr(...) AONRTCIntHandler(__VA_ARGS__)
52 void clock_update(
void);
54 static rtimer_clock_t last_isr_time;
56 #define COMPARE_INCREMENT (RTIMER_SECOND / CLOCK_SECOND)
57 #define MULTIPLE_512_MASK 0xFFFFFE00
65 #ifdef SOC_RTC_CONF_START_TICK_COUNT
66 #define SOC_RTC_START_TICK_COUNT SOC_RTC_CONF_START_TICK_COUNT
68 #define SOC_RTC_START_TICK_COUNT 0
74 bool interrupts_disabled;
78 interrupts_disabled = ti_lib_int_master_disable();
80 ti_lib_aon_rtc_disable();
82 ti_lib_aon_rtc_event_clear(AON_RTC_CH0);
83 ti_lib_aon_rtc_event_clear(AON_RTC_CH1);
86 ti_lib_aon_event_mcu_wake_up_set(AON_EVENT_MCU_WU0, AON_EVENT_RTC_CH0);
87 ti_lib_aon_event_mcu_wake_up_set(AON_EVENT_MCU_WU1, AON_EVENT_RTC_CH1);
88 ti_lib_aon_rtc_combined_event_config(AON_RTC_CH0 | AON_RTC_CH1);
90 HWREG(AON_RTC_BASE + AON_RTC_O_SEC) = SOC_RTC_START_TICK_COUNT;
92 next = ti_lib_aon_rtc_current_compare_value_get() + COMPARE_INCREMENT;
95 ti_lib_aon_rtc_compare_value_set(AON_RTC_CH1, next);
98 ti_lib_aon_rtc_channel_enable(AON_RTC_CH1);
99 ti_lib_aon_rtc_enable();
101 ti_lib_int_enable(INT_AON_RTC);
104 if(!interrupts_disabled) {
105 ti_lib_int_master_enable();
112 rtimer_clock_t ch1 = ti_lib_aon_rtc_compare_value_get(AON_RTC_CH1);
114 if(HWREG(AON_RTC_BASE + AON_RTC_O_CHCTL) & AON_RTC_CHCTL_CH0_EN) {
115 rtimer_clock_t ch0 = ti_lib_aon_rtc_compare_value_get(AON_RTC_CH0);
117 return RTIMER_CLOCK_LT(ch0, ch1) ? ch0 : ch1;
126 if((channel != AON_RTC_CH0) && (channel != AON_RTC_CH1)) {
131 ti_lib_aon_rtc_compare_value_set(channel, ticks);
132 ti_lib_aon_rtc_channel_enable(channel);
136 soc_rtc_last_isr_time(
void)
138 return last_isr_time;
147 ENERGEST_ON(ENERGEST_TYPE_IRQ);
154 if(ti_lib_aon_rtc_event_get(AON_RTC_CH1)) {
155 HWREG(AON_RTC_BASE + AON_RTC_O_EVFLAGS) = AON_RTC_EVFLAGS_CH1;
162 next = ((ti_lib_aon_rtc_current_compare_value_get() + 5) +
163 COMPARE_INCREMENT) & MULTIPLE_512_MASK;
164 ti_lib_aon_rtc_compare_value_set(AON_RTC_CH1, next);
167 if(ti_lib_aon_rtc_event_get(AON_RTC_CH0)) {
168 ti_lib_aon_rtc_channel_disable(AON_RTC_CH0);
169 HWREG(AON_RTC_BASE + AON_RTC_O_EVFLAGS) = AON_RTC_EVFLAGS_CH0;
173 ENERGEST_OFF(ENERGEST_TYPE_IRQ);
Header file for the real-time timer module.
void soc_rtc_schedule_one_shot(uint32_t channel, uint32_t ticks)
Schedule an AON RTC channel 0 one-shot compare event.
Header file with macros which rename TI CC26xxware functions.
#define RTIMER_NOW()
Get the current clock time.
Header file for the energy estimation mechanism
void soc_rtc_init(void)
Initialise the CC13XX/CC26XX AON RTC module.
void rtimer_run_next(void)
Execute the next real-time task and schedule the next task, if any.
rtimer_clock_t soc_rtc_get_next_trigger()
Return the time of the next scheduled rtimer event.