Skip to content

Commit a8ce516

Browse files
committed
targets: DISCO_H747I add support of MBED_TICKLESS
1 parent a183033 commit a8ce516

File tree

4 files changed

+53
-26
lines changed

4 files changed

+53
-26
lines changed

targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/h747i_sleep.c

Lines changed: 0 additions & 23 deletions
This file was deleted.

targets/TARGET_STM/lp_ticker.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@
6767
#define LPTIM_MST_IRQ LPTIM4_IRQn
6868
#define LPTIM_MST_RCC __HAL_RCC_LPTIM4_CLK_ENABLE
6969

70+
#define LPTIM_MST_RCC_CLKAM __HAL_RCC_LPTIM4_CLKAM_ENABLE
71+
72+
/* Enable LPTIM wakeup source but only for current core, and disable it for the other core */
73+
#define LPTIM_MST_EXTI_LPTIM_WAKEUP_CONFIG() {\
74+
HAL_EXTI_D1_EventInputConfig(EXTI_LINE52, EXTI_MODE_IT, ENABLE);\
75+
HAL_EXTI_D2_EventInputConfig(EXTI_LINE52, EXTI_MODE_IT, DISABLE);\
76+
}
7077
#define LPTIM_MST_RESET_ON __HAL_RCC_LPTIM4_FORCE_RESET
7178
#define LPTIM_MST_RESET_OFF __HAL_RCC_LPTIM4_RELEASE_RESET
7279

@@ -85,6 +92,13 @@
8592
#define LPTIM_MST_IRQ LPTIM5_IRQn
8693
#define LPTIM_MST_RCC __HAL_RCC_LPTIM5_CLK_ENABLE
8794

95+
#define LPTIM_MST_RCC_CLKAM __HAL_RCC_LPTIM5_CLKAM_ENABLE
96+
97+
/* Enable LPTIM wakeup source but only for current core, and disable it for the other core */
98+
#define LPTIM_MST_EXTI_LPTIM_WAKEUP_CONFIG() {\
99+
HAL_EXTI_D2_EventInputConfig(EXTI_LINE53, EXTI_MODE_IT, ENABLE);\
100+
HAL_EXTI_D1_EventInputConfig(EXTI_LINE53, EXTI_MODE_IT, DISABLE);\
101+
}
88102
#define LPTIM_MST_RESET_ON __HAL_RCC_LPTIM5_FORCE_RESET
89103
#define LPTIM_MST_RESET_OFF __HAL_RCC_LPTIM5_RELEASE_RESET
90104
#else
@@ -209,6 +223,10 @@ void lp_ticker_init(void)
209223
LPTIM_MST_RESET_ON();
210224
LPTIM_MST_RESET_OFF();
211225
#if defined(DUAL_CORE)
226+
/* Configure EXTI wakeup and configure autonomous mode */
227+
LPTIM_MST_RCC_CLKAM();
228+
LPTIM_MST_EXTI_LPTIM_WAKEUP_CONFIG();
229+
212230
LL_HSEM_ReleaseLock(HSEM, CFG_HW_RCC_SEMID, HSEM_CR_COREID_CURRENT);
213231
#endif /* DUAL_CORE */
214232

targets/TARGET_STM/sleep.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,25 @@ __WEAK void hal_deepsleep(void)
204204
if (!pwrClockEnabled) {
205205
__HAL_RCC_PWR_CLK_DISABLE();
206206
}
207+
#elif defined(DUAL_CORE)
208+
int lowPowerModeEnabled = LL_PWR_GetRegulModeDS();
209+
210+
#if defined(CORE_CM7)
211+
HAL_PWREx_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI, PWR_D3_DOMAIN);
212+
HAL_PWREx_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI, PWR_D1_DOMAIN);
213+
214+
#elif defined(CORE_CM4)
215+
HAL_PWREx_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI, PWR_D3_DOMAIN);
216+
HAL_PWREx_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI, PWR_D2_DOMAIN);
217+
218+
#else
219+
#error "Wrong Core selection"
220+
#endif /* CORE_CM7 */
221+
222+
if (lowPowerModeEnabled) {
223+
LL_PWR_SetRegulModeDS(lowPowerModeEnabled);
224+
}
225+
207226
#else /* PWR_CR1_LPMS_STOP2 */
208227
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
209228
#endif /* PWR_CR1_LPMS_STOP2 */
@@ -220,8 +239,19 @@ __WEAK void hal_deepsleep(void)
220239
ForceOscOutofDeepSleep();
221240
ForcePeriphOutofDeepSleep();
222241

223-
// After wake-up from STOP reconfigure the PLL
242+
/* After wake-up from STOP reconfigure the PLL */
243+
#if defined(DUAL_CORE)
244+
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID)) {
245+
}
246+
247+
if ((LL_RCC_GetSysClkSource() == LL_RCC_SYS_CLKSOURCE_STATUS_HSI)) {
248+
LL_PWR_ClearFlag_CPU();
249+
SetSysClock();
250+
}
251+
LL_HSEM_ReleaseLock(HSEM, CFG_HW_RCC_SEMID, HSEM_CR_COREID_CURRENT);
252+
#else
224253
SetSysClock();
254+
#endif
225255

226256
/* Wait for clock to be stabilized.
227257
* TO DO: a better way of doing this, would be to rely on

targets/targets.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3310,7 +3310,8 @@
33103310
"macros_add": [
33113311
"STM32H747xx",
33123312
"CORE_CM7",
3313-
"EXTRA_IDLE_STACK_REQUIRED"
3313+
"EXTRA_IDLE_STACK_REQUIRED",
3314+
"MBED_TICKLESS"
33143315
],
33153316
"overrides": { "lpticker_delay_ticks": 0 },
33163317
"supported_form_factors": [
@@ -3353,7 +3354,8 @@
33533354
"macros_add": [
33543355
"STM32H747xx",
33553356
"CORE_CM4",
3356-
"EXTRA_IDLE_STACK_REQUIRED"
3357+
"EXTRA_IDLE_STACK_REQUIRED",
3358+
"MBED_TICKLESS"
33573359
],
33583360
"overrides": { "lpticker_delay_ticks": 0 },
33593361
"supported_form_factors": [

0 commit comments

Comments
 (0)