diff options
author | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-08-31 09:34:42 +0000 |
---|---|---|
committer | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-08-31 09:34:42 +0000 |
commit | 2991a477339a28ec275647930df45443a9f8a253 (patch) | |
tree | 890599d15666a88ba081f93bd7fb7742ba586334 /os/hal/platforms | |
parent | 22d2162db773e677c900b8b397889b7087470248 (diff) | |
download | ChibiOS-2991a477339a28ec275647930df45443a9f8a253.tar.gz ChibiOS-2991a477339a28ec275647930df45443a9f8a253.tar.bz2 ChibiOS-2991a477339a28ec275647930df45443a9f8a253.zip |
RTC. nop
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/rtc_dev@3270 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms')
-rw-r--r-- | os/hal/platforms/STM32/rtc_lld.c | 28 | ||||
-rw-r--r-- | os/hal/platforms/STM32/rtc_lld.h | 7 |
2 files changed, 25 insertions, 10 deletions
diff --git a/os/hal/platforms/STM32/rtc_lld.c b/os/hal/platforms/STM32/rtc_lld.c index 4af863005..80f0185ba 100644 --- a/os/hal/platforms/STM32/rtc_lld.c +++ b/os/hal/platforms/STM32/rtc_lld.c @@ -48,6 +48,7 @@ register must be set to 1 (refer to Section 4.4.1: Power control register /* Driver exported variables. */
/*===========================================================================*/
+/** @brief RTC driver identifier.*/
RTCDriver RTCD;
@@ -69,15 +70,21 @@ RTCDriver RTCD; static void rtc_lld_serve_interrupt(RTCDriver *rtcp){
chSysLockFromIsr();
//TODO: do not forget to reset flags manually
- if (RTC->CRL & RTC_CRL_SECF){
+ if ((RTC->CRH & RTC_CRH_SECIE) && \
+ (RTC->CRL & RTC_CRL_SECF) && \
+ (rtcp->config->second_cb != NULL)){
rtcp->config->second_cb(rtcp);
RTC->CRL &= ~RTC_CRL_SECF;
}
- if (RTC->CRL & RTC_CRL_ALRF){
+ if ((RTC->CRH & RTC_CRH_ALRIE) && \
+ (RTC->CRL & RTC_CRL_ALRF) && \
+ (rtcp->config->alarm_cb != NULL)){
rtcp->config->alarm_cb(rtcp);
RTC->CRL &= ~RTC_CRL_ALRF;
}
- if (RTC->CRL & RTC_CRL_OWF){
+ if ((RTC->CRH & RTC_CRH_OWIE) && \
+ (RTC->CRL & RTC_CRL_OWF) && \
+ (rtcp->config->overflow_cb != NULL)){
rtcp->config->overflow_cb(rtcp);
RTC->CRL &= ~RTC_CRL_OWF;
}
@@ -128,6 +135,8 @@ void rtc_lld_init(void){ RTC->CRL &= ~(RTC_CRL_RSF);
while (!(RTC->CRL & RTC_CRL_RSF))
;
+
+ RTCD.config = NULL;
}
/**
@@ -137,23 +146,24 @@ void rtc_lld_init(void){ * @param[in] rtccfgp pointer to a @p RTCDriver config object
*/
#if RTC_SUPPORTS_CALLBACKS
-void rtc_lld_start(RTCDriver *rtcp, RTCConfig *rtccfgp){
- uint16_t flags = 0;
+void rtc_lld_start(RTCDriver *rtcp, const RTCConfig *rtccfgp){
+ uint16_t isr_flags = 0;
NVICEnableVector(RTC_IRQn, CORTEX_PRIORITY_MASK(STM32_RTC_IRQ_PRIORITY));
rtcp->config = rtccfgp;
if (rtcp->config->overflow_cb != NULL){
- flags |= RTC_CRH_OWIE;
+ isr_flags |= RTC_CRH_OWIE;
}
if (rtcp->config->alarm_cb != NULL){
- flags |= RTC_CRH_ALRIE;
+ isr_flags |= RTC_CRH_ALRIE;
}
if (rtcp->config->second_cb != NULL){
- flags |= RTC_CRH_SECIE;
+ isr_flags |= RTC_CRH_SECIE;
}
- RTC->CRH |= flags;
+ RTC->CRL &= ~(RTC_CRL_SECF | RTC_CRL_ALRF | RTC_CRL_OWF); /* clear all even flags*/
+ RTC->CRH |= isr_flags;
}
/**
diff --git a/os/hal/platforms/STM32/rtc_lld.h b/os/hal/platforms/STM32/rtc_lld.h index cf18b664c..f26315784 100644 --- a/os/hal/platforms/STM32/rtc_lld.h +++ b/os/hal/platforms/STM32/rtc_lld.h @@ -78,17 +78,22 @@ struct RTCDriver{ /* External declarations. */
/*===========================================================================*/
+extern RTCDriver RTCD;
+
+
#ifdef __cplusplus
extern "C" {
#endif
void rtc_lld_init(void);
#if RTC_SUPPORTS_CALLBACKS
- void rtc_lld_start(RTCDriver *rtcp, RTCConfig *rtccfgp);
+ void rtc_lld_start(RTCDriver *rtcp, const RTCConfig *rtccfgp);
void rtc_lld_stop(void);
#endif /* RTC_SUPPORTS_CALLBACKS */
void rtc_lld_set_time(uint32_t tv_sec);
uint32_t rtc_lld_get_sec(void);
uint16_t rtc_lld_get_msec(void);
+ uint32_t rtc_lld_get_alarm(void);
+ void rtc_lld_set_alarm(uint32_t);
#ifdef __cplusplus
}
#endif
|