Skip to content

Commit 0368da7

Browse files
committed
simplify the BSP to keep are timer_f and include the RTC library
Include the STM32RTC library to all the BSP as only few functions remain in the BSP as the RTC is instantiated by the STM32RTC library Signed-off-by: Francois Ramu <francois.ramu@st.com>
1 parent 37238b7 commit 0368da7

File tree

4 files changed

+49
-202
lines changed

4 files changed

+49
-202
lines changed

src/BSP/rtc.c

Lines changed: 0 additions & 145 deletions
This file was deleted.

src/BSP/rtc.h

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/BSP/timer_if.c

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,56 @@
2727
// #include "stm32_lpm.h"
2828
// #include "utilities_def.h"
2929
#include "stm32wlxx_ll_rtc.h"
30-
#include "rtc.h"
3130

3231
/* USER CODE BEGIN Includes */
3332

3433
/* USER CODE END Includes */
3534

3635
/* External variables ---------------------------------------------------------*/
37-
/**
38-
* @brief RTC handle
39-
*/
36+
4037
extern RTC_HandleTypeDef RtcHandle;
4138

39+
/* HAL MSP function used for RTC_Init */
40+
void HAL_RTC_MspInit(RTC_HandleTypeDef* rtcHandle)
41+
{
42+
43+
if(rtcHandle->Instance==RTC)
44+
{
45+
if (HAL_RTCEx_SetSSRU_IT(rtcHandle) != HAL_OK)
46+
{
47+
Error_Handler();
48+
}
49+
50+
/* RTC interrupt Init */
51+
HAL_NVIC_SetPriority(TAMP_STAMP_LSECSS_SSRU_IRQn, 0, 0);
52+
HAL_NVIC_EnableIRQ(TAMP_STAMP_LSECSS_SSRU_IRQn);
53+
54+
HAL_NVIC_SetPriority(RTC_Alarm_IRQn, RTC_IRQ_PRIO, RTC_IRQ_SUBPRIO);
55+
HAL_NVIC_EnableIRQ(RTC_Alarm_IRQn);
56+
}
57+
}
58+
59+
void HAL_RTC_MspDeInit(RTC_HandleTypeDef* rtcHandle)
60+
{
61+
62+
if(rtcHandle->Instance==RTC)
63+
{
64+
/* USER CODE BEGIN RTC_MspDeInit 0 */
65+
66+
/* USER CODE END RTC_MspDeInit 0 */
67+
/* Peripheral clock disable */
68+
__HAL_RCC_RTC_DISABLE();
69+
__HAL_RCC_RTCAPB_CLK_DISABLE();
70+
71+
/* RTC interrupt Deinit */
72+
HAL_NVIC_DisableIRQ(TAMP_STAMP_LSECSS_SSRU_IRQn);
73+
HAL_NVIC_DisableIRQ(RTC_Alarm_IRQn);
74+
/* USER CODE BEGIN RTC_MspDeInit 1 */
75+
76+
/* USER CODE END RTC_MspDeInit 1 */
77+
}
78+
}
79+
4280
/**
4381
* @brief Timer driver callbacks handler
4482
*/
@@ -187,6 +225,12 @@ UTIL_TIMER_Status_t TIMER_IF_Init(void)
187225
if (RTC_Initialized == false)
188226
{
189227
/* RTC is already Initialized by the LoRaWan::begin */
228+
RtcHandle.IsEnabled.RtcFeatures = UINT32_MAX;
229+
230+
/** Enable the Alarm B just after the HAL_RTC_Init */
231+
RTC_StartAlarm(RTC_ALARM_B, 0, 0, 0, 0, 0, RTC_HOURFORMAT12_PM, 32UL);
232+
233+
/*Stop Timer */
190234
TIMER_IF_StopTimer();
191235

192236
/*overload RTC feature enable*/

src/BSP/timer_if.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ void UTIL_TIMER_IRQ_MAP_PROCESS(void *data);
4646
/* Exported types ------------------------------------------------------------*/
4747
/* USER CODE BEGIN ET */
4848

49+
4950
/* USER CODE END ET */
5051

5152
/* Exported constants --------------------------------------------------------*/

0 commit comments

Comments
 (0)