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*/
71/* USER CODE END EM */
72
73/* Exported functions prototypes ---------------------------------------------*/
74/**
75 * @brief Init RTC hardware
76 * @return Status based on @ref UTIL_TIMER_Status_t
77 */
78UTIL_TIMER_Status_t TIMER_IF_Init(void);
79
80/**
81 * @brief Set the alarm
82 * @note The alarm is set at timeout from timer Reference (TimerContext)
83 * @param timeout Duration of the Timer in ticks
84 * @return Status based on @ref UTIL_TIMER_Status_t
85 */
86UTIL_TIMER_Status_t TIMER_IF_StartTimer(uint32_t timeout);
87
88/**
89 * @brief Stop the Alarm
90 * @return Status based on @ref UTIL_TIMER_Status_t
91 */
92UTIL_TIMER_Status_t TIMER_IF_StopTimer(void);
93
94/**
95 * @brief set timer Reference (TimerContext)
96 * @return Timer Reference Value in Ticks
97 */
98uint32_t TIMER_IF_SetTimerContext(void);
99
100/**
101 * @brief Get the RTC timer Reference
102 * @return Timer Value in Ticks
103 */
104uint32_t TIMER_IF_GetTimerContext(void);
105
106/**
107 * @brief Get the timer elapsed time since timer Reference (TimerContext) was set
108 * @return RTC Elapsed time in ticks
109 */
110uint32_t TIMER_IF_GetTimerElapsedTime(void);
111
112/**
113 * @brief Get the timer value
114 * @return RTC Timer value in ticks
115 */
116uint32_t TIMER_IF_GetTimerValue(void);
117
118/**
119 * @brief Return the minimum timeout in ticks the RTC is able to handle
120 * @return minimum value for a timeout in ticks
121 */
122uint32_t TIMER_IF_GetMinimumTimeout(void);
123
124/**
125 * @brief a delay of delay ms by polling RTC
126 * @param delay in ms
127 */
128void TIMER_IF_DelayMs(uint32_t delay);
129
130/**
131 * @brief converts time in ms to time in ticks
132 * @param[in] timeMilliSec time in milliseconds
133 * @return time in timer ticks
134 */
135uint32_t TIMER_IF_Convert_ms2Tick(uint32_t timeMilliSec);
136
137/**
138 * @brief converts time in ticks to time in ms
139 * @param[in] tick time in timer ticks
140 * @return time in timer milliseconds
141 */
142uint32_t TIMER_IF_Convert_Tick2ms(uint32_t tick);
143
144/**
145 * @brief Get rtc time
146 * @param[out] subSeconds in ticks
147 * @return time seconds
148 */
149uint32_t TIMER_IF_GetTime(uint16_t *subSeconds);
150
151/**
152 * @brief write seconds in backUp register
153 * @note Used to store seconds difference between RTC time and Unix time
154 * @param[in] Seconds time in seconds
155 */
156void TIMER_IF_BkUp_Write_Seconds(uint32_t Seconds);
157
158/**
159 * @brief reads seconds from backUp register
160 * @note Used to store seconds difference between RTC time and Unix time
161 * @return Time in seconds
162 */
163uint32_t TIMER_IF_BkUp_Read_Seconds(void);
164
165/**
166 * @brief writes SubSeconds in backUp register
167 * @note Used to store SubSeconds difference between RTC time and Unix time
168 * @param[in] SubSeconds time in SubSeconds
169 */
170void TIMER_IF_BkUp_Write_SubSeconds(uint32_t SubSeconds);
171
172/**
173 * @brief reads SubSeconds from backUp register
174 * @note Used to store SubSeconds difference between RTC time and Unix time
175 * @return Time in SubSeconds
176 */
177uint32_t TIMER_IF_BkUp_Read_SubSeconds(void);
178
179/* USER CODE BEGIN EFP */
180
181/* USER CODE END EFP */
182
183#ifdef __cplusplus
184}
185#endif
186
187#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)
RTC backup register index used to persist the standby-mode flag across a system reset / wakeup from O...
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