@@ -66,6 +66,9 @@ static void *callbackUserDataB = NULL;
66
66
#ifdef ONESECOND_IRQn
67
67
static voidCallbackPtr RTCSecondsIrqCallback = NULL ;
68
68
#endif
69
+ #ifdef STM32WLxx
70
+ static voidCallbackPtr RTCSubSecondsUnderflowIrqCallback = NULL ;
71
+ #endif
69
72
static sourceClock_t clkSrc = LSI_CLOCK ;
70
73
static uint32_t clkVal = LSI_VALUE ;
71
74
static uint8_t HSEDiv = 0 ;
@@ -98,49 +101,6 @@ static inline int _log2(int x)
98
101
}
99
102
100
103
/* Exported functions --------------------------------------------------------*/
101
-
102
- /* HAL MSP function used for RTC_Init */
103
- void HAL_RTC_MspInit (RTC_HandleTypeDef * rtcHandle )
104
- {
105
- #if defined(RTC_SCR_CSSRUF )
106
- if (rtcHandle -> Instance == RTC ) {
107
- /* In BINARY mode (MIX or ONLY), set the SSR Underflow interrupt */
108
- if (rtcHandle -> Init .BinMode != RTC_BINARY_NONE ) {
109
- #if defined(STM32WLxx )
110
- /* Only the STM32WLxx series has a TAMP_STAMP_LSECSS_SSRU_IRQn */
111
- if (HAL_RTCEx_SetSSRU_IT (rtcHandle ) != HAL_OK ) {
112
- Error_Handler ();
113
- }
114
- /* Give init value for the RtcFeatures enable */
115
- rtcHandle -> IsEnabled .RtcFeatures = 0 ;
116
-
117
- /* RTC interrupt Init */
118
- HAL_NVIC_SetPriority (TAMP_STAMP_LSECSS_SSRU_IRQn , 0 , 0 );
119
- HAL_NVIC_EnableIRQ (TAMP_STAMP_LSECSS_SSRU_IRQn );
120
- #else
121
- /* The STM32U5, STM32H5, STM32L4plus have common RTC interrupt and a SSRU flag */
122
- __HAL_RTC_SSRU_ENABLE_IT (rtcHandle , RTC_IT_SSRU );
123
- #endif /* STM32WLxx */
124
- }
125
- }
126
- #else /* RTC_SCR_CSSRUF */
127
- UNUSED (rtcHandle );
128
- #endif /* RTC_SCR_CSSRUF */
129
- /* RTC_Alarm_IRQn is enabled when enabling Alarm */
130
- }
131
-
132
- void HAL_RTC_MspDeInit (RTC_HandleTypeDef * rtcHandle )
133
- {
134
-
135
- if (rtcHandle -> Instance == RTC ) {
136
- /* RTC interrupt Deinit */
137
- #if defined(STM32WLxx )
138
- /* Only the STM32WLxx series has a TAMP_STAMP_LSECSS_SSRU_IRQn */
139
- HAL_NVIC_DisableIRQ (TAMP_STAMP_LSECSS_SSRU_IRQn );
140
- #endif /* STM32WLxx */
141
- }
142
- }
143
-
144
104
/**
145
105
* @brief Get pointer to RTC_HandleTypeDef
146
106
* @param None
@@ -638,6 +598,9 @@ void RTC_DeInit(bool reset_cb)
638
598
HAL_NVIC_DisableIRQ (RTC_Alarm_IRQn );
639
599
#ifdef ONESECOND_IRQn
640
600
HAL_NVIC_DisableIRQ (ONESECOND_IRQn );
601
+ #endif
602
+ #ifdef STM32WLxx
603
+ HAL_NVIC_DisableIRQ (TAMP_STAMP_LSECSS_SSRU_IRQn );
641
604
#endif
642
605
if (reset_cb ) {
643
606
RTCUserCallback = NULL ;
@@ -648,6 +611,9 @@ void RTC_DeInit(bool reset_cb)
648
611
#endif
649
612
#ifdef ONESECOND_IRQn
650
613
RTCSecondsIrqCallback = NULL ;
614
+ #endif
615
+ #ifdef STM32WLxx
616
+ RTCSubSecondsUnderflowIrqCallback = NULL ;
651
617
#endif
652
618
}
653
619
}
@@ -1266,6 +1232,48 @@ void RTC_WKUP_IRQHandler(void)
1266
1232
#endif /* STM32F1xx */
1267
1233
#endif /* ONESECOND_IRQn */
1268
1234
1235
+ #ifdef STM32WLxx
1236
+ /**
1237
+ * @brief Attach SubSeconds underflow interrupt callback.
1238
+ * @param func: pointer to the callback
1239
+ * @retval None
1240
+ */
1241
+ void attachSubSecondsUnderflowIrqCallback (voidCallbackPtr func )
1242
+ {
1243
+ /* Callback called on SSRU interrupt */
1244
+ RTCSubSecondsUnderflowIrqCallback = func ;
1245
+
1246
+ /* Enable the IRQ that will trig the one-second interrupt */
1247
+ if (HAL_RTCEx_SetSSRU_IT (& RtcHandle ) != HAL_OK ) {
1248
+ Error_Handler ();
1249
+ }
1250
+ HAL_NVIC_SetPriority (TAMP_STAMP_LSECSS_SSRU_IRQn , RTC_IRQ_SSRU_PRIO , RTC_IRQ_SSRU_SUBPRIO );
1251
+ HAL_NVIC_EnableIRQ (TAMP_STAMP_LSECSS_SSRU_IRQn );
1252
+ }
1253
+
1254
+ /**
1255
+ * @brief Detach SubSeconds underflow interrupt callback.
1256
+ * @param None
1257
+ * @retval None
1258
+ */
1259
+ void detachSubSecondsUnderflowIrqCallback (void )
1260
+ {
1261
+ RTCSubSecondsUnderflowIrqCallback = NULL ;
1262
+ if (HAL_RTCEx_DeactivateSSRU (& RtcHandle ) != HAL_OK ) {
1263
+ Error_Handler ();
1264
+ }
1265
+ HAL_NVIC_DisableIRQ (TAMP_STAMP_LSECSS_SSRU_IRQn );
1266
+ }
1267
+
1268
+ void HAL_RTCEx_SSRUEventCallback (RTC_HandleTypeDef * hrtc )
1269
+ {
1270
+ (void )hrtc ;
1271
+ if (RTCSubSecondsUnderflowIrqCallback != NULL ) {
1272
+ RTCSubSecondsUnderflowIrqCallback (NULL );
1273
+ }
1274
+ }
1275
+ #endif /* STM32WLxx */
1276
+
1269
1277
#if defined(STM32F1xx )
1270
1278
void RTC_StoreDate (void )
1271
1279
{
0 commit comments