Exemplo n.º 1
0
/*---------------------------------------------------------------------------*/
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() */
Exemplo n.º 2
0
/*---------------------------------------------------------------------------*/
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");
}
Exemplo n.º 3
0
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);
}
Exemplo n.º 4
0
/*! \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);
}
Exemplo n.º 5
0
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);
}
Exemplo n.º 6
0
/*---------------------------------------------------------------------------*/
void
rtimer_arch_schedule(rtimer_clock_t t)
{
  rtimer_clock_t now;

  /* Retrieve current RTC counter value */
  now = RTIMER_NOW();

  /*
   * New value must be 5 ticks in the future. The ST may tick once while we're
   * writing the registers. We play it safe here and we add a bit of leeway
   */
  if ((rtimer_clock_t)(t - now) < 7) {
    t = now + 7;
  }

  /* Set value for compare (use channel 0) */
  rtc_count_set_compare(&rtc_instance, t, RTC_COUNT_COMPARE_0);

  /* Enable compare callback */
  rtc_count_enable_callback(&rtc_instance, RTC_COUNT_CALLBACK_COMPARE_0);
}
Exemplo n.º 7
0
void enable_rtc_compare0_callback(void)
{
	rtc_count_enable_callback(&rtc_instance, RTC_COUNT_CALLBACK_COMPARE_0);
}
Exemplo n.º 8
0
void enable_rtc_overflow_callback(void)
{
	rtc_count_enable_callback(&rtc_instance, RTC_COUNT_CALLBACK_OVERFLOW);
}