L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
timer_if.h File Reference

configuration of the timer_if.c instances More...

#include "stm32_timer.h"
#include "stm32_systime.h"
Include dependency graph for timer_if.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define RTC_BKP_STANDBY   RTC_BKP_DR3
 RTC backup register index used to persist the standby-mode flag across a system reset / wakeup from OFF (standby) mode. Written with RTC_BKP_STANDBY_SIGN before entering standby so that after wakeup the application knows it came from a planned sleep cycle rather than a cold power-on.
#define RTC_BKP_STANDBY_SIGN   0xABCD
 Magic value stored in RTC_BKP_STANDBY before entering standby mode. On wakeup, if getBackUpRegister(RTC_BKP_STANDBY) == RTC_BKP_STANDBY_SIGN, the device knows it woke from a planned sleep and can skip full re-initialisation where appropriate.

Functions

UTIL_TIMER_Status_t TIMER_IF_Init (void)
 Init RTC hardware.
UTIL_TIMER_Status_t TIMER_IF_StartTimer (uint32_t timeout)
 Set the alarm.
UTIL_TIMER_Status_t TIMER_IF_StopTimer (void)
 Stop the Alarm.
uint32_t TIMER_IF_SetTimerContext (void)
 set timer Reference (TimerContext)
uint32_t TIMER_IF_GetTimerContext (void)
 Get the RTC timer Reference.
uint32_t TIMER_IF_GetTimerElapsedTime (void)
 Get the timer elapsed time since timer Reference (TimerContext) was set.
uint32_t TIMER_IF_GetTimerValue (void)
 Get the timer value.
uint32_t TIMER_IF_GetMinimumTimeout (void)
 Return the minimum timeout in ticks the RTC is able to handle.
void TIMER_IF_DelayMs (uint32_t delay)
 a delay of delay ms by polling RTC
uint32_t TIMER_IF_Convert_ms2Tick (uint32_t timeMilliSec)
 converts time in ms to time in ticks
uint32_t TIMER_IF_Convert_Tick2ms (uint32_t tick)
 converts time in ticks to time in ms
uint32_t TIMER_IF_GetTime (uint16_t *subSeconds)
 Get rtc time.
void TIMER_IF_BkUp_Write_Seconds (uint32_t Seconds)
 write seconds in backUp register
uint32_t TIMER_IF_BkUp_Read_Seconds (void)
 reads seconds from backUp register
void TIMER_IF_BkUp_Write_SubSeconds (uint32_t SubSeconds)
 writes SubSeconds in backUp register
uint32_t TIMER_IF_BkUp_Read_SubSeconds (void)
 reads SubSeconds from backUp register

Detailed Description

configuration of the timer_if.c instances

Author
MCD Application Team
Attention

Copyright (c) 2026 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

Definition in file timer_if.h.

Macro Definition Documentation

◆ RTC_BKP_STANDBY

#define RTC_BKP_STANDBY   RTC_BKP_DR3

RTC backup register index used to persist the standby-mode flag across a system reset / wakeup from OFF (standby) mode. Written with RTC_BKP_STANDBY_SIGN before entering standby so that after wakeup the application knows it came from a planned sleep cycle rather than a cold power-on.

Definition at line 61 of file timer_if.h.

Referenced by main(), and PWR_EnterOffMode().

◆ RTC_BKP_STANDBY_SIGN

#define RTC_BKP_STANDBY_SIGN   0xABCD

Magic value stored in RTC_BKP_STANDBY before entering standby mode. On wakeup, if getBackUpRegister(RTC_BKP_STANDBY) == RTC_BKP_STANDBY_SIGN, the device knows it woke from a planned sleep and can skip full re-initialisation where appropriate.

Definition at line 69 of file timer_if.h.

Referenced by main(), and PWR_EnterOffMode().

Function Documentation

◆ TIMER_IF_BkUp_Read_Seconds()

uint32_t TIMER_IF_BkUp_Read_Seconds ( void )

reads seconds from backUp register

Note
Used to store seconds difference between RTC time and Unix time
Returns
Time in seconds

Definition at line 449 of file timer_if.c.

References hrtc, and RTC_BKP_SECONDS.

◆ TIMER_IF_BkUp_Read_SubSeconds()

uint32_t TIMER_IF_BkUp_Read_SubSeconds ( void )

reads SubSeconds from backUp register

Note
Used to store SubSeconds difference between RTC time and Unix time
Returns
Time in SubSeconds

Definition at line 462 of file timer_if.c.

References hrtc, and RTC_BKP_SUBSECONDS.

◆ TIMER_IF_BkUp_Write_Seconds()

void TIMER_IF_BkUp_Write_Seconds ( uint32_t Seconds)

write seconds in backUp register

Note
Used to store seconds difference between RTC time and Unix time
Parameters
[in]Secondstime in seconds

Definition at line 427 of file timer_if.c.

References hrtc, and RTC_BKP_SECONDS.

◆ TIMER_IF_BkUp_Write_SubSeconds()

void TIMER_IF_BkUp_Write_SubSeconds ( uint32_t SubSeconds)

writes SubSeconds in backUp register

