Skip to content

Commit 6bca23c

Browse files
committed
Activate default clocks on the stm32wb with semaphore
This procedure is preventing the M0 to access the RCC during the clock enabled by the M4. Signed-off-by: Francois Ramu <[email protected]>
1 parent 60d2609 commit 6bca23c

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

src/utility/HCISharedMemTransport.cpp

+29-7
Original file line numberDiff line numberDiff line change
@@ -553,13 +553,35 @@ size_t HCISharedMemTransportClass::write(const uint8_t *data, size_t length)
553553
//private:
554554
void HCISharedMemTransportClass::start_ble_rf(void)
555555
{
556-
if ((LL_RCC_IsActiveFlag_PINRST()) && (!LL_RCC_IsActiveFlag_SFTRST())) {
557-
/* Simulate power off reset */
558-
LL_PWR_EnableBkUpAccess();
559-
LL_PWR_EnableBkUpAccess();
560-
LL_RCC_ForceBackupDomainReset();
561-
LL_RCC_ReleaseBackupDomainReset();
562-
}
556+
/* HW semaphore Clock is enabled for this variant */
557+
LL_AHB3_GRP1_EnableClock(LL_AHB3_GRP1_PERIPH_HSEM);
558+
559+
//* This prevents the CPU2 (M0+) to configure RCC */
560+
while (LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID));
561+
562+
#ifdef LL_APB1_GRP1_PERIPH_PWR
563+
/* Enable the power interface clock */
564+
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
565+
#endif
566+
/* Set the DBP bit in the Power control register 1 (PWR_CR1) */
567+
LL_PWR_EnableBkUpAccess();
568+
569+
/* LSE belongs to the back-up domain, enable access.*/
570+
while (!LL_PWR_IsEnabledBkUpAccess()) {
571+
/* Wait for Backup domain access */
572+
}
573+
LL_RCC_ForceBackupDomainReset();
574+
LL_RCC_ReleaseBackupDomainReset();
575+
576+
/* Enable LSE Oscillator (32.768 kHz) */
577+
LL_RCC_LSE_Enable();
578+
while (!LL_RCC_LSE_IsReady()) {
579+
/* Wait for LSE ready */
580+
}
581+
582+
LL_PWR_DisableBkUpAccess();
583+
584+
LL_HSEM_ReleaseLock(HSEM, CFG_HW_RCC_SEMID, 0);
563585

564586
/* Switch OFF LSI as LSE is the source clock */
565587
LL_RCC_LSI2_Disable();

src/utility/HCISharedMemTransport.h

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
/* STM32WB include files */
2626
#include "stm32wb55xx.h"
2727
#include "stm32wbxx_ll_rcc.h"
28+
#include "stm32wbxx_ll_hsem.h"
2829
#include "stm32wbxx_ll_ipcc.h"
2930
#include "stm32wbxx_ll_system.h"
3031
#include "STM32Cube_FW/tl.h"
@@ -38,6 +39,8 @@
3839
/* this CONFIG_DEBUG must be defined for -Og option */
3940
//#define CONFIG_DEBUG
4041

42+
#define CFG_HW_RCC_SEMID 3U
43+
4144
/******************************************************************************
4245
* BLE config parameters
4346
******************************************************************************/

0 commit comments

Comments
 (0)