diff options
author | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-09-29 17:44:23 +0000 |
---|---|---|
committer | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-09-29 17:44:23 +0000 |
commit | 71095fd300a131b65dfbe2bd7dc3d8fc40818f32 (patch) | |
tree | 361d73d22d92956fbb9fbde29e935da67c1d7343 /os/hal | |
parent | 3ffadedd4f8b3b38e9066c1970ec48515124cc30 (diff) | |
download | ChibiOS-71095fd300a131b65dfbe2bd7dc3d8fc40818f32.tar.gz ChibiOS-71095fd300a131b65dfbe2bd7dc3d8fc40818f32.tar.bz2 ChibiOS-71095fd300a131b65dfbe2bd7dc3d8fc40818f32.zip |
RTCv2. Add support for STM32F0xx.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@6331 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal')
-rw-r--r-- | os/hal/platforms/STM32/RTCv2/rtc_lld.c | 8 | ||||
-rw-r--r-- | os/hal/platforms/STM32/RTCv2/rtc_lld.h | 23 | ||||
-rw-r--r-- | os/hal/platforms/STM32F0xx/platform.mk | 2 |
3 files changed, 31 insertions, 2 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 \
|