aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
Diffstat (limited to 'os')
-rw-r--r--os/hal/platforms/STM32/RTCv2/rtc_lld.c8
-rw-r--r--os/hal/platforms/STM32/RTCv2/rtc_lld.h23
-rw-r--r--os/hal/platforms/STM32F0xx/platform.mk2
-rw-r--r--os/various/chrtclib.c9
4 files changed, 36 insertions, 6 deletions
diff --git a/os/hal/platforms/STM32/RTCv2/rtc_lld.c b/os/hal/platforms/STM32/RTCv2/rtc_lld.c
index 17ae46ccf..f663ecd3b 100644
--- a/os/hal/platforms/STM32/RTCv2/rtc_lld.c
+++ b/os/hal/platforms/STM32/RTCv2/rtc_lld.c
@@ -187,6 +187,7 @@ void rtc_lld_set_alarm(RTCDriver *rtcp,
rtcp->id_rtc->CR &= ~RTC_CR_ALRAE;
}
}
+#if RTC_ALARMS == 2
else{
if (alarmspec != NULL){
rtcp->id_rtc->CR &= ~RTC_CR_ALRBE;
@@ -201,6 +202,7 @@ void rtc_lld_set_alarm(RTCDriver *rtcp,
rtcp->id_rtc->CR &= ~RTC_CR_ALRBE;
}
}
+#endif /* RTC_ALARMS == 2 */
}
/**
@@ -217,8 +219,10 @@ void rtc_lld_get_alarm(RTCDriver *rtcp,
RTCAlarm *alarmspec) {
if (alarm == 1)
alarmspec->tv_datetime = rtcp->id_rtc->ALRMAR;
+#if RTC_ALARMS == 2
else
alarmspec->tv_datetime = rtcp->id_rtc->ALRMBR;
+#endif
}
/**
@@ -231,6 +235,7 @@ void rtc_lld_get_alarm(RTCDriver *rtcp,
*
* @api
*/
+#if RTC_HAS_PERIODIC_WAKEUPS
void rtcSetPeriodicWakeup_v2(RTCDriver *rtcp, RTCWakeup *wakeupspec){
chDbgCheck((wakeupspec->wakeup != 0x30000),
"rtc_lld_set_periodic_wakeup, forbidden combination");
@@ -249,6 +254,7 @@ void rtcSetPeriodicWakeup_v2(RTCDriver *rtcp, RTCWakeup *wakeupspec){
rtcp->id_rtc->CR &= ~RTC_CR_WUTE;
}
}
+#endif /* RTC_HAS_PERIODIC_WAKEUPS */
/**
* @brief Gets time of periodic wakeup.
@@ -260,11 +266,13 @@ void rtcSetPeriodicWakeup_v2(RTCDriver *rtcp, RTCWakeup *wakeupspec){
*
* @api
*/
+#if RTC_HAS_PERIODIC_WAKEUPS
void rtcGetPeriodicWakeup_v2(RTCDriver *rtcp, RTCWakeup *wakeupspec){
wakeupspec->wakeup = 0;
wakeupspec->wakeup |= rtcp->id_rtc->WUTR;
wakeupspec->wakeup |= (((uint32_t)rtcp->id_rtc->CR) & 0x7) << 16;
}
+#endif /* RTC_HAS_PERIODIC_WAKEUPS */
/**
* @brief Get current time in format suitable for usage in FatFS.
diff --git a/os/hal/platforms/STM32/RTCv2/rtc_lld.h b/os/hal/platforms/STM32/RTCv2/rtc_lld.h
index 8e0ce8dd0..ef96b777e 100644
--- a/os/hal/platforms/STM32/RTCv2/rtc_lld.h
+++ b/os/hal/platforms/STM32/RTCv2/rtc_lld.h
@@ -36,9 +36,22 @@
/*===========================================================================*/
/**
- * @brief Two alarm comparators available on STM32F4x.
+ * @brief Two alarm comparators available on STM32F4x and STM32F2x.
*/
-#define RTC_ALARMS 2
+#if !defined(STM32F0XX)
+#define RTC_ALARMS 2
+#else
+#define RTC_ALARMS 1
+#endif
+
+/**
+ * @brief STM32F0x has no periodic wakeups.
+ */
+#if !defined(STM32F0XX)
+#define RTC_HAS_PERIODIC_WAKEUPS TRUE
+#else
+#define RTC_HAS_PERIODIC_WAKEUPS FALSE
+#endif
/**
* @brief Data offsets in RTC date and time registers.
@@ -81,9 +94,11 @@
#define RTC_USE_INTERRUPTS FALSE
#endif
+#if defined(STM32_PCLK1) /* For devices without STM32_PCLK1 (STM32F0xx) */
#if STM32_PCLK1 < (STM32_RTCCLK * 7)
#error "STM32_PCLK1 frequency is too low to handle RTC without ugly workaround"
#endif
+#endif /* defined(STM32_PCLK1) */
/*===========================================================================*/
/* Driver data structures and types. */
@@ -144,6 +159,7 @@ struct RTCAlarm {
uint32_t tv_datetime;
};
+#if RTC_HAS_PERIODIC_WAKEUPS
/**
* @brief Structure representing an RTC periodic wakeup period.
*/
@@ -157,6 +173,7 @@ struct RTCWakeup {
*/
uint32_t wakeup;
};
+#endif /* RTC_HAS_PERIODIC_WAKEUPS */
/**
* @brief Structure representing an RTC driver.
@@ -192,8 +209,10 @@ extern "C" {
void rtc_lld_get_alarm(RTCDriver *rtcp,
rtcalarm_t alarm,
RTCAlarm *alarmspec);
+#if RTC_HAS_PERIODIC_WAKEUPS
void rtcSetPeriodicWakeup_v2(RTCDriver *rtcp, RTCWakeup *wakeupspec);
void rtcGetPeriodicWakeup_v2(RTCDriver *rtcp, RTCWakeup *wakeupspec);
+#endif /* RTC_HAS_PERIODIC_WAKEUPS */
uint32_t rtc_lld_get_time_fat(RTCDriver *rtcp);
#ifdef __cplusplus
}
diff --git a/os/hal/platforms/STM32F0xx/platform.mk b/os/hal/platforms/STM32F0xx/platform.mk
index 8e49a2e86..00107c4d6 100644
--- a/os/hal/platforms/STM32F0xx/platform.mk
+++ b/os/hal/platforms/STM32F0xx/platform.mk
@@ -6,6 +6,7 @@ PLATFORMSRC = ${CHIBIOS}/os/hal/platforms/STM32F0xx/stm32_dma.c \
${CHIBIOS}/os/hal/platforms/STM32/ext_lld.c \
${CHIBIOS}/os/hal/platforms/STM32/GPIOv2/pal_lld.c \
${CHIBIOS}/os/hal/platforms/STM32/I2Cv2/i2c_lld.c \
+ ${CHIBIOS}/os/hal/platforms/STM32/RTCv2/rtc_lld.c \
${CHIBIOS}/os/hal/platforms/STM32/SPIv2/spi_lld.c \
${CHIBIOS}/os/hal/platforms/STM32/TIMv1/gpt_lld.c \
${CHIBIOS}/os/hal/platforms/STM32/TIMv1/icu_lld.c \
@@ -17,6 +18,7 @@ PLATFORMSRC = ${CHIBIOS}/os/hal/platforms/STM32F0xx/stm32_dma.c \
PLATFORMINC = ${CHIBIOS}/os/hal/platforms/STM32F0xx \
${CHIBIOS}/os/hal/platforms/STM32 \
${CHIBIOS}/os/hal/platforms/STM32/GPIOv2 \
+ ${CHIBIOS}/os/hal/platforms/STM32/RTCv2 \
${CHIBIOS}/os/hal/platforms/STM32/I2Cv2 \
${CHIBIOS}/os/hal/platforms/STM32/SPIv2 \
${CHIBIOS}/os/hal/platforms/STM32/TIMv1 \
diff --git a/os/various/chrtclib.c b/os/various/chrtclib.c
index f8a6a86ff..c8690c043 100644
--- a/os/various/chrtclib.c
+++ b/os/various/chrtclib.c
@@ -33,10 +33,11 @@
#include "chrtclib.h"
-#if (defined(STM32F4XX) || defined(STM32F2XX) || defined(STM32L1XX) || \
- defined(STM32F30X) || defined(STM32F37X) || \
- defined(STM32F1XX) || defined(STM32F10X_MD) || defined(STM32F10X_LD) || \
- defined(STM32F10X_HD) || defined(LPC122X) || defined(__DOXYGEN__))
+#if (defined(STM32F4XX) || defined(STM32F2XX) || defined(STM32L1XX) || \
+ defined(STM32F30X) || defined(STM32F37X) || \
+ defined(STM32F1XX) || defined(STM32F10X_MD) || defined(STM32F10X_LD) || \
+ defined(STM32F10X_HD) || defined(STM32F0XX) || defined(LPC122X) || \
+ defined(__DOXYGEN__))
#if STM32_RTC_IS_CALENDAR
/**
* @brief Converts from STM32 BCD to canonicalized time format.