diff --git a/platform/mcu/STM32F4xx/drivers/rtc.h b/openrtx/include/interfaces/rtc.h similarity index 86% rename from platform/mcu/STM32F4xx/drivers/rtc.h rename to openrtx/include/interfaces/rtc.h index 5d121b5c..d8b3c816 100644 --- a/platform/mcu/STM32F4xx/drivers/rtc.h +++ b/openrtx/include/interfaces/rtc.h @@ -1,5 +1,7 @@ /*************************************************************************** - * Copyright (C) 2020 by Silvano Seva IU2KWO and Niccolò Izzo IU2KIN * + * Copyright (C) 2020 by Federico Amedeo Izzo IU2NUO, * + * Niccolò Izzo IU2KIN * + * Silvano Seva IU2KWO * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -19,14 +21,13 @@ #define RTC_H #include -#include "stm32f4xx.h" /** - * Driver for STM32 real time clock, providing both calendar and clock - * functionalities. + * Standard interface for real time clock drivers, providing both calendar and + * clock functionalities. * - * RTC is active also when radio is powered off, thanks to the internal - * lithium backup battery. + * Depending on hardware, RTC is active also when radio is powered off, thanks + * to the internal lithium backup battery. */ typedef struct @@ -42,14 +43,12 @@ typedef struct }curTime_t; /** - * Initialise and start RTC, which uses as clock source the external 32.768kHz - * crystal connected to PC14 and PC15 (indicated with LSE in STM32 reference - * manual). + * Initialise and start RTC. */ void rtc_init(); /** - * Shutdown RTC and external 32.768kHz clock source. + * Shutdown RTC. */ void rtc_shutdown(); diff --git a/platform/mcu/STM32F4xx/drivers/rtc.c b/platform/mcu/STM32F4xx/drivers/rtc.c index 9b28bb12..d91e60ba 100644 --- a/platform/mcu/STM32F4xx/drivers/rtc.c +++ b/platform/mcu/STM32F4xx/drivers/rtc.c @@ -1,5 +1,7 @@ /*************************************************************************** - * Copyright (C) 2020 by Silvano Seva IU2KWO and Niccolò Izzo IU2KIN * + * Copyright (C) 2020 by Federico Amedeo Izzo IU2NUO, * + * Niccolò Izzo IU2KIN * + * Silvano Seva IU2KWO * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -15,9 +17,9 @@ * along with this program; if not, see * ***************************************************************************/ +#include #include "rtc.h" -#include "FreeRTOS.h" -#include "task.h" +#include "stm32f4xx.h" void rtc_init() { @@ -65,13 +67,13 @@ void rtc_setTime(curTime_t t) time &= RTC_TR_HT | RTC_TR_HU | RTC_TR_MNT | RTC_TR_MNU | RTC_TR_ST | RTC_TR_SU; /* Enter initialisation mode and update registers */ - taskENTER_CRITICAL(); + CPU_CRITICAL_ENTER(); RTC->ISR |= RTC_ISR_INIT; while((RTC->ISR & RTC_ISR_INITF) == 0) ; RTC->TR = time; RTC->DR = date; RTC->ISR &= ~RTC_ISR_INIT; - taskEXIT_CRITICAL(); + CPU_CRITICAL_EXIT(); } void rtc_setHour(uint8_t hours, uint8_t minutes, uint8_t seconds) @@ -118,17 +120,17 @@ void rtc_dstSet() { /* If BKP bit is set, DST has been already set */ if(RTC->CR & RTC_CR_BCK) return; - taskENTER_CRITICAL(); + CPU_CRITICAL_ENTER(); RTC->CR |= RTC_CR_BCK | RTC_CR_ADD1H; - taskEXIT_CRITICAL(); + CPU_CRITICAL_EXIT(); } void rtc_dstClear() { /* If BKP bit is cleared, DST has been already removed */ if((RTC->CR & RTC_CR_BCK) == 0) return; - taskENTER_CRITICAL(); + CPU_CRITICAL_ENTER(); RTC->CR &= ~RTC_CR_BCK; RTC->CR |= RTC_CR_SUB1H; - taskEXIT_CRITICAL(); + CPU_CRITICAL_EXIT(); }