33 #if defined(PIOS_INCLUDE_RTC)
34 #include <pios_rtc_priv.h>
36 #ifndef PIOS_RTC_PRESCALER
37 #define PIOS_RTC_PRESCALER 100
41 void (*
fn)(uintptr_t);
45 #define PIOS_RTC_MAX_CALLBACKS 3
47 static uint8_t rtc_callback_next = 0;
51 RCC_BackupResetCmd(ENABLE);
52 RCC_BackupResetCmd(DISABLE);
53 RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
54 PWR_BackupAccessCmd(ENABLE);
56 RCC_RTCCLKConfig(cfg->
clksrc);
57 RCC_RTCCLKCmd(ENABLE);
59 RTC_WakeUpCmd(DISABLE);
61 RTC_WakeUpClockConfig(RTC_WakeUpClock_RTCCLK_Div16);
64 RTC_WakeUpCmd(ENABLE);
67 EXTI_InitTypeDef ExtiInit = {
68 .EXTI_Line = EXTI_Line22,
69 .EXTI_Mode = EXTI_Mode_Interrupt,
70 .EXTI_Trigger = EXTI_Trigger_Rising,
71 .EXTI_LineCmd = ENABLE,
74 NVIC_Init((NVIC_InitTypeDef*)&cfg->
irq.
init);
75 RTC_ITConfig(RTC_IT_WUT, ENABLE);
77 RTC_ClearFlag(RTC_FLAG_WUTF);
82 return RTC_GetWakeUpCounter();
90 return (
float) (8e6 / 128) / (1 + PIOS_RTC_PRESCALER);
117 if (RTC_GetITStatus(RTC_IT_WUT))
120 for (uint8_t
i = 0;
i < rtc_callback_next;
i++) {
128 RTC_ClearITPendingBit(RTC_IT_WUT);
131 if (EXTI_GetITStatus(EXTI_Line22) != RESET)
132 EXTI_ClearITPendingBit(EXTI_Line22);
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()