/*---------------------------------------------------------------------------*/ void rtimer_arch_init(void) { struct rtc_count_config config_rtc_count; /* Configure RTC in counter mode */ rtc_count_get_config_defaults(&config_rtc_count); config_rtc_count.prescaler = RTC_COUNT_PRESCALER_DIV_1; #ifdef TEST_RTC_COUNTER config_rtc_count.mode = RTC_COUNT_MODE_16BIT; #else config_rtc_count.mode = RTC_COUNT_MODE_32BIT; #endif config_rtc_count.continuously_update = true; rtc_count_init(&rtc_instance, RTC, &config_rtc_count); /* Enable RTC */ rtc_count_enable(&rtc_instance); #ifdef TEST_RTC_COUNTER /* Overflow callback and reload value */ rtc_count_register_callback( &rtc_instance, rtc_overflow_callback, RTC_COUNT_CALLBACK_OVERFLOW); rtc_count_enable_callback(&rtc_instance, RTC_COUNT_CALLBACK_OVERFLOW); rtc_count_set_period(&rtc_instance, 100); #endif /* Compare callback */ rtc_count_register_callback( &rtc_instance, rtc_compare_callback, RTC_COUNT_CALLBACK_COMPARE_0); INFO("RTIMER initialized"); }
/*---------------------------------------------------------------------------*/ static void _hal_tcInit(void) { //! [init_conf] struct rtc_count_config config_rtc_count; rtc_count_get_config_defaults(&config_rtc_count); //! [init_conf] //! [set_config] config_rtc_count.prescaler = RTC_COUNT_PRESCALER_DIV_1; config_rtc_count.mode = RTC_COUNT_MODE_16BIT; config_rtc_count.continuously_update = true; //! [set_config] //! [init_rtc] rtc_count_init(&rtc_instance, RTC, &config_rtc_count); //! [init_rtc] //! [period] rtc_count_set_period(&rtc_instance, 32); //! [period] //! [reg_callback] rtc_count_register_callback( &rtc_instance, _isr_tc_interrupt, RTC_COUNT_CALLBACK_OVERFLOW); //! [reg_callback] //! [en_callback] rtc_count_enable_callback(&rtc_instance, RTC_COUNT_CALLBACK_OVERFLOW); //! [en_callback] //! [enable] rtc_count_enable(&rtc_instance); //! [enable] } /* _hal_tcInit() */
static void configure_rtc_callbacks(void) { /*Register rtc callback*/ rtc_count_register_callback( &rtc_instance, rtc_overflow_callback, RTC_COUNT_CALLBACK_OVERFLOW); rtc_count_enable_callback(&rtc_instance, RTC_COUNT_CALLBACK_OVERFLOW); }
/*! \brief Configure the RTC timer callback */ void configure_rtc_callbacks(void) { /* Register callback */ rtc_count_register_callback( &rtc_instance, rtc_compare_callback, RTC_COUNT_CALLBACK_COMPARE_0 ); /* Enable callback */ rtc_count_enable_callback(&rtc_instance,RTC_COUNT_CALLBACK_COMPARE_0); }
/* 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); }
void configure_rtc_callbacks(void) { rtc_count_register_callback(&rtc_instance, rtc_overflow_callback, RTC_COUNT_CALLBACK_OVERFLOW); rtc_count_register_callback(&rtc_instance, rtc_compare0_callback, RTC_COUNT_CALLBACK_COMPARE_0); }