File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -136,14 +136,14 @@ typedef enum {
136136static inline void hsem_lock (uint32_t semID , uint32_t retry )
137137{
138138#if defined(STM32MP1xx ) || defined(STM32WBxx )
139- while (LL_HSEM_1StepLock (HSEM , semID )) {
140- if (retry != HSEM_LOCK_WAIT_FOREVER ) {
139+ while (LL_HSEM_1StepLock (HSEM , semID )) {
140+ if (retry != HSEM_LOCK_WAIT_FOREVER ) {
141141 retry -- ;
142- if (retry == 0 ) {
143- Error_Handler ();
144- }
145- }
146- }
142+ if (retry == 0 ) {
143+ Error_Handler ();
144+ }
145+ }
146+ }
147147#endif /* STM32MP1xx || STM32WBxx */
148148}
149149
@@ -155,7 +155,7 @@ static inline void hsem_lock(uint32_t semID, uint32_t retry)
155155static inline void hsem_unlock (uint32_t semID )
156156{
157157#if defined(STM32MP1xx ) || defined(STM32WBxx )
158- LL_HSEM_ReleaseLock (HSEM , semID , 0 );
158+ LL_HSEM_ReleaseLock (HSEM , semID , 0 );
159159#endif /* STM32MP1xx || STM32WBxx */
160160}
161161
Original file line number Diff line number Diff line change 1717*/
1818
1919#include " pins_arduino.h"
20+ #include " lock_resource.h"
2021
2122#ifdef __cplusplus
2223extern " C" {
@@ -99,9 +100,15 @@ WEAK void SystemClock_Config(void)
99100 RCC_ClkInitTypeDef RCC_ClkInitStruct = {};
100101 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {};
101102
103+ /* This prevents the CPU2 (M0+) to configure RCC */
104+ hsem_lock (CFG_HW_RCC_SEMID, HSEM_LOCK_DEFAULT_RETRY);
105+
102106 __HAL_RCC_LSEDRIVE_CONFIG (RCC_LSEDRIVE_LOW);
103107 __HAL_PWR_VOLTAGESCALING_CONFIG (PWR_REGULATOR_VOLTAGE_SCALE1);
104108
109+ /* This prevents the CPU2 (M0+) to disable the HSI48 oscillator */
110+ hsem_lock (CFG_HW_CLK48_CONFIG_SEMID, HSEM_LOCK_DEFAULT_RETRY);
111+
105112 /* Initializes the CPU, AHB and APB busses clocks */
106113 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48
107114 | RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_LSE;
@@ -149,6 +156,7 @@ WEAK void SystemClock_Config(void)
149156 /* Select HSI as system clock source after Wake Up from Stop mode */
150157 LL_RCC_SetClkAfterWakeFromStop (LL_RCC_STOP_WAKEUPCLOCK_HSI);
151158
159+ hsem_unlock (CFG_HW_RCC_SEMID);
152160}
153161
154162#ifdef __cplusplus
You can’t perform that action at this time.
0 commit comments