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_APB1PeriphClockCmd(RCC_APB1Periph_BKP | RCC_APB1Periph_PWR,
53 PWR_BackupAccessCmd(ENABLE);
55 RCC_RTCCLKConfig(cfg->
clksrc);
56 RCC_RTCCLKCmd(ENABLE);
57 RTC_WaitForLastTask();
59 RTC_WaitForLastTask();
62 NVIC_Init((NVIC_InitTypeDef*)&cfg->
irq.
init);
63 RTC_ITConfig( RTC_IT_SEC, ENABLE );
64 RTC_WaitForLastTask();
67 RTC_WaitForLastTask();
69 RTC_WaitForLastTask();
74 return RTC_GetCounter();
82 return (
float) (8e6 / 128) / (1 + PIOS_RTC_PRESCALER);
107 if (RTC_GetITStatus(RTC_IT_SEC))
110 for (uint8_t
i = 0;
i < rtc_callback_next;
i++) {
118 RTC_WaitForLastTask();
120 RTC_ClearITPendingBit(RTC_IT_SEC);
Main PiOS header to include all the compiled in PiOS options.
uint32_t PIOS_RTC_Counter()
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)