@@ -95,16 +95,6 @@ typedef struct
9595 */
9696static bool RtcInitialized = false;
9797
98- /*!
99- * \brief Indicates if the RTC Wake Up Time is calibrated or not
100- */
101- static bool McuWakeUpTimeInitialized = false;
102-
103- /*!
104- * \brief Compensates MCU wakeup time
105- */
106- static int16_t McuWakeUpTimeCal = 0 ;
107-
10898/*!
10999 * Number of days in each month on a normal year
110100 */
@@ -290,7 +280,7 @@ void RtcDelayMs( uint32_t delay )
290280void RtcSetAlarm ( uint32_t timeout )
291281{
292282 // We don't go in Low Power mode for timeout below MIN_ALARM_DELAY
293- if ( ( int64_t )( MIN_ALARM_DELAY + McuWakeUpTimeCal ) < ( int64_t )( timeout - RtcGetTimerElapsedTime ( ) ) )
283+ if ( ( int64_t )MIN_ALARM_DELAY < ( int64_t )( timeout - RtcGetTimerElapsedTime ( ) ) )
294284 {
295285 LpmSetStopMode ( LPM_RTC_ID , LPM_ENABLE );
296286 }
@@ -299,12 +289,6 @@ void RtcSetAlarm( uint32_t timeout )
299289 LpmSetStopMode ( LPM_RTC_ID , LPM_DISABLE );
300290 }
301291
302- // In case stop mode is required
303- if ( LpmGetMode ( ) == LPM_STOP_MODE )
304- {
305- timeout = timeout - McuWakeUpTimeCal ;
306- }
307-
308292 RtcStartAlarm ( timeout );
309293}
310294
@@ -443,41 +427,6 @@ uint32_t RtcGetTimerElapsedTime( void )
443427 return ( ( uint32_t )( calendarValue - RtcTimerContext .Time ) );
444428}
445429
446- void RtcSetMcuWakeUpTime ( void )
447- {
448- RTC_TimeTypeDef time ;
449- RTC_DateTypeDef date ;
450-
451- uint32_t now , hit ;
452- int16_t mcuWakeUpTime ;
453-
454- if ( ( McuWakeUpTimeInitialized == false ) &&
455- ( HAL_NVIC_GetPendingIRQ ( RTC_Alarm_IRQn ) == 1 ) )
456- {
457- /* WARNING: Works ok if now is below 30 days
458- * it is ok since it's done once at first alarm wake-up
459- */
460- McuWakeUpTimeInitialized = true;
461- now = ( uint32_t )RtcGetCalendarValue ( & date , & time );
462-
463- HAL_RTC_GetAlarm ( & RtcHandle , & RtcAlarm , RTC_ALARM_A , RTC_FORMAT_BIN );
464- hit = RtcAlarm .AlarmTime .Seconds +
465- 60 * ( RtcAlarm .AlarmTime .Minutes +
466- 60 * ( RtcAlarm .AlarmTime .Hours +
467- 24 * ( RtcAlarm .AlarmDateWeekDay - 1 ) ) );
468- hit = ( hit << N_PREDIV_S ) + ( PREDIV_S - RtcAlarm .AlarmTime .SubSeconds );
469-
470- mcuWakeUpTime = ( int16_t )( ( now - hit ) );
471- McuWakeUpTimeCal += mcuWakeUpTime ;
472- //PRINTF( 3, "Cal=%d, %d\n", McuWakeUpTimeCal, mcuWakeUpTime);
473- }
474- }
475-
476- int16_t RtcGetMcuWakeUpTime ( void )
477- {
478- return McuWakeUpTimeCal ;
479- }
480-
481430static uint64_t RtcGetCalendarValue ( RTC_DateTypeDef * date , RTC_TimeTypeDef * time )
482431{
483432 uint64_t calendarValue = 0 ;
0 commit comments