summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriabdalkader <i.abdalkader@gmail.com>2018-02-24 01:11:25 +0200
committerDamien George <damien.p.george@gmail.com>2018-03-09 15:12:29 +1100
commit711f817c2a6e9ac0321c93b44042d32482e7fdf3 (patch)
tree1356760c543c1167dc85d7d59fde1b54a9f43b2a
parent0e51e4d13986e7dc65eb6186253cc1812d966647 (diff)
stm32/rtc: Add RTC support for H7 MCUs.
-rw-r--r--ports/stm32/rtc.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/ports/stm32/rtc.c b/ports/stm32/rtc.c
index c0bc0f5b6..7e67b7c62 100644
--- a/ports/stm32/rtc.c
+++ b/ports/stm32/rtc.c
@@ -223,12 +223,16 @@ STATIC HAL_StatusTypeDef PYB_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruc
/*------------------------------ LSE Configuration -------------------------*/
if ((RCC_OscInitStruct->OscillatorType & RCC_OSCILLATORTYPE_LSE) == RCC_OSCILLATORTYPE_LSE) {
+ #if !defined(STM32H7)
// Enable Power Clock
__HAL_RCC_PWR_CLK_ENABLE();
+ #endif
+
+ // Enable access to the backup domain
HAL_PWR_EnableBkUpAccess();
uint32_t tickstart = HAL_GetTick();
- #if defined(MCU_SERIES_F7) || defined(MCU_SERIES_L4)
+ #if defined(MCU_SERIES_F7) || defined(MCU_SERIES_L4) || defined(STM32H7)
//__HAL_RCC_PWR_CLK_ENABLE();
// Enable write access to Backup domain
//PWR->CR1 |= PWR_CR1_DBP;
@@ -298,7 +302,7 @@ STATIC HAL_StatusTypeDef PYB_RTC_Init(RTC_HandleTypeDef *hrtc) {
// Exit Initialization mode
hrtc->Instance->ISR &= (uint32_t)~RTC_ISR_INIT;
- #if defined(MCU_SERIES_L4)
+ #if defined(MCU_SERIES_L4) || defined(STM32H7)
hrtc->Instance->OR &= (uint32_t)~RTC_OR_ALARMOUTTYPE;
hrtc->Instance->OR |= (uint32_t)(hrtc->Init.OutPutType);
#elif defined(MCU_SERIES_F7)
@@ -634,6 +638,9 @@ mp_obj_t pyb_rtc_wakeup(size_t n_args, const mp_obj_t *args) {
#if defined(MCU_SERIES_L4)
EXTI->IMR1 |= 1 << 22;
EXTI->RTSR1 |= 1 << 22;
+ #elif defined(STM32H7)
+ EXTI_D1->IMR1 |= 1 << 22;
+ EXTI->RTSR1 |= 1 << 22;
#else
EXTI->IMR |= 1 << 22;
EXTI->RTSR |= 1 << 22;
@@ -643,6 +650,8 @@ mp_obj_t pyb_rtc_wakeup(size_t n_args, const mp_obj_t *args) {
RTC->ISR &= ~(1 << 10);
#if defined(MCU_SERIES_L4)
EXTI->PR1 = 1 << 22;
+ #elif defined(STM32H7)
+ EXTI_D1->PR1 = 1 << 22;
#else
EXTI->PR = 1 << 22;
#endif
@@ -661,6 +670,8 @@ mp_obj_t pyb_rtc_wakeup(size_t n_args, const mp_obj_t *args) {
// disable external interrupts on line 22
#if defined(MCU_SERIES_L4)
EXTI->IMR1 &= ~(1 << 22);
+ #elif defined(STM32H7)
+ EXTI_D1->IMR1 |= 1 << 22;
#else
EXTI->IMR &= ~(1 << 22);
#endif