Skip to content

Commit 88f7733

Browse files
committed
feat: add the HAL_MSP_Init/DeInit functions
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 699658d commit 88f7733

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/rtc.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,54 @@ static inline int _log2(int x)
9898

9999
/* Exported functions --------------------------------------------------------*/
100100

101+
/* HAL MSP function used for RTC_Init */
102+
void HAL_RTC_MspInit(RTC_HandleTypeDef *rtcHandle)
103+
{
104+
#if defined(RTC_SCR_CSSRUF)
105+
if (rtcHandle->Instance == RTC) {
106+
/* In BINARY mode (MIX or ONLY), set the SSR Underflow interrupt */
107+
if (rtcHandle->Init.BinMode != RTC_BINARY_NONE) {
108+
#if defined(STM32WLxx)
109+
/* Only the STM32WLxx series has a TAMP_STAMP_LSECSS_SSRU_IRQn */
110+
if (HAL_RTCEx_SetSSRU_IT(rtcHandle) != HAL_OK) {
111+
Error_Handler();
112+
}
113+
/* Give init value for the RtcFeatures enable */
114+
rtcHandle->IsEnabled.RtcFeatures = 0;
115+
116+
/* RTC interrupt Init */
117+
HAL_NVIC_SetPriority(TAMP_STAMP_LSECSS_SSRU_IRQn, 0, 0);
118+
HAL_NVIC_EnableIRQ(TAMP_STAMP_LSECSS_SSRU_IRQn);
119+
#else
120+
/* The STM32U5, STM32H5, STM32L4plus have common RTC interrupt and a SSRU flag */
121+
__HAL_RTC_SSRU_ENABLE_IT(rtcHandle, RTC_IT_SSRU);
122+
#endif /* STM32WLxx */
123+
}
124+
}
125+
#else /* RTC_SCR_CSSRUF */
126+
UNUSED(rtcHandle);
127+
#endif /* RTC_SCR_CSSRUF */
128+
/* RTC_Alarm_IRQn is enabled when enabling Alarm */
129+
}
130+
131+
void HAL_RTC_MspDeInit(RTC_HandleTypeDef *rtcHandle)
132+
{
133+
134+
if (rtcHandle->Instance == RTC) {
135+
/* Peripheral clock disable */
136+
__HAL_RCC_RTC_DISABLE();
137+
#ifdef __HAL_RCC_RTCAPB_CLK_DISABLE
138+
__HAL_RCC_RTCAPB_CLK_DISABLE();
139+
#endif
140+
/* RTC interrupt Deinit */
141+
#if defined(STM32WLxx)
142+
/* Only the STM32WLxx series has a TAMP_STAMP_LSECSS_SSRU_IRQn */
143+
HAL_NVIC_DisableIRQ(TAMP_STAMP_LSECSS_SSRU_IRQn);
144+
#endif /* STM32WLxx */
145+
HAL_NVIC_DisableIRQ(RTC_Alarm_IRQn);
146+
}
147+
}
148+
101149
/**
102150
* @brief Get pointer to RTC_HandleTypeDef
103151
* @param None

0 commit comments

Comments
 (0)