Note
Used to store SubSeconds difference between RTC time and Unix time
Parameters
[in]SubSecondstime in SubSeconds

Definition at line 438 of file timer_if.c.

References hrtc, and RTC_BKP_SUBSECONDS.

◆ TIMER_IF_Convert_ms2Tick()

uint32_t TIMER_IF_Convert_ms2Tick ( uint32_t timeMilliSec)

converts time in ms to time in ticks

Parameters
[in]timeMilliSectime in milliseconds
Returns
time in timer ticks

Definition at line 333 of file timer_if.c.

References RTC_N_PREDIV_S.

Referenced by TIMER_IF_DelayMs().

Here is the caller graph for this function:

◆ TIMER_IF_Convert_Tick2ms()

uint32_t TIMER_IF_Convert_Tick2ms ( uint32_t tick)

converts time in ticks to time in ms

Parameters
[in]ticktime in timer ticks
Returns
time in timer milliseconds

Definition at line 346 of file timer_if.c.

References RTC_N_PREDIV_S.

Referenced by TIMER_IF_GetTime().

Here is the caller graph for this function:

◆ TIMER_IF_DelayMs()

void TIMER_IF_DelayMs ( uint32_t delay)

a delay of delay ms by polling RTC

Parameters
delayin ms

Definition at line 359 of file timer_if.c.

References GetTimerTicks(), and TIMER_IF_Convert_ms2Tick().

Referenced by HAL_Delay().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIMER_IF_GetMinimumTimeout()

uint32_t TIMER_IF_GetMinimumTimeout ( void )

Return the minimum timeout in ticks the RTC is able to handle.

Returns
minimum value for a timeout in ticks

Definition at line 320 of file timer_if.c.

References MIN_ALARM_DELAY.

◆ TIMER_IF_GetTime()

uint32_t TIMER_IF_GetTime ( uint16_t * subSeconds)

Get rtc time.

Parameters
[out]subSecondsin ticks
Returns
time seconds

Definition at line 403 of file timer_if.c.

References GetTimerTicks(), RTC_N_PREDIV_S, RTC_PREDIV_S, TIMER_IF_BkUp_Read_MSBticks(), and TIMER_IF_Convert_Tick2ms().

Here is the call graph for this function:

◆ TIMER_IF_GetTimerContext()

uint32_t TIMER_IF_GetTimerContext ( void )

Get the RTC timer Reference.

Returns
Timer Value in Ticks

Definition at line 280 of file timer_if.c.

References RtcTimerContext, and TIMER_IF_DBG_PRINTF.

◆ TIMER_IF_GetTimerElapsedTime()

uint32_t TIMER_IF_GetTimerElapsedTime ( void )

Get the timer elapsed time since timer Reference (TimerContext) was set.

Returns
RTC Elapsed time in ticks

Definition at line 291 of file timer_if.c.

References GetTimerTicks(), and RtcTimerContext.

Here is the call graph for this function:

◆ TIMER_IF_GetTimerValue()

uint32_t TIMER_IF_GetTimerValue ( void )

Get the timer value.

Returns
RTC Timer value in ticks

Definition at line 304 of file timer_if.c.

References GetTimerTicks(), and RTC_Initialized.

Referenced by HAL_GetTick().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIMER_IF_Init()

UTIL_TIMER_Status_t TIMER_IF_Init ( void )

Init RTC hardware.

Returns
Status based on UTIL_TIMER_Status_t

DeActivate the Alarm A enabled by STM32CubeMX during MX_RTC_Init()

Definition at line 183 of file timer_if.c.

References hrtc, MX_RTC_Init(), RTC_Initialized, TIMER_IF_BkUp_Write_MSBticks(), TIMER_IF_SetTimerContext(), TIMER_IF_StopTimer(), and UTIL_TIMER_IRQ_MAP_INIT.

Here is the call graph for this function:

◆ TIMER_IF_SetTimerContext()

uint32_t TIMER_IF_SetTimerContext ( void )

set timer Reference (TimerContext)

Returns
Timer Reference Value in Ticks

Definition at line 266 of file timer_if.c.

References GetTimerTicks(), RtcTimerContext, and TIMER_IF_DBG_PRINTF.

Referenced by TIMER_IF_Init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TIMER_IF_StartTimer()

UTIL_TIMER_Status_t TIMER_IF_StartTimer ( uint32_t timeout)

Set the alarm.

Note
The alarm is set at timeout from timer Reference (TimerContext)
Parameters
timeoutDuration of the Timer in ticks
Returns
Status based on UTIL_TIMER_Status_t

Definition at line 220 of file timer_if.c.

References Error_Handler(), GetTimerTicks(), hrtc, RtcTimerContext, TIMER_IF_DBG_PRINTF, and TIMER_IF_StopTimer().

Here is the call graph for this function:

◆ TIMER_IF_StopTimer()

UTIL_TIMER_Status_t TIMER_IF_StopTimer ( void )

Stop the Alarm.

Returns
Status based on UTIL_TIMER_Status_t

Definition at line 248 of file timer_if.c.

References hrtc.

Referenced by TIMER_IF_Init(), and TIMER_IF_StartTimer().

Here is the caller graph for this function: