Skip to content

Commit bd762ce

Browse files
authored
Merge pull request ARMmbed#10466 from jeromecoutant/PR_STM32H7_WATCHDOG
STM32H7: WATCHDOG and RESET_REASON support
2 parents 1c91d03 + 923be9e commit bd762ce

File tree

5 files changed

+37
-6
lines changed

5 files changed

+37
-6
lines changed

targets/TARGET_STM/TARGET_STM32H7/device/stm32h7xx_hal_conf.h

+9
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@
121121
#define HSI_VALUE ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/
122122
#endif /* HSI_VALUE */
123123

124+
/**
125+
* @brief Internal Low Speed oscillator (LSI) value.
126+
*/
127+
#if !defined (LSI_VALUE)
128+
#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/
129+
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
130+
The real value may vary depending on the variations
131+
in voltage and temperature. */
132+
124133
/**
125134
* @brief External Low Speed oscillator (LSE) value.
126135
* This value is used by the UART, RTC HAL module to compute the system frequency

targets/TARGET_STM/TARGET_STM32H7/device/stm32h7xx_hal_iwdg.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,8 @@
109109
/** @defgroup IWDG_Private_Defines IWDG Private Defines
110110
* @{
111111
*/
112-
/* Status register need 5 RC LSI divided by prescaler clock to be updated. With
113-
higher prescaler (256), and according to LSI variation, we need to wait at
114-
least 6 cycles so 48 ms. */
115-
#define HAL_IWDG_DEFAULT_TIMEOUT 48u
112+
/* MBED */
113+
#define HAL_IWDG_DEFAULT_TIMEOUT 96u
116114
/**
117115
* @}
118116
*/

targets/TARGET_STM/TARGET_STM32H7/objects.h

+3
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ struct can_s {
170170
#define RCC_LPUART1CLKSOURCE_PCLK1 RCC_LPUART1CLKSOURCE_PLL2
171171
#define RCC_LPUART1CLKSOURCE_SYSCLK RCC_LPUART1CLKSOURCE_D3PCLK1
172172

173+
/* watchdog_api.c */
174+
#define IWDG IWDG1
175+
173176
#ifdef __cplusplus
174177
}
175178
#endif

targets/TARGET_STM/reset_reason.c

+22
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,36 @@ reset_reason_t hal_reset_reason_get(void)
2727
}
2828
#endif
2929

30+
#ifdef RCC_FLAG_LPWR1RST
31+
if ((__HAL_RCC_GET_FLAG(RCC_FLAG_LPWR1RST))||(__HAL_RCC_GET_FLAG(RCC_FLAG_LPWR2RST))) {
32+
return RESET_REASON_WAKE_LOW_POWER;
33+
}
34+
#endif
35+
3036
#ifdef RCC_FLAG_WWDGRST
3137
if (__HAL_RCC_GET_FLAG(RCC_FLAG_WWDGRST)) {
3238
return RESET_REASON_WATCHDOG;
3339
}
3440
#endif
3541

42+
#ifdef RCC_FLAG_WWDG1RST
43+
if (__HAL_RCC_GET_FLAG(RCC_FLAG_WWDG1RST)) {
44+
return RESET_REASON_WATCHDOG;
45+
}
46+
#endif
47+
3648
#ifdef RCC_FLAG_IWDGRST
3749
if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST)) {
3850
return RESET_REASON_WATCHDOG;
3951
}
4052
#endif
4153

54+
#ifdef RCC_FLAG_IWDG1RST
55+
if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDG1RST)) {
56+
return RESET_REASON_WATCHDOG;
57+
}
58+
#endif
59+
4260
#ifdef RCC_FLAG_SFTRST
4361
if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST)) {
4462
return RESET_REASON_SOFTWARE;
@@ -69,7 +87,11 @@ reset_reason_t hal_reset_reason_get(void)
6987

7088
uint32_t hal_reset_reason_get_raw(void)
7189
{
90+
#if TARGET_STM32H7
91+
return RCC->RSR;
92+
#else /* TARGET_STM32H7 */
7293
return RCC->CSR;
94+
#endif /* TARGET_STM32H7 */
7395
}
7496

7597

targets/targets.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -3227,8 +3227,7 @@
32273227
],
32283228
"release_versions": ["2", "5"],
32293229
"device_name": "STM32H743ZI",
3230-
"bootloader_supported": true,
3231-
"device_has_remove": ["WATCHDOG"]
3230+
"bootloader_supported": true
32323231
},
32333232
"NUCLEO_H743ZI2": {
32343233
"inherits": ["NUCLEO_H743ZI"],

0 commit comments

Comments
 (0)