Integrate the RTC to the task module
This commit is contained in:
parent
24e412446d
commit
89c81b8c42
20
srv/task.c
20
srv/task.c
@ -26,6 +26,10 @@
|
||||
#include "task.h"
|
||||
#include "error.h"
|
||||
#include "../drv/stk.h"
|
||||
#include "../drv/pwr.h"
|
||||
#include "../drv/rcc.h"
|
||||
#include "../drv/bkp.h"
|
||||
#include "../drv/exti.h"
|
||||
|
||||
|
||||
//--local definitions-----------------------------------------------------------
|
||||
@ -51,7 +55,13 @@ static volatile uint32_t timestamp;
|
||||
void task_start_scheduler(void)
|
||||
{
|
||||
stk_configure(1000, callback_stk);
|
||||
//TODO: configure RTC
|
||||
|
||||
rcc_configure_lsi(true);
|
||||
pwr_configure_bkp_write(true);
|
||||
bkp_reset();
|
||||
bkp_configure_rtc(1000, BKP_RTC_CLOCK_SRC_LSI, BKP_RTC_IRQ_NONE, nullptr);
|
||||
pwr_configure_bkp_write(false);
|
||||
exti_configure(EXTI_LINE_RTC, EXTI_CONFIG_RISING_EDGE, callback_rtc);
|
||||
|
||||
while (true) {
|
||||
uint8_t triggers = stk_irq << 0 | rtc_irq << 1;
|
||||
@ -65,10 +75,13 @@ void task_start_scheduler(void)
|
||||
|
||||
if (stk_needed) {
|
||||
stk_start();
|
||||
__asm("wfi");
|
||||
pwr_sleep();
|
||||
} else {
|
||||
pwr_configure_bkp_write(true);
|
||||
bkp_set_rtc_alam(1);
|
||||
pwr_configure_bkp_write(false);
|
||||
stk_stop();
|
||||
//TODO: enter deep sleep
|
||||
pwr_sleep();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -158,4 +171,5 @@ static void callback_stk(void)
|
||||
static void callback_rtc(void)
|
||||
{
|
||||
rtc_irq = true;
|
||||
timestamp = bkp_read_rtc() * 1000;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user