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

pull/1920/merge
Tobias Badertscher 2016-03-22 16:56:28 +01:00 zatwierdzone przez Damien George
rodzic aed1da913b
commit 432465b167
1 zmienionych plików z 22 dodań i 2 usunięć

Wyświetl plik

@ -190,7 +190,11 @@ void rtc_init_finalise() {
// fresh reset; configure RTC Calendar
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) {
#endif
// power on reset occurred
rtc_info |= 0x10000;
}
@ -223,7 +227,7 @@ STATIC HAL_StatusTypeDef PYB_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruc
HAL_PWR_EnableBkUpAccess();
uint32_t tickstart = HAL_GetTick();
#if defined(MCU_SERIES_F7)
#if defined(MCU_SERIES_F7) || defined(MCU_SERIES_L4)
//__HAL_RCC_PWR_CLK_ENABLE();
// Enable write access to Backup domain
//PWR->CR1 |= PWR_CR1_DBP;
@ -293,7 +297,10 @@ STATIC HAL_StatusTypeDef PYB_RTC_Init(RTC_HandleTypeDef *hrtc) {
// Exit Initialization mode
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)(hrtc->Init.OutPutType);
#else
@ -619,12 +626,21 @@ mp_obj_t pyb_rtc_wakeup(mp_uint_t n_args, const mp_obj_t *args) {
RTC->WPR = 0xff;
// 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->RTSR |= 1 << 22;
#endif
// clear interrupt flags
RTC->ISR &= ~(1 << 10);
#if defined(MCU_SERIES_L4)
EXTI->PR1 = 1 << 22;
#else
EXTI->PR = 1 << 22;
#endif
HAL_NVIC_SetPriority(RTC_WKUP_IRQn, IRQ_PRI_RTC_WKUP, IRQ_SUBPRI_RTC_WKUP);
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) {
RTC->WPR = 0xff;
// disable external interrupts on line 22
#if defined(MCU_SERIES_L4)
EXTI->IMR1 &= ~(1 << 22);
#else
EXTI->IMR &= ~(1 << 22);
#endif
}
return mp_const_none;