L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
timer_if.h
Go to the documentation of this file.
1/* USER CODE BEGIN Header */
2/**
3 ******************************************************************************
4 * @file timer_if.h
5 * @author MCD Application Team
6 * @brief configuration of the timer_if.c instances
7 ******************************************************************************
8 * @attention
9 *
10 * Copyright (c) 2026 STMicroelectronics.
11 * All rights reserved.
12 *
13 * This software is licensed under terms that can be found in the LICENSE file
14 * in the root directory of this software component.
15 * If no LICENSE file comes with this software, it is provided AS-IS.
16 *
17 ******************************************************************************
18 */
19/* USER CODE END Header */
20
21/* Define to prevent recursive inclusion -------------------------------------*/
22#ifndef __TIMER_IF_H__
23#define __TIMER_IF_H__
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29/* Includes ------------------------------------------------------------------*/
30#include "stm32_timer.h"
31#include "stm32_systime.h"
32
33/* USER CODE BEGIN Includes */
34
35/* USER CODE END Includes */
36
37/* Exported types ------------------------------------------------------------*/
38/* USER CODE BEGIN ET */
39
40/* USER CODE END ET */
41
42/* Exported constants --------------------------------------------------------*/
43/* USER CODE BEGIN EC */
44
45/* USER CODE END EC */
46
47/* External variables --------------------------------------------------------*/
48/* USER CODE BEGIN EV */
49
50/* USER CODE END EV */
51
52/* Exported macro ------------------------------------------------------------*/
53/* USER CODE BEGIN EM */
54/**
55 * @brief RTC backup register index used to persist the standby-mode flag
56 * across a system reset / wakeup from OFF (standby) mode.
57 * Written with RTC_BKP_STANDBY_SIGN before entering standby so that
58 * after wakeup the application knows it came from a planned sleep cycle
59 * rather than a cold power-on.
60 */
61#define RTC_BKP_STANDBY RTC_BKP_DR3
62
63/**
64 * @brief Magic value stored in RTC_BKP_STANDBY before entering standby mode.
65 * On wakeup, if getBackUpRegister(RTC_BKP_STANDBY) == RTC_BKP_STANDBY_SIGN,
66 * the device knows it woke from a planned sleep and can skip full
67 * re-initialisation where appropriate.
68 */
69#define RTC_BKP_STANDBY_SIGN 0xABCD
70/* USER CODE END EM */
71
72/* Exported functions prototypes ---------------------------------------------*/
73/**
74 * @brief Init RTC hardware
75 * @return Status based on @ref UTIL_TIMER_Status_t
76 */
77UTIL_TIMER_Status_t TIMER_IF_Init(void);
78
79/**
80 * @brief Set the alarm
81 * @note The alarm is set at timeout from timer Reference (TimerContext)
82 * @param timeout Duration of the Timer in ticks
83 * @return Status based on @ref UTIL_TIMER_Status_t
84 */
85UTIL_TIMER_Status_t TIMER_IF_StartTimer(uint32_t timeout);
86
87/**
88 * @brief Stop the Alarm
89 * @return Status based on @ref UTIL_TIMER_Status_t
90 */
91UTIL_TIMER_Status_t TIMER_IF_StopTimer(void);
92
93/**
94 * @brief set timer Reference (TimerContext)
95 * @return Timer Reference Value in Ticks
96 */
97uint32_t TIMER_IF_SetTimerContext(void);
98
99/**
100 * @brief Get the RTC timer Reference
101 * @return Timer Value in Ticks
102 */
103uint32_t TIMER_IF_GetTimerContext(void);
104
105/**
106 * @brief Get the timer elapsed time since timer Reference (TimerContext) was set
107 * @return RTC Elapsed time in ticks
108 */
109uint32_t TIMER_IF_GetTimerElapsedTime(void);
110
111/**
112 * @brief Get the timer value
113 * @return RTC Timer value in ticks
114 */
115uint32_t TIMER_IF_GetTimerValue(void);
116
117/**
118 * @brief Return the minimum timeout in ticks the RTC is able to handle
119 * @return minimum value for a timeout in ticks
120 */
121uint32_t TIMER_IF_GetMinimumTimeout(void);
122
123/**
124 * @brief a delay of delay ms by polling RTC
125 * @param delay in ms
126 */
127void TIMER_IF_DelayMs(uint32_t delay);
128
129/**
130 * @brief converts time in ms to time in ticks
131 * @param[in] timeMilliSec time in milliseconds
132 * @return time in timer ticks
133 */
134uint32_t TIMER_IF_Convert_ms2Tick(uint32_t timeMilliSec);
135
136/**
137 * @brief converts time in ticks to time in ms
138 * @param[in] tick time in timer ticks
139 * @return time in timer milliseconds
140 */
141uint32_t TIMER_IF_Convert_Tick2ms(uint32_t tick);
142
143/**
144 * @brief Get rtc time
145 * @param[out] subSeconds in ticks
146 * @return time seconds
147 */
148uint32_t TIMER_IF_GetTime(uint16_t *subSeconds);
149
150/**
151 * @brief write seconds in backUp register
152 * @note Used to store seconds difference between RTC time and Unix time
153 * @param[in] Seconds time in seconds
154 */
155void TIMER_IF_BkUp_Write_Seconds(uint32_t Seconds);
156
157/**
158 * @brief reads seconds from backUp register
159 * @note Used to store seconds difference between RTC time and Unix time
160 * @return Time in seconds
161 */
162uint32_t TIMER_IF_BkUp_Read_Seconds(void);
163
164/**
165 * @brief writes SubSeconds in backUp register
166 * @note Used to store SubSeconds difference between RTC time and Unix time
167 * @param[in] SubSeconds time in SubSeconds
168 */
169void TIMER_IF_BkUp_Write_SubSeconds(uint32_t SubSeconds);
170
171/**
172 * @brief reads SubSeconds from backUp register
173 * @note Used to store SubSeconds difference between RTC time and Unix time
174 * @return Time in SubSeconds
175 */
176uint32_t TIMER_IF_BkUp_Read_SubSeconds(void);
177
178/* USER CODE BEGIN EFP */
179
180/* USER CODE END EFP */
181
182#ifdef __cplusplus
183}
184#endif
185
186#endif /* __TIMER_IF_H__ */
uint32_t TIMER_IF_Convert_ms2Tick(uint32_t timeMilliSec)
converts time in ms to time in ticks
Definition timer_if.c:333
void TIMER_IF_DelayMs(uint32_t delay)
a delay of delay ms by polling RTC
Definition timer_if.c:359
uint32_t TIMER_IF_GetTime(uint16_t *subSeconds)
Get rtc time.
Definition timer_if.c:403
uint32_t TIMER_IF_BkUp_Read_Seconds(void)
reads seconds from backUp register
Definition timer_if.c:449
void TIMER_IF_BkUp_Write_Seconds(uint32_t Seconds)
write seconds in backUp register
Definition timer_if.c:427
uint32_t TIMER_IF_Convert_Tick2ms(uint32_t tick)
converts time in ticks to time in ms
Definition timer_if.c:346
uint32_t TIMER_IF_GetTimerElapsedTime(void)
Get the timer elapsed time since timer Reference (TimerContext) was set.
Definition timer_if.c:291
uint32_t TIMER_IF_GetTimerValue(void)
Get the timer value.
Definition timer_if.c:304
UTIL_TIMER_Status_t TIMER_IF_StopTimer(void)
Stop the Alarm.
Definition timer_if.c:248
uint32_t TIMER_IF_GetMinimumTimeout(void)
Return the minimum timeout in ticks the RTC is able to handle.
Definition timer_if.c:320
uint32_t TIMER_IF_BkUp_Read_SubSeconds(void)
reads SubSeconds from backUp register
Definition timer_if.c:462
UTIL_TIMER_Status_t TIMER_IF_StartTimer(uint32_t timeout)
Set the alarm.
Definition timer_if.c:220
uint32_t TIMER_IF_SetTimerContext(void)
set timer Reference (TimerContext)
Definition timer_if.c:266
UTIL_TIMER_Status_t TIMER_IF_Init(void)
Init RTC hardware.
Definition timer_if.c:183
void TIMER_IF_BkUp_Write_SubSeconds(uint32_t SubSeconds)
writes SubSeconds in backUp register
Definition timer_if.c:438
uint32_t TIMER_IF_GetTimerContext(void)
Get the RTC timer Reference.
Definition timer_if.c:280