/** * \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); }
/** Write the RTC value * * Update the time value in RTC * @param[in] t The time value to be written * @return void */ void rtc_write(time_t t) { if (!rtc_inited) { /* Initialize the RTC is not yet initialized */ rtc_init(); } uint32_t count_value = (uint32_t)t; rtc_count_set_count(&rtc_instance, count_value); }
static void _rtc_timer_start(uint32_t ms) { uint32_t compare = 0; compare = (uint32_t)(32.768 * ms); // rtc_count_register_callback(&rtc_instance, _rtc_timer_int_cb, RTC_COUNT_CALLBACK_COMPARE_0); rtc_count_enable_callback(&rtc_instance, RTC_COUNT_CALLBACK_COMPARE_0); rtc_count_set_count(&rtc_instance, 0); rtc_count_set_compare(&rtc_instance, compare, RTC_COUNT_COMPARE_0); rtc_count_enable(&rtc_instance); }
/* Init RTC as ADC sample timer */ static void _rtc_timer_init(void) { struct rtc_count_config conf; rtc_count_get_config_defaults(&conf); conf.prescaler = RTC_COUNT_PRESCALER_DIV_1; conf.mode = RTC_COUNT_MODE_32BIT; conf.clear_on_match = false; conf.compare_values[0] = 0; // struct rtc_count_events evconfig; // evconfig.generate_event_on_compare[0] = true; rtc_count_init(&rtc_instance, RTC, &conf); // rtc_count_enable_events(&rtc_instance, &evconfig); // rtc_count_enable(&rtc_instance); rtc_count_set_count(&rtc_instance, 0); rtc_count_register_callback(&rtc_instance, _rtc_timer_int_cb, RTC_COUNT_CALLBACK_COMPARE_0); // rtc_count_enable_callback(&rtc_instance, RTC_COUNT_CALLBACK_COMPARE_0); }