diff options
Diffstat (limited to 'Projects/P-NUCLEO-WB55.USBDongle/Applications/BLE/BLE_p2pClient/Core/Src/main.c')
-rw-r--r-- | Projects/P-NUCLEO-WB55.USBDongle/Applications/BLE/BLE_p2pClient/Core/Src/main.c | 65 |
1 files changed, 38 insertions, 27 deletions
diff --git a/Projects/P-NUCLEO-WB55.USBDongle/Applications/BLE/BLE_p2pClient/Core/Src/main.c b/Projects/P-NUCLEO-WB55.USBDongle/Applications/BLE/BLE_p2pClient/Core/Src/main.c index 7e80f2c17..1754a019a 100644 --- a/Projects/P-NUCLEO-WB55.USBDongle/Applications/BLE/BLE_p2pClient/Core/Src/main.c +++ b/Projects/P-NUCLEO-WB55.USBDongle/Applications/BLE/BLE_p2pClient/Core/Src/main.c @@ -195,7 +195,13 @@ static void Init_RTC( void ) hrtc.Init.SynchPrediv = CFG_RTC_SYNCH_PRESCALER; HAL_RTC_Init(&hrtc); - MODIFY_REG(RTC->CR, RTC_CR_WUCKSEL, CFG_RTC_WUCKSEL_DIVIDER); + /* Disable RTC registers write protection */ + LL_RTC_DisableWriteProtection(RTC); + + LL_RTC_WAKEUP_SetClock(RTC, CFG_RTC_WUCKSEL_DIVIDER); + + /* Enable RTC registers write protection */ + LL_RTC_EnableWriteProtection(RTC); return; } @@ -218,6 +224,12 @@ void SystemClock_Config( void ) RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = { 0 }; RCC_CRSInitTypeDef RCC_CRSInitStruct = { 0 }; + /** + * This prevents the CPU2 to disable the HSI48 oscillator when + * it does not use anymore the RNG IP + */ + LL_HSEM_1StepLock( HSEM, 5 ); + LL_RCC_HSI48_Enable(); while(!LL_RCC_HSI48_IsReady()); @@ -268,19 +280,6 @@ void SystemClock_Config( void ) */ LL_RCC_SetRFWKPClockSource(LL_RCC_RFWKP_CLKSOURCE_LSE); - /** - * Switch OFF LSI - */ - LL_RCC_LSI1_Disable(); - - - /** - * Set RNG on HSI48 - */ - LL_RCC_HSI48_Enable(); - while(!LL_RCC_HSI48_IsReady()); - LL_RCC_SetCLK48ClockSource(LL_RCC_CLK48_CLKSOURCE_HSI48); - return; } @@ -289,21 +288,33 @@ void SystemClock_Config( void ) * WRAP FUNCTIONS * *************************************************************/ - -/** - * This function is empty to avoid starting the SysTick Timer - */ -HAL_StatusTypeDef HAL_InitTick( uint32_t TickPriority ) +void HAL_Delay(uint32_t Delay) { - return (HAL_OK); -} + uint32_t tickstart = HAL_GetTick(); + uint32_t wait = Delay; -/** - * This function is empty as the SysTick Timer is not used - */ -void HAL_Delay(__IO uint32_t Delay) -{ - return; + /* Add a freq to guarantee minimum wait */ + if (wait < HAL_MAX_DELAY) + { + wait += HAL_GetTickFreq(); + } + + while ((HAL_GetTick() - tickstart) < wait) + { + /************************************************************************************ + * ENTER SLEEP MODE + ***********************************************************************************/ + LL_LPM_EnableSleep( ); /**< Clear SLEEPDEEP bit of Cortex System Control Register */ + + /** + * This option is used to ensure that store operations are completed + */ + #if defined ( __CC_ARM) + __force_stores(); + #endif + + __WFI( ); + } } /******************* (C) COPYRIGHT 2019 STMicroelectronics *****END OF FILE****/ |