@@ -46,6 +46,8 @@ void HAL_RTC_MspInit(RTC_HandleTypeDef* rtcHandle)
46
46
{
47
47
Error_Handler ();
48
48
}
49
+ /* give init value for the RtcFeatures enable */
50
+ rtcHandle -> IsEnabled .RtcFeatures = 0 ;
49
51
50
52
/* RTC interrupt Init */
51
53
HAL_NVIC_SetPriority (TAMP_STAMP_LSECSS_SSRU_IRQn , 0 , 0 );
@@ -224,17 +226,8 @@ UTIL_TIMER_Status_t TIMER_IF_Init(void)
224
226
/* USER CODE END TIMER_IF_Init */
225
227
if (RTC_Initialized == false)
226
228
{
227
- /* 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 */
234
- TIMER_IF_StopTimer ();
235
-
236
- /*overload RTC feature enable*/
237
- RtcHandle .IsEnabled .RtcFeatures = UINT32_MAX ;
229
+ /*Stop Timer : Disable the Alarm B interrupt */
230
+ RTC_StopAlarm (RTC_ALARM_B );
238
231
239
232
/*Initialize MSB ticks*/
240
233
TIMER_IF_BkUp_Write_MSBticks (0 );
@@ -259,13 +252,15 @@ UTIL_TIMER_Status_t TIMER_IF_StartTimer(uint32_t timeout)
259
252
/* USER CODE BEGIN TIMER_IF_StartTimer */
260
253
261
254
/* USER CODE END TIMER_IF_StartTimer */
255
+
262
256
/*Stop timer if one is already started*/
263
- TIMER_IF_StopTimer ();
257
+ RTC_StopAlarm (RTC_ALARM_B );
258
+
264
259
timeout += RtcTimerContext ;
265
260
266
- TIMER_IF_DBG_PRINTF ("Start timer: time=%d, alarm=%d\n\r" , GetTimerTicks (), timeout );
261
+ TIMER_IF_DBG_PRINTF ("Start timer: time=%d, alarm=%d\n\r" , GetTimerTicks (), timeout );
267
262
268
- /* Program ALARM B on subsecond, mask is 32 (and fixed to RTC_ALARMMASK_NONE for calendar) */
263
+ /* Program ALARM B on subsecond, mask is 32 (and fixed to RTC_ALARMMASK_ALL for calendar) */
269
264
RTC_StartAlarm (RTC_ALARM_B , 0 , 0 , 0 , 0 , UINT32_MAX - timeout , RTC_HOURFORMAT12_PM , 32UL );
270
265
271
266
/* USER CODE BEGIN TIMER_IF_StartTimer_Last */
@@ -284,8 +279,6 @@ UTIL_TIMER_Status_t TIMER_IF_StopTimer(void)
284
279
/* Disable the Alarm B interrupt */
285
280
RTC_StopAlarm (RTC_ALARM_B );
286
281
287
- /*overload RTC feature enable*/
288
- RtcHandle .IsEnabled .RtcFeatures = UINT32_MAX ;
289
282
/* USER CODE BEGIN TIMER_IF_StopTimer_Last */
290
283
291
284
/* USER CODE END TIMER_IF_StopTimer_Last */
0 commit comments