Skip to content
Snippets Groups Projects
Commit 65520865 authored by Hauke Petersen's avatar Hauke Petersen
Browse files

cpu/stm32f1: adjusted to RTT interface changes

parent 636287a1
No related branches found
No related tags found
No related merge requests found
...@@ -42,9 +42,15 @@ inline void _rtt_leave_config_mode(void); ...@@ -42,9 +42,15 @@ inline void _rtt_leave_config_mode(void);
/* /*
* callback and argument for an active alarm * callback and argument for an active alarm
*/ */
static rtt_alarm_cb_t alarm_cb; static rtt_cb_t alarm_cb;
static void *alarm_arg; static void *alarm_arg;
/*
* callback and argument for overflow callback
*/
static rtt_cb_t overflow_cb;
static void *overflow_arg;
void rtt_init(void) void rtt_init(void)
{ {
rtt_poweron(); rtt_poweron();
...@@ -69,6 +75,24 @@ void rtt_init(void) ...@@ -69,6 +75,24 @@ void rtt_init(void)
_rtt_leave_config_mode(); _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) uint32_t rtt_get_counter(void)
{ {
/* wait for syncronization */ /* wait for syncronization */
...@@ -97,7 +121,7 @@ uint32_t rtt_get_alarm(void) ...@@ -97,7 +121,7 @@ uint32_t rtt_get_alarm(void)
return (((uint32_t)RTT_DEV->ALRH << 16 ) | (uint32_t)(RTT_DEV->ALRL)); 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(); _rtt_enter_config_mode();
...@@ -169,6 +193,10 @@ void RTT_ISR(void) ...@@ -169,6 +193,10 @@ void RTT_ISR(void)
RTT_DEV->CRL &= ~(RTC_CRL_ALRF); RTT_DEV->CRL &= ~(RTC_CRL_ALRF);
alarm_cb(alarm_arg); 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) { if (sched_context_switch_request) {
thread_yield(); thread_yield();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment