mirror of https://github.com/rusefi/ChibiOS.git
RTC. nop
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/rtc_dev@3270 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
22d2162db7
commit
2991a47733
|
@ -59,7 +59,7 @@ extern "C" {
|
|||
#endif
|
||||
void rtcInit(void);
|
||||
#if RTC_SUPPORTS_CALLBACKS
|
||||
void rtcStart(RTCDriver *rtcp, RTCConfig *rtccfgp);
|
||||
void rtcStart(RTCDriver *rtcp, const RTCConfig *rtccfgp);
|
||||
void rtcStop(void);
|
||||
#endif /* RTC_SUPPORTS_CALLBACKS */
|
||||
void rtcSetTime(uint32_t tv_sec);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
|
||||
#include "rtc_lld.h"
|
||||
|
||||
#if HAL_USE_RTC || defined(__DOXYGEN__)
|
||||
|
||||
|
@ -45,7 +46,7 @@ void rtcInit(void){
|
|||
* @param[in] rtcp - pointer to RTC driver structure.
|
||||
* @param[in] rtccfgp - pointer to RTC config structure.
|
||||
*/
|
||||
void rtcStart(RTCDriver *rtcp, RTCConfig *rtccfgp){
|
||||
void rtcStart(RTCDriver *rtcp, const RTCConfig *rtccfgp){
|
||||
chDbgCheck(((rtcp != NULL) && (rtccfgp != NULL)), "rtcStart");
|
||||
rtc_lld_start(rtcp, rtccfgp);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue