RTC. API cnahge.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3376 35acf78f-673a-0410-8e92-d51de3d6d3f4master
parent
42e2ea515d
commit
95713cae20
|
@ -75,8 +75,7 @@ extern "C" {
|
|||
#endif /* RTC_SUPPORTS_CALLBACKS */
|
||||
|
||||
void rtcSetTime(uint32_t tv_sec);
|
||||
uint32_t rtcGetSec(void);
|
||||
uint16_t rtcGetMsec(void);
|
||||
uint32_t rtcGetTime(uint16_t *msec);
|
||||
void rtcSetAlarm(uint32_t tv_alarm);
|
||||
uint32_t rtcGetAlarm(void);
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -125,6 +125,7 @@ void rtc_lld_init(void){
|
|||
#if STM32_RTC == STM32_RTC_LSE
|
||||
if (! ((RCC->BDCR & RCC_BDCR_RTCEN) || (RCC->BDCR & RCC_BDCR_LSEON))){
|
||||
RCC->BDCR |= RCC_BDCR_LSEON;
|
||||
/* Note: cold start time of LSE oscillator on STM32 is about 3 seconds. */
|
||||
while(!(RCC->BDCR & RCC_BDCR_LSERDY))
|
||||
;
|
||||
RCC->BDCR |= RCC_BDCR_RTCEN;
|
||||
|
@ -262,23 +263,20 @@ void rtc_lld_set_time(uint32_t tv_sec){
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Return current time in UNIX notation.
|
||||
* @brief Return return seconds since UNIX epoch.
|
||||
*
|
||||
* @param[in] msec pointer to variable for storing fractional part of
|
||||
* time (milliseconds).
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
inline uint32_t rtc_lld_get_sec(void){
|
||||
return ((RTC->CNTH << 16) + RTC->CNTL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return fractional part of current time (milliseconds).
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
inline uint16_t rtc_lld_get_msec(void){
|
||||
inline uint32_t rtc_lld_get_time(uint16_t *msec){
|
||||
uint32_t time_frac = 0;
|
||||
time_frac = (((uint32_t)RTC->DIVH) << 16) + (RTC->DIVL);
|
||||
return(((STM32_LSECLK - time_frac) * 1000) / STM32_LSECLK);
|
||||
if(msec != NULL){
|
||||
time_frac = (((uint32_t)RTC->DIVH) << 16) + (RTC->DIVL);
|
||||
*msec = (uint16_t)(((STM32_LSECLK - time_frac) * 1000) / STM32_LSECLK);
|
||||
}
|
||||
return ((RTC->CNTH << 16) + RTC->CNTL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -100,8 +100,7 @@ extern "C" {
|
|||
void rtc_lld_set_callback(RTCDriver *rtcp, rtccb_t overflow_cb,
|
||||
rtccb_t second_cb, rtccb_t alarm_cb);
|
||||
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_time(uint16_t *msec);
|
||||
uint32_t rtc_lld_get_alarm(void);
|
||||
void rtc_lld_set_alarm(uint32_t);
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -90,17 +90,15 @@ void rtcSetTime(uint32_t tv_sec){
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Return current time in UNIX notation.
|
||||
* @brief Return return seconds since UNIX epoch.
|
||||
*
|
||||
* @param[in] msec pointer to variable for storing fractional part of
|
||||
* time (milliseconds).
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
inline uint32_t rtcGetSec(void){
|
||||
return rtc_lld_get_sec();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return fractional part of current time (milliseconds).
|
||||
*/
|
||||
inline uint16_t rtcGetMsec(void){
|
||||
return rtc_lld_get_msec();
|
||||
inline uint32_t rtcGetTime(uint16_t *msec){
|
||||
return rtc_lld_get_time(msec);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue