diff options
Diffstat (limited to 'os/hal/platforms/STM32/RTCv2')
-rw-r--r-- | os/hal/platforms/STM32/RTCv2/rtc_lld.c | 27 | ||||
-rw-r--r-- | os/hal/platforms/STM32/RTCv2/rtc_lld.h | 15 |
2 files changed, 30 insertions, 12 deletions
diff --git a/os/hal/platforms/STM32/RTCv2/rtc_lld.c b/os/hal/platforms/STM32/RTCv2/rtc_lld.c index 3fdc7ceee..ca15dc1b9 100644 --- a/os/hal/platforms/STM32/RTCv2/rtc_lld.c +++ b/os/hal/platforms/STM32/RTCv2/rtc_lld.c @@ -185,12 +185,12 @@ void rtc_lld_get_time(RTCDriver *rtcp, RTCTime *timespec) { while(!(RTC->ISR & RTC_ISR_RSF))
;
- timespec->tv_time = RTCD1.id_rtc->TR;
- timespec->tv_date = RTCD1.id_rtc->DR;
#if STM32_RTC_HAS_SUBSECONDS
- timespec->tv_msec = ((RTCD1.id_rtc->PRER & 0x7FFF) - RTCD1.id_rtc->SSR) /
+ timespec->tv_msec = (1000 * (RTCD1.id_rtc->PRER & 0x7FFF) - RTCD1.id_rtc->SSR) /
((RTCD1.id_rtc->PRER & 0x7FFF) + 1);
#endif /* STM32_RTC_HAS_SUBSECONDS */
+ timespec->tv_time = RTCD1.id_rtc->TR;
+ timespec->tv_date = RTCD1.id_rtc->DR;
}
/**
@@ -297,26 +297,39 @@ void rtc_lld_get_periodic_wakeup(RTCDriver *rtcp, RTCWakeup *wakeupspec){ */
void rtc_lld_set_callback(RTCDriver *rtcp, RTCCallbackConfig *cb_cfg) {
- if (cb_cfg->cb_cfg & ALARMA_INT)
+ if (cb_cfg->cb_cfg & ALARMA_CB_FLAG)
rtcp->id_rtc->CR |= RTC_CR_ALRAIE;
else
rtcp->id_rtc->CR &= ~RTC_CR_ALRAIE;
- if (cb_cfg->cb_cfg & ALARMB_INT)
+ if (cb_cfg->cb_cfg & ALARMB_CB_FLAG)
rtcp->id_rtc->CR |= RTC_CR_ALRBIE;
else
rtcp->id_rtc->CR &= ~RTC_CR_ALRBIE;
- if (cb_cfg->cb_cfg & WAKEUP_INT)
+ if (cb_cfg->cb_cfg & WAKEUP_CB_FLAG)
rtcp->id_rtc->CR |= RTC_CR_WUTIE;
else
rtcp->id_rtc->CR &= ~RTC_CR_WUTIE;
- if (cb_cfg->cb_cfg & TIMESTAMP_INT)
+ if (cb_cfg->cb_cfg & TIMESTAMP_CB_FLAG)
rtcp->id_rtc->CR |= RTC_CR_TSIE;
else
rtcp->id_rtc->CR &= ~RTC_CR_TSIE;
}
+
+/**
+ * @brief Gets current RTC callbacks.
+ *
+ * @param[in] rtcp pointer to RTC driver structure
+ * @param[out] cb_cfg callback bitmask
+ *
+ * @notapi
+ */
+void rtc_lld_get_callback(RTCDriver *rtcp, RTCCallbackConfig *cb_cfg) {
+ cb_cfg->cb_cfg = rtcp->cb_cfg->cb_cfg;
+}
+
#endif /* RTC_SUPPORTS_CALLBACKS */
#endif /* HAL_USE_RTC */
diff --git a/os/hal/platforms/STM32/RTCv2/rtc_lld.h b/os/hal/platforms/STM32/RTCv2/rtc_lld.h index 8e1b58f6b..23ceb3132 100644 --- a/os/hal/platforms/STM32/RTCv2/rtc_lld.h +++ b/os/hal/platforms/STM32/RTCv2/rtc_lld.h @@ -48,12 +48,12 @@ #define RTC_ALARMS 2
/**
- * @brief Interrupt enable masks.
+ * @brief Callback enable masks.
*/
-#define ALARMA_INT 0x1
-#define ALARMB_INT 0x2
-#define WAKEUP_INT 0x4
-#define TIMESTAMP_INT 0x8
+#define ALARMA_CB_FLAG 0x1
+#define ALARMB_CB_FLAG 0x2
+#define WAKEUP_CB_FLAG 0x4
+#define TIMESTAMP_CB_FLAG 0x8
/*===========================================================================*/
/* Driver pre-compile time settings. */
@@ -158,6 +158,11 @@ struct RTCWakeup { /**
* @brief Structure representing an RTC callbacks config.
+ * @details It is bitmask. Set bit to enable callback, clear bit to disable.
+ * bit0 - alarmA
+ * bit1 - alarmB
+ * bit2 - wakeup
+ * bit3 - timestamp
*/
struct RTCCallbackConfig{
uint32_t cb_cfg;
|