From 93bc407303b10aadc52b44a126f2ed123d0cdb7d Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 3 Feb 2021 15:54:42 +0100 Subject: [PATCH] [WB] Add hardware semaphore management Signed-off-by: Frederic Pillon --- variants/PNUCLEO_WB55RG/variant.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/variants/PNUCLEO_WB55RG/variant.cpp b/variants/PNUCLEO_WB55RG/variant.cpp index 62fbc2c0ac..bf16a2204a 100644 --- a/variants/PNUCLEO_WB55RG/variant.cpp +++ b/variants/PNUCLEO_WB55RG/variant.cpp @@ -17,6 +17,7 @@ */ #include "pins_arduino.h" +#include "lock_resource.h" #ifdef __cplusplus extern "C" { @@ -99,9 +100,15 @@ WEAK void SystemClock_Config(void) RCC_ClkInitTypeDef RCC_ClkInitStruct = {}; RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {}; + /* This prevents the CPU2 (M0+) to configure RCC */ + hsem_lock(CFG_HW_RCC_SEMID, HSEM_LOCK_DEFAULT_RETRY); + __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + /* This prevents the CPU2 (M0+) to disable the HSI48 oscillator */ + hsem_lock(CFG_HW_CLK48_CONFIG_SEMID, HSEM_LOCK_DEFAULT_RETRY); + /* Initializes the CPU, AHB and APB busses clocks */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_LSE; @@ -149,6 +156,7 @@ WEAK void SystemClock_Config(void) /* Select HSI as system clock source after Wake Up from Stop mode */ LL_RCC_SetClkAfterWakeFromStop(LL_RCC_STOP_WAKEUPCLOCK_HSI); + hsem_unlock(CFG_HW_RCC_SEMID); } #ifdef __cplusplus