Skip to content

Commit

Permalink
[WB] Add hardware semaphore management
Browse files Browse the repository at this point in the history
Signed-off-by: Frederic Pillon <[email protected]>
  • Loading branch information
fpistm committed Feb 3, 2021
1 parent 96801d8 commit ad41c6d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions variants/PNUCLEO_WB55RG/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

#include "pins_arduino.h"
#include "lock_resource.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ad41c6d

Please sign in to comment.