1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/stm32f1: adjusted to RTT interface changes

This commit is contained in:
Hauke Petersen 2014-11-07 12:25:59 +01:00
parent 636287a1aa
commit 65520865b1

View File

@ -42,9 +42,15 @@ inline void _rtt_leave_config_mode(void);
/*
* callback and argument for an active alarm
*/
static rtt_alarm_cb_t alarm_cb;
static rtt_cb_t alarm_cb;
static void *alarm_arg;
/*
* callback and argument for overflow callback
*/
static rtt_cb_t overflow_cb;
static void *overflow_arg;
void rtt_init(void)
{
rtt_poweron();
@ -69,6 +75,24 @@ void rtt_init(void)
_rtt_leave_config_mode();
}
void rtt_set_overflow_cb(rtt_cb_t cb, void *arg)
{
overflow_cb = cb;
overflow_arg = arg;
_rtt_enter_config_mode();
/* Enable overflow interrupt */
RTT_DEV->CRH |= RTC_CRH_OWIE;
_rtt_leave_config_mode();
}
void rtt_clear_overflow_cb(void)
{
_rtt_enter_config_mode();
/* Clear overflow interrupt */
RTT_DEV->CRH &= ~(RTC_CRH_OWIE);
_rtt_leave_config_mode();
}
uint32_t rtt_get_counter(void)
{
/* wait for syncronization */
@ -97,7 +121,7 @@ uint32_t rtt_get_alarm(void)
return (((uint32_t)RTT_DEV->ALRH << 16 ) | (uint32_t)(RTT_DEV->ALRL));
}
void rtt_set_alarm(uint32_t alarm, rtt_alarm_cb_t cb, void *arg)
void rtt_set_alarm(uint32_t alarm, rtt_cb_t cb, void *arg)
{
_rtt_enter_config_mode();
@ -169,6 +193,10 @@ void RTT_ISR(void)
RTT_DEV->CRL &= ~(RTC_CRL_ALRF);
alarm_cb(alarm_arg);
}
if (RTT_DEV->CRL & RTC_CRL_OWF) {
RTT_DEV->CRL &= ~(RTC_CRL_OWF);
overflow_cb(overflow_arg);
}
if (sched_context_switch_request) {
thread_yield();
}