@@ -572,26 +572,40 @@ size_t HCISharedMemTransportClass::write(const uint8_t *data, size_t length)
572572// private:
573573void HCISharedMemTransportClass::start_ble_rf (void )
574574{
575- /* Set the DBP bit in the Power control register 1 (PWR_CR1) */
576- LL_PWR_EnableBkUpAccess ();
577-
578- /* LSE belongs to the back-up domain, enable access.*/
579- while (!LL_PWR_IsEnabledBkUpAccess ()) {
580- /* Wait for Backup domain access */
581- }
582- LL_RCC_ForceBackupDomainReset ();
583- LL_RCC_ReleaseBackupDomainReset ();
575+ /* Read the actual configured RF Wakeup clock source from registers */
576+ uint32_t rfwkpSource = LL_RCC_GetRFWKPClockSource ();
577+
578+ if (rfwkpSource == LL_RCC_RFWKP_CLKSOURCE_LSE ) {
579+ /* LSE is selected: Enable LSE and wait for ready */
580+ LL_PWR_EnableBkUpAccess ();
581+ while (!LL_PWR_IsEnabledBkUpAccess ()) {
582+ /* Wait for Backup domain access */
583+ }
584+ LL_RCC_ForceBackupDomainReset ();
585+ LL_RCC_ReleaseBackupDomainReset ();
584586
585- /* Enable LSE Oscillator (32.768 kHz) */
586- LL_RCC_LSE_Enable ();
587- while (!LL_RCC_LSE_IsReady ()) {
588- /* Wait for LSE ready */
589- }
587+ LL_RCC_LSE_Enable ();
588+ while (!LL_RCC_LSE_IsReady ()) {
589+ /* Wait for LSE ready */
590+ }
590591
591- LL_PWR_DisableBkUpAccess ();
592+ LL_PWR_DisableBkUpAccess ();
592593
593- /* Switch OFF LSI as LSE is the source clock */
594- LL_RCC_LSI2_Disable ();
594+ /* Switch OFF LSI as LSE is the source clock */
595+ LL_RCC_LSI2_Disable ();
596+ }
597+ #if defined(LL_RCC_RFWKP_CLKSOURCE_LSI)
598+ else if (rfwkpSource == LL_RCC_RFWKP_CLKSOURCE_LSI ) {
599+ /* LSI is selected: Enable LSI1 and wait for ready */
600+ LL_RCC_LSI1_Enable ();
601+ while (!LL_RCC_LSI1_IsReady ()) {
602+ /* Wait for LSI1 ready */
603+ }
604+ }
605+ #endif
606+ else if (rfwkpSource == LL_RCC_RFWKP_CLKSOURCE_HSE_DIV1024 ) {
607+ /* HSE/1024 is selected: No low-speed oscillator needs enabling */
608+ }
595609}
596610
597611void HCISharedMemTransportClass::stm32wb_reset (void )
0 commit comments