34 #if defined(PIOS_INCLUDE_RTC)
35 #include <pios_rtc_priv.h>
37 #ifndef PIOS_RTC_PRESCALER
38 #define PIOS_RTC_PRESCALER 100
42 void (*
fn)(uintptr_t);
46 #define PIOS_RTC_MAX_CALLBACKS 3
48 static uint8_t rtc_callback_next = 0;
52 RCC_BackupResetCmd(ENABLE);
53 RCC_BackupResetCmd(DISABLE);
54 RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
55 PWR_BackupAccessCmd(ENABLE);
57 RCC_RTCCLKConfig(cfg->
clksrc);
58 RCC_RTCCLKCmd(ENABLE);
60 RTC_WakeUpCmd(DISABLE);
62 RTC_WakeUpClockConfig(RTC_WakeUpClock_RTCCLK_Div16);
65 RTC_WakeUpCmd(ENABLE);
68 EXTI_InitTypeDef ExtiInit = {
69 .EXTI_Line = EXTI_Line20,
70 .EXTI_Mode = EXTI_Mode_Interrupt,
71 .EXTI_Trigger = EXTI_Trigger_Rising,
72 .EXTI_LineCmd = ENABLE,
74 EXTI_Init((EXTI_InitTypeDef*)&ExtiInit);
75 NVIC_Init((NVIC_InitTypeDef*)&cfg->
irq.
init);
76 RTC_ITConfig(RTC_IT_WUT, ENABLE);
78 RTC_ClearFlag(RTC_FLAG_WUTF);
83 return RTC_GetWakeUpCounter();
91 return (
float) (8e6 / 128) / (1 + PIOS_RTC_PRESCALER);
118 if (RTC_GetITStatus(RTC_IT_WUT))
121 for (uint8_t
i = 0;
i < rtc_callback_next;
i++) {
129 RTC_ClearITPendingBit(RTC_IT_WUT);
132 if (EXTI_GetITStatus(EXTI_Line20) != RESET)
133 EXTI_ClearITPendingBit(EXTI_Line20);
Main PiOS header to include all the compiled in PiOS options.
uint32_t PIOS_RTC_Counter()
#define PIOS_IRQ_Epilogue()
bool PIOS_RTC_RegisterTickCallback(void(*fn)(uintptr_t id), uintptr_t data)
uint8_t data[XFER_BYTES_PER_PACKET]
static struct rtc_callback_entry rtc_callback_list[PIOS_RTC_MAX_CALLBACKS]
static struct flyingpicmd_cfg_fa cfg
float PIOS_RTC_MsPerTick()
void PIOS_RTC_Init(const struct pios_rtc_cfg *cfg)
#define PIOS_RTC_MAX_CALLBACKS
void PIOS_RTC_irq_handler(void)
#define PIOS_IRQ_Prologue()