/** * \internal * \brief Cleanup Function: Asynchronous event propagation. * * This function disables the RTC, clears the RTC COUNT register and * stops the timer (TC3). * * \param test Current test case. */ static void cleanup_asynchronous_event_test(const struct test_case *test) { rtc_count_disable(&rtc_inst); rtc_count_set_count(&rtc_inst, 0); tc_stop_counter(&tc_inst); events_release(&events); }
static void _sleep_entry(void) { rt_tick_t timeout; rt_uint32_t ms; rt_uint32_t count; system_set_sleepmode(SYSTEM_SLEEPMODE_STANDBY); timeout = rt_timer_next_timeout_tick() - rt_tick_get(); ms = timeout * (1000 / RT_TICK_PER_SECOND); rt_kprintf("os tick:%u entry sleep:%u tick\r\n", rt_tick_get(), timeout); _rtc_timer_start(ms); system_sleep(); rt_enter_critical(); count = rtc_count_get_count(&rtc_instance); ms = (count + 32) / 32.768; rtc_count_disable(&rtc_instance); sleep_tick_adjust(ms); timeout = rt_tick_get(); rt_exit_critical(); rt_kprintf("sleep exited, os tick:%u\n", timeout); }
/** * \brief Resets the RTC module. * Resets the RTC to hardware defaults. * * \param[in,out] module Pointer to the software instance struct */ void rtc_count_reset(struct rtc_module *const module) { /* Sanity check arguments */ Assert(module); Assert(module->hw); Rtc *const rtc_module = module->hw; /* Disable module before reset. */ rtc_count_disable(module); #if RTC_COUNT_ASYNC == true module->registered_callback = 0; module->enabled_callback = 0; #endif while (rtc_count_is_syncing(module)) { /* Wait for synchronization */ } /* Initiate software reset. */ rtc_module->MODE0.CTRLA.reg |= RTC_MODE0_CTRLA_SWRST; while (rtc_count_is_syncing(module)) { /* Wait for synchronization */ } }
/** Frees the RTC * * @param[void] void */ void rtc_free(void) { if (rtc_inited) { /* Disable the RTC module */ rtc_count_disable(&rtc_instance); /* Disable the RTC clock */ system_gclk_chan_disable(RTC_GCLK_ID); rtc_inited = 0; } }
void sleep_timer_stop(void) { rtc_count_disable(&rtc_instance); }
static void rtc_overflow_callback(void) { /* Do something on RTC overflow here */ rtc_count_disable(&rtc_instance); }