RTCv2. Add support for STM32F0xx.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@6331 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
3ffadedd4f
commit
71095fd300
|
@ -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.
|
||||
|
|
|
@ -36,9 +36,22 @@
|
|||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Two alarm comparators available on STM32F4x.
|
||||
* @brief Two alarm comparators available on STM32F4x and STM32F2x.
|
||||
*/
|
||||
#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
|
||||
}
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -36,7 +36,8 @@
|
|||
#if (defined(STM32F4XX) || defined(STM32F2XX) || defined(STM32L1XX) || \
|
||||
defined(STM32F30X) || defined(STM32F37X) || \
|
||||
defined(STM32F1XX) || defined(STM32F10X_MD) || defined(STM32F10X_LD) || \
|
||||
defined(STM32F10X_HD) || defined(LPC122X) || defined(__DOXYGEN__))
|
||||
defined(STM32F10X_HD) || defined(STM32F0XX) || defined(LPC122X) || \
|
||||
defined(__DOXYGEN__))
|
||||
#if STM32_RTC_IS_CALENDAR
|
||||
/**
|
||||
* @brief Converts from STM32 BCD to canonicalized time format.
|
||||
|
|
|
@ -47,22 +47,6 @@ static RTCWakeup wakeupspec;
|
|||
static RTCAlarm alarmspec;
|
||||
static time_t unix_time;
|
||||
|
||||
/* libc stub */
|
||||
int _getpid(void) {return 1;}
|
||||
/* libc stub */
|
||||
void _exit(int i) {(void)i;}
|
||||
/* libc stub */
|
||||
#include <errno.h>
|
||||
#undef errno
|
||||
extern int errno;
|
||||
int _kill(int pid, int sig) {
|
||||
(void)pid;
|
||||
(void)sig;
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* sleep indicator thread */
|
||||
static WORKING_AREA(blinkWA, 128);
|
||||
static msg_t blink_thd(void *arg){
|
||||
|
|
Loading…
Reference in New Issue