From aaeed65c1875fa8a60b660c30a7e51c69e64e5b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Fri, 6 Mar 2020 11:10:46 +0100 Subject: [PATCH] application: use LSE for oscillator (and remove other board ifdef --- application.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/application.c b/application.c index 61248ba..9662262 100644 --- a/application.c +++ b/application.c @@ -37,13 +37,12 @@ #include // debug utilities #include // design utilities #include // flash utilities +#include // backup domain utilities /* own libraries */ #include "global.h" // board definitions #include "print.h" // printing utilities -#if !defined(STLINKV2) #include "uart.h" // USART utilities -#endif #include "usb_cdcacm.h" // USB CDC ACM utilities #include "terminal.h" // handle the terminal interface #include "menu.h" // menu utilities @@ -54,16 +53,12 @@ /** set to 0 if the RTC is reset when the board is powered on, only indicates the uptime * set to 1 if VBAT can keep the RTC running when the board is unpowered, indicating the date and time */ -#if defined(CORE_BOARD) #define RTC_DATE_TIME 1 -#else -#define RTC_DATE_TIME 0 -#endif /** number of RTC ticks per second * @note use integer divider of oscillator to keep second precision */ -#define RTC_TICKS_SECOND 4 +#define RTC_TICKS_SECOND 1 #if defined(RTC_DATE_TIME) && RTC_DATE_TIME /** the start time from which to RTC ticks count @@ -609,12 +604,8 @@ void main(void) // setup RTC puts("setup internal RTC: "); -#if defined(BLUE_PILL) || defined(STLINKV2) || defined(BLASTER) // for boards without a Low Speed External oscillator - // note: the blue pill LSE oscillator is affected when toggling the onboard LED, thus prefer the HSE - rtc_auto_awake(RCC_HSE, 8000000 / 128 / RTC_TICKS_SECOND - 1); // use High Speed External oscillator (8 MHz / 128) as RTC clock (VBAT can't be used to keep the RTC running) -#else // for boards with an precise Low Speed External oscillator + // note: the blue pill LSE oscillator is affected when toggling the onboard LED -> DON'T USE THE ONBOARD LED since we want to use the LSE rtc_auto_awake(RCC_LSE, 32768 / RTC_TICKS_SECOND - 1); // ensure internal RTC is on, uses the 32.678 kHz LSE, and the prescale is set to our tick speed, else update backup registers accordingly (power off the micro-controller for the change to take effect) -#endif rtc_interrupt_enable(RTC_SEC); // enable RTC interrupt on "seconds" nvic_enable_irq(NVIC_RTC_IRQ); // allow the RTC to interrupt time_start = rtc_get_counter_val(); // get start time from internal RTC