20 void rtc_callback(
void);
21 static volatile uint8_t flag;
26 static void (*rtc_alarm_handler)(void);
27 static void (*rtc_resolution_handler)(void);
28 static void (*rtc_overflow_handler)(void);
42 rtc_awake_from_off(RCC_LSI);
43 rtc_set_counter_val(0);
57 rtc_set_prescale_val(resolution);
74 rtc_set_counter_val(0);
75 rtc_set_prescale_val(0);
77 rtc_set_prescale_val(rtc_get_counter_val()-4);
78 rtc_set_counter_val(0);
84 void rtc_callback(
void){
92 rtc_set_counter_val(count);
98 rtc_awake_from_off(RCC_LSI);
103 return rtc_get_counter_val();
114 rtc_resolution_handler = res_isr;
115 rtc_interrupt_enable(RTC_SEC);
116 nvic_enable_irq(NVIC_RTC_IRQ);
121 rtc_interrupt_disable(RTC_SEC);
126 return (RTC_CRH & RTC_CRH_SECIE);
136 rtc_alarm_handler = al_isr;
137 rtc_interrupt_enable(RTC_ALR);
138 rtc_set_alarm_time(count);
139 nvic_enable_irq(NVIC_RTC_IRQ);
144 rtc_interrupt_disable(RTC_ALR);
149 return (RTC_CRH & RTC_CRH_ALRIE);
158 rtc_overflow_handler = ov_isr;
159 rtc_interrupt_enable(RTC_OW);
160 nvic_enable_irq(NVIC_RTC_IRQ);
165 rtc_interrupt_disable(RTC_OW);
170 return (RTC_CRH & RTC_CRH_OWIE);
178 if(rtc_check_flag(RTC_OW)){
180 rtc_clear_flag(RTC_OW);
181 rtc_overflow_handler();
183 else if(rtc_check_flag(RTC_ALR)){
185 rtc_clear_flag(RTC_ALR);
188 else if(rtc_check_flag(RTC_SEC)){
190 rtc_clear_flag(RTC_SEC);
191 rtc_resolution_handler();
uint32_t RTC_getCount(void)
Get the current count value.
mcu_error RTC_setPrescaler(uint32_t resolution)
Set the raw prescaler value of the RTC.
void RTC_clockEnable(void)
Enable the RTC clock.
void MCU_printError(mcu_error errorNum)
Print a given error number as a character stream.
uint8_t RTC_isOverflowEnabled(void)
Determine if the overflow interrupt is enabled.
uint8_t MCU_debugIsEnabled(void)
Checks if debug is enabled.
Error RTC: Invalid period specified.
void RTC_setCount(uint32_t count)
Set the current count value.
void SYSTICK_stop(void)
Stop the systick counter.
uint8_t RTC_isResolutionEnabled(void)
Determine if the resolution (second) interrupt is enabled.
void RTC_disableAlarmISR(void)
disables the alarm ISR.
void RTC_enableAlarmISR(uint32_t count, void(*al_isr)(void))
Enables the alarm ISR.
void RTC_disableResolutionISR(void)
disables the resolution ISR.
void RTC_enableOverflowISR(void(*ov_isr)(void))
Enables the overflow ISR.
mcu_error RTC_setup(uint32_t resolution)
Initialize the Real time clock.
void RTC_disableOverflowISR(void)
disables the overflow ISR.
Header file for stm32f103cb real time clock (RTC)
void RTC_enableResolutionISR(void(*res_isr)(void))
Enables the resolution ISR.
uint8_t RTC_isAlarmEnabled(void)
Determine if the alarm interrupt is enabled.
mcu_error RTC_calibrate(uint32_t resolution)
Calibrate the RTC to a given resolution in milliseconds.
mcu_error SYSTICK_setup(uint32_t timeout, void(*handler)(void))
Sets up systick and handler.
mcu_error
Error enumerators for the Debug peripheral.