48 #define soc_rtc_isr(...) AONRTCIntHandler(__VA_ARGS__) 51 void clock_update(
void);
53 static rtimer_clock_t last_isr_time;
55 #define COMPARE_INCREMENT (RTIMER_SECOND / CLOCK_SECOND) 56 #define MULTIPLE_512_MASK 0xFFFFFE00 64 #ifdef SOC_RTC_CONF_START_TICK_COUNT 65 #define SOC_RTC_START_TICK_COUNT SOC_RTC_CONF_START_TICK_COUNT 67 #define SOC_RTC_START_TICK_COUNT 0 73 bool interrupts_disabled;
77 interrupts_disabled = ti_lib_int_master_disable();
79 ti_lib_aon_rtc_disable();
81 ti_lib_aon_rtc_event_clear(AON_RTC_CH0);
82 ti_lib_aon_rtc_event_clear(AON_RTC_CH1);
83 ti_lib_aon_rtc_event_clear(AON_RTC_CH2);
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_event_mcu_wake_up_set(AON_EVENT_MCU_WU2, AON_EVENT_RTC_CH2);
89 ti_lib_aon_rtc_combined_event_config(AON_RTC_CH0 | AON_RTC_CH1 | AON_RTC_CH2);
91 HWREG(AON_RTC_BASE + AON_RTC_O_SEC) = SOC_RTC_START_TICK_COUNT;
93 next = ti_lib_aon_rtc_current_compare_value_get() + COMPARE_INCREMENT;
96 ti_lib_aon_rtc_compare_value_set(AON_RTC_CH1, next);
99 ti_lib_aon_rtc_channel_enable(AON_RTC_CH1);
100 ti_lib_aon_rtc_enable();
102 ti_lib_int_enable(INT_AON_RTC_COMB);
105 if(!interrupts_disabled) {
106 ti_lib_int_master_enable();
113 rtimer_clock_t ch1 = ti_lib_aon_rtc_compare_value_get(AON_RTC_CH1);
115 if(HWREG(AON_RTC_BASE + AON_RTC_O_CHCTL) & AON_RTC_CHCTL_CH0_EN) {
116 rtimer_clock_t ch0 = ti_lib_aon_rtc_compare_value_get(AON_RTC_CH0);
118 return RTIMER_CLOCK_LT(ch0, ch1) ? ch0 : ch1;
127 if((channel != AON_RTC_CH0) && (channel != AON_RTC_CH1) && (channel != AON_RTC_CH2)) {
132 ti_lib_aon_rtc_compare_value_set(channel, ticks);
133 ti_lib_aon_rtc_channel_enable(channel);
137 soc_rtc_last_isr_time(
void)
139 return last_isr_time;
153 if(ti_lib_aon_rtc_event_get(AON_RTC_CH1)) {
154 HWREG(AON_RTC_BASE + AON_RTC_O_EVFLAGS) = AON_RTC_EVFLAGS_CH1;
161 next = ((ti_lib_aon_rtc_current_compare_value_get() + 5) +
162 COMPARE_INCREMENT) & MULTIPLE_512_MASK;
163 ti_lib_aon_rtc_compare_value_set(AON_RTC_CH1, next);
166 if(ti_lib_aon_rtc_event_get(AON_RTC_CH0)) {
167 ti_lib_aon_rtc_channel_disable(AON_RTC_CH0);
168 HWREG(AON_RTC_BASE + AON_RTC_O_EVFLAGS) = AON_RTC_EVFLAGS_CH0;
172 if(ti_lib_aon_rtc_event_get(AON_RTC_CH2)) {
174 ti_lib_aon_rtc_channel_disable(AON_RTC_CH2);
175 HWREG(AON_RTC_BASE + AON_RTC_O_EVFLAGS) = AON_RTC_EVFLAGS_CH2;
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.
void rtimer_run_next(void)
Execute the next real-time task and schedule the next task, if any.
void soc_rtc_init(void)
Initialise the CC13XX/CC26XX AON RTC module.
Header file for the real-time timer module.
rtimer_clock_t soc_rtc_get_next_trigger()
Return the time of the next scheduled rtimer event.