1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/stm32-common: add RTC support to stm32l0

Signed-off-by: joris <laborde.joris@gmail.com>
This commit is contained in:
joris 2017-06-02 20:03:09 +02:00
parent 3cdb92aaf4
commit 6a5da1c1f7

View File

@ -27,7 +27,8 @@
#if defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F2) || \
defined(CPU_FAM_STM32F3) || defined(CPU_FAM_STM32F4) || \
defined(CPU_FAM_STM32F7) || defined(CPU_FAM_STM32L1)
defined(CPU_FAM_STM32F7) || defined(CPU_FAM_STM32L0) || \
defined(CPU_FAM_STM32L1)
/* guard file in case no RTC device was specified */
#if RTC_NUMOF
@ -65,7 +66,7 @@ void rtc_init(void)
PWR->CR |= PWR_CR_DBP;
#endif
#if defined(CPU_FAM_STM32L1)
#if defined(CPU_FAM_STM32L1) || defined(CPU_FAM_STM32L0)
if (!(RCC->CSR & RCC_CSR_RTCEN)) {
#else
if (!(RCC->BDCR & RCC_BDCR_RTCEN)) {
@ -192,9 +193,15 @@ int rtc_set_alarm(struct tm *time, rtc_alarm_cb_t cb, void *arg)
/* Enable RTC write protection */
RTC->WPR = 0xFF;
#if defined(CPU_FAM_STM32L0)
EXTI->IMR |= EXTI_IMR_IM17;
#else
EXTI->IMR |= EXTI_IMR_MR17;
#endif
EXTI->RTSR |= EXTI_RTSR_TR17;
#if defined(CPU_FAM_STM32F0)
#if defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32L0)
NVIC_SetPriority(RTC_IRQn, 10);
NVIC_EnableIRQ(RTC_IRQn);
#else
@ -235,7 +242,7 @@ void rtc_clear_alarm(void)
void rtc_poweron(void)
{
#if defined(CPU_FAM_STM32L1)
#if defined(CPU_FAM_STM32L1) || defined(CPU_FAM_STM32L0)
/* Reset RTC domain */
RCC->CSR |= RCC_CSR_RTCRST;
RCC->CSR &= ~(RCC_CSR_RTCRST);
@ -274,7 +281,7 @@ void rtc_poweron(void)
void rtc_poweroff(void)
{
#if defined(CPU_FAM_STM32L1)
#if defined(CPU_FAM_STM32L1) || defined(CPU_FAM_STM32L0)
/* Reset RTC domain */
RCC->CSR |= RCC_CSR_RTCRST;
RCC->CSR &= ~(RCC_CSR_RTCRST);
@ -293,7 +300,7 @@ void rtc_poweroff(void)
#endif
}
#if defined(CPU_FAM_STM32F0)
#if defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32L0)
void isr_rtc(void)
#else
void isr_rtc_alarm(void)
@ -331,4 +338,5 @@ static uint8_t byte2bcd(uint8_t value)
#endif /* defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F2) || \
defined(CPU_FAM_STM32F3) || defined(CPU_FAM_STM32F4) || \
defined(CPU_FAM_STM32F7) || defined(CPU_FAM_STM32L1) */
defined(CPU_FAM_STM32F7) || defined(CPU_FAM_STM32L0) || \
defined(CPU_FAM_STM32L1) */