Commit 432465b1 authored by Tobias Badertscher's avatar Tobias Badertscher Committed by Damien George

stmhal: L4: Modify rtc.c to support L4 MCU.

parent aed1da91
...@@ -190,7 +190,11 @@ void rtc_init_finalise() { ...@@ -190,7 +190,11 @@ void rtc_init_finalise() {
// fresh reset; configure RTC Calendar // fresh reset; configure RTC Calendar
RTC_CalendarConfig(); RTC_CalendarConfig();
#if defined(MCU_SERIES_L4)
if(__HAL_RCC_GET_FLAG(RCC_FLAG_BORRST) != RESET) {
#else
if(__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET) { if(__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET) {
#endif
// power on reset occurred // power on reset occurred
rtc_info |= 0x10000; rtc_info |= 0x10000;
} }
...@@ -223,7 +227,7 @@ STATIC HAL_StatusTypeDef PYB_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruc ...@@ -223,7 +227,7 @@ STATIC HAL_StatusTypeDef PYB_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruc
HAL_PWR_EnableBkUpAccess(); HAL_PWR_EnableBkUpAccess();
uint32_t tickstart = HAL_GetTick(); uint32_t tickstart = HAL_GetTick();
#if defined(MCU_SERIES_F7) #if defined(MCU_SERIES_F7) || defined(MCU_SERIES_L4)
//__HAL_RCC_PWR_CLK_ENABLE(); //__HAL_RCC_PWR_CLK_ENABLE();
// Enable write access to Backup domain // Enable write access to Backup domain
//PWR->CR1 |= PWR_CR1_DBP; //PWR->CR1 |= PWR_CR1_DBP;
...@@ -293,7 +297,10 @@ STATIC HAL_StatusTypeDef PYB_RTC_Init(RTC_HandleTypeDef *hrtc) { ...@@ -293,7 +297,10 @@ STATIC HAL_StatusTypeDef PYB_RTC_Init(RTC_HandleTypeDef *hrtc) {
// Exit Initialization mode // Exit Initialization mode
hrtc->Instance->ISR &= (uint32_t)~RTC_ISR_INIT; hrtc->Instance->ISR &= (uint32_t)~RTC_ISR_INIT;
#if defined(MCU_SERIES_F7) #if defined(MCU_SERIES_L4)
hrtc->Instance->OR &= (uint32_t)~RTC_OR_ALARMOUTTYPE;
hrtc->Instance->OR |= (uint32_t)(hrtc->Init.OutPutType);
#elif defined(MCU_SERIES_F7)
hrtc->Instance->OR &= (uint32_t)~RTC_OR_ALARMTYPE; hrtc->Instance->OR &= (uint32_t)~RTC_OR_ALARMTYPE;
hrtc->Instance->OR |= (uint32_t)(hrtc->Init.OutPutType); hrtc->Instance->OR |= (uint32_t)(hrtc->Init.OutPutType);
#else #else
...@@ -619,12 +626,21 @@ mp_obj_t pyb_rtc_wakeup(mp_uint_t n_args, const mp_obj_t *args) { ...@@ -619,12 +626,21 @@ mp_obj_t pyb_rtc_wakeup(mp_uint_t n_args, const mp_obj_t *args) {
RTC->WPR = 0xff; RTC->WPR = 0xff;
// enable external interrupts on line 22 // enable external interrupts on line 22
#if defined(MCU_SERIES_L4)
EXTI->IMR1 |= 1 << 22;
EXTI->RTSR1 |= 1 << 22;
#else
EXTI->IMR |= 1 << 22; EXTI->IMR |= 1 << 22;
EXTI->RTSR |= 1 << 22; EXTI->RTSR |= 1 << 22;
#endif
// clear interrupt flags // clear interrupt flags
RTC->ISR &= ~(1 << 10); RTC->ISR &= ~(1 << 10);
#if defined(MCU_SERIES_L4)
EXTI->PR1 = 1 << 22;
#else
EXTI->PR = 1 << 22; EXTI->PR = 1 << 22;
#endif
HAL_NVIC_SetPriority(RTC_WKUP_IRQn, IRQ_PRI_RTC_WKUP, IRQ_SUBPRI_RTC_WKUP); HAL_NVIC_SetPriority(RTC_WKUP_IRQn, IRQ_PRI_RTC_WKUP, IRQ_SUBPRI_RTC_WKUP);
HAL_NVIC_EnableIRQ(RTC_WKUP_IRQn); HAL_NVIC_EnableIRQ(RTC_WKUP_IRQn);
...@@ -638,7 +654,11 @@ mp_obj_t pyb_rtc_wakeup(mp_uint_t n_args, const mp_obj_t *args) { ...@@ -638,7 +654,11 @@ mp_obj_t pyb_rtc_wakeup(mp_uint_t n_args, const mp_obj_t *args) {
RTC->WPR = 0xff; RTC->WPR = 0xff;
// disable external interrupts on line 22 // disable external interrupts on line 22
#if defined(MCU_SERIES_L4)
EXTI->IMR1 &= ~(1 << 22);
#else
EXTI->IMR &= ~(1 << 22); EXTI->IMR &= ~(1 << 22);
#endif
} }
return mp_const_none; return mp_const_none;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment