From 3384cea281b41d75f6c472cde8fc1a6140f53af0 Mon Sep 17 00:00:00 2001 From: jeromecoutant Date: Wed, 27 Feb 2019 14:59:23 +0100 Subject: [PATCH 1/5] STM32H7 : add LSI --- .../TARGET_STM32H7/device/stm32h7xx_hal_conf.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/targets/TARGET_STM/TARGET_STM32H7/device/stm32h7xx_hal_conf.h b/targets/TARGET_STM/TARGET_STM32H7/device/stm32h7xx_hal_conf.h index a883705f06..7c392f306e 100644 --- a/targets/TARGET_STM/TARGET_STM32H7/device/stm32h7xx_hal_conf.h +++ b/targets/TARGET_STM/TARGET_STM32H7/device/stm32h7xx_hal_conf.h @@ -121,6 +121,15 @@ #define HSI_VALUE ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/ #endif /* HSI_VALUE */ +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature. */ + /** * @brief External Low Speed oscillator (LSE) value. * This value is used by the UART, RTC HAL module to compute the system frequency From da9b919268d1af52078114ec5dba6a1a4fbb3fbd Mon Sep 17 00:00:00 2001 From: jeromecoutant Date: Wed, 27 Feb 2019 15:00:14 +0100 Subject: [PATCH 2/5] STM32H7: Increase watchdog timeout value --- .../TARGET_STM/TARGET_STM32H7/device/stm32h7xx_hal_iwdg.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32H7/device/stm32h7xx_hal_iwdg.c b/targets/TARGET_STM/TARGET_STM32H7/device/stm32h7xx_hal_iwdg.c index 39e041efd3..1ff788b021 100644 --- a/targets/TARGET_STM/TARGET_STM32H7/device/stm32h7xx_hal_iwdg.c +++ b/targets/TARGET_STM/TARGET_STM32H7/device/stm32h7xx_hal_iwdg.c @@ -109,10 +109,8 @@ /** @defgroup IWDG_Private_Defines IWDG Private Defines * @{ */ -/* Status register need 5 RC LSI divided by prescaler clock to be updated. With - higher prescaler (256), and according to LSI variation, we need to wait at - least 6 cycles so 48 ms. */ -#define HAL_IWDG_DEFAULT_TIMEOUT 48u +/* MBED */ +#define HAL_IWDG_DEFAULT_TIMEOUT 96u /** * @} */ From aa31b1268aa2fb1bb5ff793a4a4762dbfcab1d64 Mon Sep 17 00:00:00 2001 From: jeromecoutant Date: Wed, 27 Feb 2019 15:01:20 +0100 Subject: [PATCH 3/5] STM32H7 watchdog patch --- targets/TARGET_STM/TARGET_STM32H7/objects.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/targets/TARGET_STM/TARGET_STM32H7/objects.h b/targets/TARGET_STM/TARGET_STM32H7/objects.h index 5cbd0ed911..2a6e60dba6 100644 --- a/targets/TARGET_STM/TARGET_STM32H7/objects.h +++ b/targets/TARGET_STM/TARGET_STM32H7/objects.h @@ -170,6 +170,9 @@ struct can_s { #define RCC_LPUART1CLKSOURCE_PCLK1 RCC_LPUART1CLKSOURCE_PLL2 #define RCC_LPUART1CLKSOURCE_SYSCLK RCC_LPUART1CLKSOURCE_D3PCLK1 +/* watchdog_api.c */ +#define IWDG IWDG1 + #ifdef __cplusplus } #endif From 8b6d0920a8df97e00e84c54cb521ed6d177b5662 Mon Sep 17 00:00:00 2001 From: jeromecoutant Date: Wed, 27 Feb 2019 15:03:10 +0100 Subject: [PATCH 4/5] STM32H7: Reset Reason update --- targets/TARGET_STM/reset_reason.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/targets/TARGET_STM/reset_reason.c b/targets/TARGET_STM/reset_reason.c index 6772c34ebc..b73d1f1869 100644 --- a/targets/TARGET_STM/reset_reason.c +++ b/targets/TARGET_STM/reset_reason.c @@ -27,18 +27,36 @@ reset_reason_t hal_reset_reason_get(void) } #endif +#ifdef RCC_FLAG_LPWR1RST + if ((__HAL_RCC_GET_FLAG(RCC_FLAG_LPWR1RST))||(__HAL_RCC_GET_FLAG(RCC_FLAG_LPWR2RST))) { + return RESET_REASON_WAKE_LOW_POWER; + } +#endif + #ifdef RCC_FLAG_WWDGRST if (__HAL_RCC_GET_FLAG(RCC_FLAG_WWDGRST)) { return RESET_REASON_WATCHDOG; } #endif +#ifdef RCC_FLAG_WWDG1RST + if (__HAL_RCC_GET_FLAG(RCC_FLAG_WWDG1RST)) { + return RESET_REASON_WATCHDOG; + } +#endif + #ifdef RCC_FLAG_IWDGRST if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST)) { return RESET_REASON_WATCHDOG; } #endif +#ifdef RCC_FLAG_IWDG1RST + if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDG1RST)) { + return RESET_REASON_WATCHDOG; + } +#endif + #ifdef RCC_FLAG_SFTRST if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST)) { return RESET_REASON_SOFTWARE; @@ -69,7 +87,11 @@ reset_reason_t hal_reset_reason_get(void) uint32_t hal_reset_reason_get_raw(void) { +#if TARGET_STM32H7 + return RCC->RSR; +#else /* TARGET_STM32H7 */ return RCC->CSR; +#endif /* TARGET_STM32H7 */ } From 923be9e20ef2134c9349f2dd3e782423e5c0f38b Mon Sep 17 00:00:00 2001 From: jeromecoutant Date: Wed, 27 Feb 2019 15:08:31 +0100 Subject: [PATCH 5/5] NUCLEO_H743ZI: enable WATCHDOG back --- targets/targets.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/targets/targets.json b/targets/targets.json index 6622d00b15..af93e7a705 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -3227,8 +3227,7 @@ ], "release_versions": ["2", "5"], "device_name": "STM32H743ZI", - "bootloader_supported": true, - "device_has_remove": ["WATCHDOG"] + "bootloader_supported": true }, "NUCLEO_H743ZI2": { "inherits": ["NUCLEO_H743ZI"],