Skip to content

Commit 58e3c73

Browse files
committed
add init of the RTC
Signed-off-by: Francois Ramu <[email protected]>
1 parent 52a5492 commit 58e3c73

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/utility/HCISharedMemTransport.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include "HCISharedMemTransport.h"
2121
#include "STM32Cube_FW/hw.h"
22+
#include "stm32wbxx_hal_rtc.h"
23+
#include "stm32wbxx_hal_rtc_ex.h"
2224

2325
/* global var used as semaphore to control incoming events */
2426
volatile bool sys_event; /* true : M0 core is already up and running */
@@ -463,6 +465,28 @@ size_t HCISharedMemTransportClass::write(const uint8_t* data, size_t length)
463465
//private:
464466
void start_ble_rf(void)
465467
{
468+
469+
LL_PWR_EnableBkUpAccess();
470+
__HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSE);
471+
__HAL_RCC_RTC_ENABLE();
472+
473+
RTC_HandleTypeDef hrtc;
474+
475+
hrtc.Instance = RTC;
476+
hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
477+
hrtc.Init.AsynchPrediv = 0x7F;
478+
hrtc.Init.SynchPrediv = 0x0FF;
479+
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
480+
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
481+
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
482+
if (HAL_RTC_Init(&hrtc) != HAL_OK) {
483+
Error_Handler();
484+
}
485+
MODIFY_REG(RTC->CR, RTC_CR_WUCKSEL, 0);
486+
HAL_RTCEx_EnableBypassShadow(&hrtc);
487+
488+
489+
466490
if ((LL_RCC_IsActiveFlag_PINRST()) && (!LL_RCC_IsActiveFlag_SFTRST())) {
467491
/* Simulate power off reset */
468492
LL_PWR_EnableBkUpAccess();

0 commit comments

Comments
 (0)