Skip to content

Commit ad41c6d

Browse files
committed
[WB] Add hardware semaphore management
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 96801d8 commit ad41c6d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: variants/PNUCLEO_WB55RG/variant.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include "pins_arduino.h"
20+
#include "lock_resource.h"
2021

2122
#ifdef __cplusplus
2223
extern "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

0 commit comments

Comments
 (0)