From 5665f035c4d718a308668799a44a51f7749f07d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Sat, 30 Apr 2016 12:11:38 +0200 Subject: [PATCH] a tick counter --- lib/rtc_ds1307.c | 2 ++ lib/rtc_ds1307.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/rtc_ds1307.c b/lib/rtc_ds1307.c index b0ed66d..a4956a9 100644 --- a/lib/rtc_ds1307.c +++ b/lib/rtc_ds1307.c @@ -37,6 +37,7 @@ #include "rtc_ds1307.h" // RTC header and definitions #if defined(SQUARE_WAVE_TICKS) +volatile uint32_t rtc_ticks = 0; volatile bool rtc_tick_flag = false; #endif @@ -450,6 +451,7 @@ void SQUARE_WAVE_TIMER_ISR(void) { if (timer_get_flag(SQUARE_WAVE_TIMER, TIM_SR_UIF)) { // overflow even happened timer_clear_flag(SQUARE_WAVE_TIMER, TIM_SR_UIF); // clear flag + rtc_ticks++; // increment count rtc_tick_flag = true; // update flag } } diff --git a/lib/rtc_ds1307.h b/lib/rtc_ds1307.h index 7abe523..2851610 100644 --- a/lib/rtc_ds1307.h +++ b/lib/rtc_ds1307.h @@ -52,7 +52,8 @@ /** @} */ #if defined(SQUARE_WAVE_TICKS) -extern volatile bool rtc_tick_flag; /**< set on SQUARE_WAVE_TICS square wave tics */ +extern volatile uint32_t rtc_ticks; /**< increment on SQUARE_WAVE_TICS square wave ticks */ +extern volatile bool rtc_tick_flag; /**< set on SQUARE_WAVE_TICS square wave ticks */ #endif /** @brief setup communication with RTC IC