|
L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
|
Configure RTC Alarm, Tick and Calendar manager. More...
#include <math.h>#include "timer_if.h"#include "main.h"#include "rtc.h"#include "utilities_def.h"#include "stm32wlxx_ll_rtc.h"Go to the source code of this file.
Macros | |
| #define | MIN_ALARM_DELAY 3 |
| Minimum timeout delay of Alarm in ticks. | |
| #define | RTC_BKP_SECONDS RTC_BKP_DR0 |
| Backup seconds register. | |
| #define | RTC_BKP_SUBSECONDS RTC_BKP_DR1 |
| Backup subseconds register. | |
| #define | RTC_BKP_MSBTICKS RTC_BKP_DR2 |
| Backup msbticks register. | |
| #define | UTIL_TIMER_IRQ_MAP_INIT() |
| Map UTIL_TIMER_IRQ can be overridden in utilities_conf.h to Map on Task rather then Isr. | |
| #define | UTIL_TIMER_IRQ_MAP_PROCESS() |
| #define | TIMER_IF_DBG_PRINTF(...) |
| not used | |
Functions | |
| static uint32_t | GetTimerTicks (void) |
| Get rtc timer Value in rtc tick. | |
| static void | TIMER_IF_BkUp_Write_MSBticks (uint32_t MSBticks) |
| Writes MSBticks to backup register Absolute RTC time in tick is (MSBticks)<<32 + (32bits binary counter). | |
| static uint32_t | TIMER_IF_BkUp_Read_MSBticks (void) |
| Reads MSBticks from backup register Absolute RTC time in tick is (MSBticks)<<32 + (32bits binary counter). | |
| 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. | |
| 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 | |
| void | TIMER_IF_DelayMs (uint32_t delay) |
| a delay of delay ms by polling RTC | |
| void | HAL_RTC_AlarmAEventCallback (RTC_HandleTypeDef *hrtc) |
| void | HAL_RTCEx_SSRUEventCallback (RTC_HandleTypeDef *hrtc) |
| uint32_t | TIMER_IF_GetTime (uint16_t *mSeconds) |
| Get rtc time. | |
| void | TIMER_IF_BkUp_Write_Seconds (uint32_t Seconds) |
| write seconds in backUp register | |
| void | TIMER_IF_BkUp_Write_SubSeconds (uint32_t SubSeconds) |
| writes SubSeconds in backUp register | |
| uint32_t | TIMER_IF_BkUp_Read_Seconds (void) |
| reads seconds from backUp register | |
| uint32_t | TIMER_IF_BkUp_Read_SubSeconds (void) |
| reads SubSeconds from backUp register | |
Variables | |
| RTC_HandleTypeDef | hrtc |
| RTC handle. | |
| const UTIL_TIMER_Driver_s | UTIL_TimerDriver |
| Timer driver callbacks handler. | |
| const UTIL_SYSTIM_Driver_s | UTIL_SYSTIMDriver |
| SysTime driver callbacks handler. | |
| static bool | RTC_Initialized = false |
| Indicates if the RTC is already Initialized or not. | |
| static uint32_t | RtcTimerContext = 0 |
| RtcTimerContext. | |
Configure RTC Alarm, Tick and Calendar manager.
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.c.
| #define MIN_ALARM_DELAY 3 |
Minimum timeout delay of Alarm in ticks.
Definition at line 86 of file timer_if.c.
Referenced by TIMER_IF_GetMinimumTimeout().
| #define RTC_BKP_MSBTICKS RTC_BKP_DR2 |
Backup msbticks register.
Definition at line 101 of file timer_if.c.
Referenced by TIMER_IF_BkUp_Read_MSBticks(), and TIMER_IF_BkUp_Write_MSBticks().
| #define RTC_BKP_SECONDS RTC_BKP_DR0 |
Backup seconds register.
Definition at line 91 of file timer_if.c.
Referenced by TIMER_IF_BkUp_Read_Seconds(), and TIMER_IF_BkUp_Write_Seconds().
| #define RTC_BKP_SUBSECONDS RTC_BKP_DR1 |
Backup subseconds register.
Definition at line 96 of file timer_if.c.
Referenced by TIMER_IF_BkUp_Read_SubSeconds(), and TIMER_IF_BkUp_Write_SubSeconds().
| #define TIMER_IF_DBG_PRINTF | ( | ... | ) |
not used
Definition at line 133 of file timer_if.c.
Referenced by HAL_RTCEx_SSRUEventCallback(), TIMER_IF_GetTimerContext(), TIMER_IF_SetTimerContext(), and TIMER_IF_StartTimer().
| #define UTIL_TIMER_IRQ_MAP_INIT | ( | ) |
Map UTIL_TIMER_IRQ can be overridden in utilities_conf.h to Map on Task rather then Isr.
Definition at line 109 of file timer_if.c.
Referenced by TIMER_IF_Init().
| #define UTIL_TIMER_IRQ_MAP_PROCESS | ( | ) |
Definition at line 113 of file timer_if.c.
Referenced by HAL_RTC_AlarmAEventCallback().
|
inlinestatic |
Get rtc timer Value in rtc tick.
Definition at line 504 of file timer_if.c.
Referenced by HAL_RTCEx_SSRUEventCallback(), TIMER_IF_DelayMs(), TIMER_IF_GetTime(), TIMER_IF_GetTimerElapsedTime(), TIMER_IF_GetTimerValue(), TIMER_IF_SetTimerContext(), and TIMER_IF_StartTimer().
| void HAL_RTC_AlarmAEventCallback | ( | RTC_HandleTypeDef * | hrtc | ) |
Definition at line 377 of file timer_if.c.
References hrtc, and UTIL_TIMER_IRQ_MAP_PROCESS.
| void HAL_RTCEx_SSRUEventCallback | ( | RTC_HandleTypeDef * | hrtc | ) |
Definition at line 388 of file timer_if.c.
References GetTimerTicks(), hrtc, TIMER_IF_BkUp_Read_MSBticks(), TIMER_IF_BkUp_Write_MSBticks(), and TIMER_IF_DBG_PRINTF.
|
static |
Reads MSBticks from backup register Absolute RTC time in tick is (MSBticks)<<32 + (32bits binary counter).
| MSBticks |
Definition at line 491 of file timer_if.c.
References hrtc, and RTC_BKP_MSBTICKS.
Referenced by HAL_RTCEx_SSRUEventCallback(), and TIMER_IF_GetTime().
| uint32_t TIMER_IF_BkUp_Read_Seconds | ( | void | ) |
reads seconds from backUp register
Definition at line 449 of file timer_if.c.
References hrtc, and RTC_BKP_SECONDS.
| uint32_t TIMER_IF_BkUp_Read_SubSeconds | ( | void | ) |
reads SubSeconds from backUp register
Definition at line 462 of file timer_if.c.
References hrtc, and RTC_BKP_SUBSECONDS.
|
static |
Writes MSBticks to backup register Absolute RTC time in tick is (MSBticks)<<32 + (32bits binary counter).
| [in] | MSBticks |
Definition at line 480 of file timer_if.c.
References hrtc, and RTC_BKP_MSBTICKS.
Referenced by HAL_RTCEx_SSRUEventCallback(), and TIMER_IF_Init().
| void TIMER_IF_BkUp_Write_Seconds | ( | uint32_t | Seconds | ) |
write seconds in backUp register
| [in] | Seconds | time in seconds |
Definition at line 427 of file timer_if.c.
References hrtc, and RTC_BKP_SECONDS.
| void TIMER_IF_BkUp_Write_SubSeconds | ( | uint32_t | SubSeconds | ) |
writes SubSeconds in backUp register
| [in] | SubSeconds | time in SubSeconds |
Definition at line 438 of file timer_if.c.
References hrtc, and RTC_BKP_SUBSECONDS.
| uint32_t TIMER_IF_Convert_ms2Tick | ( | uint32_t | timeMilliSec | ) |
converts time in ms to time in ticks
| [in] | timeMilliSec | time in milliseconds |
Definition at line 333 of file timer_if.c.
References RTC_N_PREDIV_S.
Referenced by TIMER_IF_DelayMs().
| uint32_t TIMER_IF_Convert_Tick2ms | ( | uint32_t | tick | ) |
converts time in ticks to time in ms
| [in] | tick | time in timer ticks |
Definition at line 346 of file timer_if.c.
References RTC_N_PREDIV_S.
Referenced by TIMER_IF_GetTime().
| void TIMER_IF_DelayMs | ( | uint32_t | delay | ) |
a delay of delay ms by polling RTC
| delay | in ms |
Definition at line 359 of file timer_if.c.
References GetTimerTicks(), and TIMER_IF_Convert_ms2Tick().
Referenced by HAL_Delay().
| uint32_t TIMER_IF_GetMinimumTimeout | ( | void | ) |
Return the minimum timeout in ticks the RTC is able to handle.
Definition at line 320 of file timer_if.c.
References MIN_ALARM_DELAY.
| uint32_t TIMER_IF_GetTime | ( | uint16_t * | subSeconds | ) |
Get rtc time.
| [out] | subSeconds | in ticks |
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().
| uint32_t TIMER_IF_GetTimerContext | ( | void | ) |
Get the RTC timer Reference.
Definition at line 280 of file timer_if.c.
References RtcTimerContext, and TIMER_IF_DBG_PRINTF.
| uint32_t TIMER_IF_GetTimerElapsedTime | ( | void | ) |
Get the timer elapsed time since timer Reference (TimerContext) was set.
Definition at line 291 of file timer_if.c.
References GetTimerTicks(), and RtcTimerContext.
| uint32_t TIMER_IF_GetTimerValue | ( | void | ) |
Get the timer value.
Definition at line 304 of file timer_if.c.
References GetTimerTicks(), and RTC_Initialized.
Referenced by HAL_GetTick().
| UTIL_TIMER_Status_t TIMER_IF_Init | ( | void | ) |
Init RTC hardware.
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.
| uint32_t TIMER_IF_SetTimerContext | ( | void | ) |
set timer Reference (TimerContext)
Definition at line 266 of file timer_if.c.
References GetTimerTicks(), RtcTimerContext, and TIMER_IF_DBG_PRINTF.
Referenced by TIMER_IF_Init().
| UTIL_TIMER_Status_t TIMER_IF_StartTimer | ( | uint32_t | timeout | ) |
Set the alarm.
| timeout | Duration of the Timer in ticks |
Definition at line 220 of file timer_if.c.
References Error_Handler(), GetTimerTicks(), hrtc, RtcTimerContext, TIMER_IF_DBG_PRINTF, and TIMER_IF_StopTimer().
| UTIL_TIMER_Status_t TIMER_IF_StopTimer | ( | void | ) |
Stop the Alarm.
Definition at line 248 of file timer_if.c.
References hrtc.
Referenced by TIMER_IF_Init(), and TIMER_IF_StartTimer().
|
static |
Indicates if the RTC is already Initialized or not.
Definition at line 144 of file timer_if.c.
Referenced by TIMER_IF_GetTimerValue(), and TIMER_IF_Init().
|
static |
RtcTimerContext.
Definition at line 149 of file timer_if.c.
Referenced by TIMER_IF_GetTimerContext(), TIMER_IF_GetTimerElapsedTime(), TIMER_IF_SetTimerContext(), and TIMER_IF_StartTimer().
| const UTIL_SYSTIM_Driver_s UTIL_SYSTIMDriver |
SysTime driver callbacks handler.
Definition at line 64 of file timer_if.c.
| const UTIL_TIMER_Driver_s UTIL_TimerDriver |
Timer driver callbacks handler.
Definition at line 42 of file timer_if.c.