27#include "stm32wlxx_ll_rtc.h"
37extern RTC_HandleTypeDef
hrtc;
86#define MIN_ALARM_DELAY 3
91#define RTC_BKP_SECONDS RTC_BKP_DR0
96#define RTC_BKP_SUBSECONDS RTC_BKP_DR1
101#define RTC_BKP_MSBTICKS RTC_BKP_DR2
108#ifndef UTIL_TIMER_IRQ_MAP_INIT
109#define UTIL_TIMER_IRQ_MAP_INIT()
112#ifndef UTIL_TIMER_IRQ_MAP_PROCESS
113#define UTIL_TIMER_IRQ_MAP_PROCESS() UTIL_TIMER_IRQ_Handler()
128#define TIMER_IF_DBG_PRINTF(...) do{ {UTIL_ADV_TRACE_COND_FSend(VLEVEL_ALWAYS, T_REG_OFF, TS_OFF, __VA_ARGS__);} }while(0);
133#define TIMER_IF_DBG_PRINTF(...)
185 UTIL_TIMER_Status_t ret = UTIL_TIMER_OK;
191 hrtc.IsEnabled.RtcFeatures = UINT32_MAX;
197 HAL_RTC_DeactivateAlarm(&
hrtc, RTC_ALARM_A);
199 hrtc.IsEnabled.RtcFeatures = UINT32_MAX;
202 HAL_RTCEx_EnableBypassShadow(&
hrtc);
222 UTIL_TIMER_Status_t ret = UTIL_TIMER_OK;
226 RTC_AlarmTypeDef sAlarm = {0};
233 sAlarm.BinaryAutoClr = RTC_ALARMSUBSECONDBIN_AUTOCLR_NO;
234 sAlarm.AlarmTime.SubSeconds = UINT32_MAX - timeout;
235 sAlarm.AlarmMask = RTC_ALARMMASK_NONE;
236 sAlarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDBINMASK_NONE;
237 sAlarm.Alarm = RTC_ALARM_A;
238 if (HAL_RTC_SetAlarm_IT(&
hrtc, &sAlarm, RTC_FORMAT_BCD) != HAL_OK)
250 UTIL_TIMER_Status_t ret = UTIL_TIMER_OK;
255 __HAL_RTC_ALARM_CLEAR_FLAG(&
hrtc, RTC_FLAG_ALRAF);
257 HAL_RTC_DeactivateAlarm(&
hrtc, RTC_ALARM_A);
259 hrtc.IsEnabled.RtcFeatures = UINT32_MAX;
339 ret = ((uint32_t)((((uint64_t) timeMilliSec) <<
RTC_N_PREDIV_S) / 1000));
352 ret = ((uint32_t)((((uint64_t)(tick)) * 1000) >>
RTC_N_PREDIV_S));
405 uint32_t seconds = 0;
413 ticks = (((uint64_t) timerValueMSB) << 32) + timerValueLsb;
509 uint32_t ssr = LL_RTC_TIME_GetSubSecond(RTC);
511 while (ssr != LL_RTC_TIME_GetSubSecond(RTC))
513 ssr = LL_RTC_TIME_GetSubSecond(RTC);
515 return UINT32_MAX - ssr;
: Header for main.c file. This file contains the common defines of the application.
void Error_Handler(void)
Default error handler called by HAL on unrecoverable errors. Disables interrupts and enters an infini...
This file contains all the function prototypes for the rtc.c file.
void MX_RTC_Init(void)
Initialise the RTC peripheral with settings generated by STM32CubeMX. Configures the prescalers,...
Function prototypes for sys_app.c file.
uint32_t TIMER_IF_Convert_ms2Tick(uint32_t timeMilliSec)
converts time in ms to time in ticks
const UTIL_TIMER_Driver_s UTIL_TimerDriver
Timer driver callbacks handler.
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)
static uint32_t GetTimerTicks(void)
Get rtc timer Value in rtc tick.
void TIMER_IF_DelayMs(uint32_t delay)
a delay of delay ms by polling RTC
uint32_t TIMER_IF_BkUp_Read_Seconds(void)
reads seconds from backUp register
void TIMER_IF_BkUp_Write_Seconds(uint32_t Seconds)
write seconds in backUp register
#define TIMER_IF_DBG_PRINTF(...)
not used
const UTIL_SYSTIM_Driver_s UTIL_SYSTIMDriver
SysTime driver callbacks handler.
uint32_t TIMER_IF_Convert_Tick2ms(uint32_t tick)
converts time in ticks to time in ms
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.
#define RTC_BKP_MSBTICKS
Backup msbticks register.
#define RTC_BKP_SECONDS
Backup seconds register.
#define UTIL_TIMER_IRQ_MAP_PROCESS()
void HAL_RTCEx_SSRUEventCallback(RTC_HandleTypeDef *hrtc)
UTIL_TIMER_Status_t TIMER_IF_StopTimer(void)
Stop the Alarm.
#define RTC_BKP_SUBSECONDS
Backup subseconds register.
uint32_t TIMER_IF_GetMinimumTimeout(void)
Return the minimum timeout in ticks the RTC is able to handle.
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 count...
static uint32_t TIMER_IF_BkUp_Read_MSBticks(void)
Reads MSBticks from backup register Absolute RTC time in tick is (MSBticks)<<32 + (32bits binary coun...
#define MIN_ALARM_DELAY
Minimum timeout delay of Alarm in ticks.
#define UTIL_TIMER_IRQ_MAP_INIT()
Map UTIL_TIMER_IRQ can be overridden in utilities_conf.h to Map on Task rather then Isr.
uint32_t TIMER_IF_GetTime(uint16_t *mSeconds)
Get rtc time.
uint32_t TIMER_IF_BkUp_Read_SubSeconds(void)
reads SubSeconds from backUp register
UTIL_TIMER_Status_t TIMER_IF_StartTimer(uint32_t timeout)
Set the alarm.
static uint32_t RtcTimerContext
RtcTimerContext.
uint32_t TIMER_IF_SetTimerContext(void)
set timer Reference (TimerContext)
UTIL_TIMER_Status_t TIMER_IF_Init(void)
Init RTC hardware.
void TIMER_IF_BkUp_Write_SubSeconds(uint32_t SubSeconds)
writes SubSeconds in backUp register
uint32_t TIMER_IF_GetTimerContext(void)
Get the RTC timer Reference.
static bool RTC_Initialized
Indicates if the RTC is already Initialized or not.
configuration of the timer_if.c instances
uint32_t TIMER_IF_Convert_ms2Tick(uint32_t timeMilliSec)
converts time in ms to time in ticks
uint32_t TIMER_IF_GetTime(uint16_t *subSeconds)
Get rtc time.
uint32_t TIMER_IF_BkUp_Read_Seconds(void)
reads seconds from backUp register
void TIMER_IF_BkUp_Write_Seconds(uint32_t Seconds)
write seconds in backUp register
uint32_t TIMER_IF_Convert_Tick2ms(uint32_t tick)
converts time in ticks to time in ms
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.
UTIL_TIMER_Status_t TIMER_IF_StopTimer(void)
Stop the Alarm.
uint32_t TIMER_IF_GetMinimumTimeout(void)
Return the minimum timeout in ticks the RTC is able to handle.
uint32_t TIMER_IF_BkUp_Read_SubSeconds(void)
reads SubSeconds from backUp register
UTIL_TIMER_Status_t TIMER_IF_StartTimer(uint32_t timeout)
Set the alarm.
uint32_t TIMER_IF_SetTimerContext(void)
set timer Reference (TimerContext)
UTIL_TIMER_Status_t TIMER_IF_Init(void)
Init RTC hardware.
void TIMER_IF_BkUp_Write_SubSeconds(uint32_t SubSeconds)
writes SubSeconds in backUp register
uint32_t TIMER_IF_GetTimerContext(void)
Get the RTC timer Reference.
Definitions for modules requiring utilities.