VSF Documented
sthal_rtc.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2024 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __ST_HAL_RTC_H__
19#define __ST_HAL_RTC_H__
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/*============================ INCLUDES ======================================*/
26
27#include "sthal_def.h"
28
29/*============================ MACROS ========================================*/
30/*============================ MACROFIED FUNCTIONS ===========================*/
31/*============================ TYPES =========================================*/
32
34
35typedef enum {
42
43typedef struct {
51
52typedef struct {
62
63typedef struct {
69
70typedef struct {
78
79#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
80typedef struct __RTC_HandleTypeDef {
81#else
82typedef struct {
83#endif
88#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
89 void (*AlarmAEventCallback)(struct __RTC_HandleTypeDef *hrtc);
90 void (*AlarmBEventCallback)(struct __RTC_HandleTypeDef *hrtc);
91 void (*TimeStampEventCallback)(struct __RTC_HandleTypeDef *hrtc);
92 void (*WakeUpTimerEventCallback)(struct __RTC_HandleTypeDef *hrtc);
93 void (*Tamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc);
94# if defined(RTC_TAMPER2_SUPPORT)
95 void (*Tamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc);
96# endif
97 void (*MspInitCallback)(struct __RTC_HandleTypeDef *hrtc);
98 void (*MspDeInitCallback)(struct __RTC_HandleTypeDef *hrtc);
99#endif
101
102#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
103typedef enum {
104 HAL_RTC_ALARM_A_EVENT_CB_ID = 0x00U,
105 HAL_RTC_ALARM_B_EVENT_CB_ID = 0x01U,
106 HAL_RTC_TIMESTAMP_EVENT_CB_ID = 0x02U,
107 HAL_RTC_WAKEUPTIMER_EVENT_CB_ID = 0x03U,
108 HAL_RTC_TAMPER1_EVENT_CB_ID = 0x04U,
109# if defined(RTC_TAMPER2_SUPPORT)
110 HAL_RTC_TAMPER2_EVENT_CB_ID = 0x05U,
111# endif
112 HAL_RTC_MSPINIT_CB_ID = 0x0EU,
113 HAL_RTC_MSPDEINIT_CB_ID = 0x0FU,
114} HAL_RTC_CallbackIDTypeDef;
115
116typedef void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef *hrtc);
117#endif
118
119typedef struct {
129
130/*============================ GLOBAL VARIABLES ==============================*/
131/*============================ PROTOTYPES ====================================*/
132
137
138#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
139HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc,
140 HAL_RTC_CallbackIDTypeDef CallbackID,
141 pRTC_CallbackTypeDef pCallback);
142HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(
143 RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID);
144#endif
145
147 RTC_TimeTypeDef *sTime, uint32_t Format);
149 RTC_TimeTypeDef *sTime, uint32_t Format);
151 RTC_DateTypeDef *sDate, uint32_t Format);
153 RTC_DateTypeDef *sDate, uint32_t Format);
154
156 RTC_AlarmTypeDef *sAlarm, uint32_t Format);
158 RTC_AlarmTypeDef *sAlarm,
159 uint32_t Format);
161 uint32_t Alarm);
163 RTC_AlarmTypeDef *sAlarm, uint32_t Alarm,
164 uint32_t Format);
167 uint32_t Timeout);
169
171
177
179
184
186 uint32_t RTC_TimeStampEdge,
187 uint32_t RTC_TimeStampPin);
189 uint32_t RTC_TimeStampEdge,
190 uint32_t RTC_TimeStampPin);
193 RTC_TimeTypeDef *sTimeStamp,
194 RTC_DateTypeDef *sTimeStampDate,
195 uint32_t Format);
196
198 RTC_TamperTypeDef *sTamper);
200 RTC_TamperTypeDef *sTamper);
202 uint32_t Tamper);
204
206#if defined(RTC_TAMPER2_SUPPORT)
207void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc);
208#endif /* RTC_TAMPER2_SUPPORT */
211 uint32_t Timeout);
213 uint32_t Timeout);
214#if defined(RTC_TAMPER2_SUPPORT)
215HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc,
216 uint32_t Timeout);
217#endif /* RTC_TAMPER2_SUPPORT */
218
220 uint32_t WakeUpCounter,
221 uint32_t WakeUpClock);
223 uint32_t WakeUpCounter,
224 uint32_t WakeUpClock);
230 uint32_t Timeout);
231void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister,
232 uint32_t Data);
234
236 uint32_t CalibSign, uint32_t Value);
239 RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod,
240 uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue);
242 uint32_t ShiftAdd1S,
243 uint32_t ShiftSubFS);
245 uint32_t CalibOutput);
247 RTC_HandleTypeDef *hrtc);
254 uint32_t Timeout);
255
256#ifdef __cplusplus
257}
258#endif
259
260#endif
unsigned uint32_t
Definition stdint.h:9
unsigned char uint8_t
Definition stdint.h:5
HAL_StatusTypeDef
Definition sthal_def.h:65
HAL_LockTypeDef
Definition sthal_def.h:72
HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS)
Definition sthal_rtc.c:446
HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format)
Definition sthal_rtc.c:206
HAL_StatusTypeDef HAL_RTCEx_SetCoarseCalib(RTC_HandleTypeDef *hrtc, uint32_t CalibSign, uint32_t Value)
Definition sthal_rtc.c:426
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:240
HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
Definition sthal_rtc.c:409
HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm)
Definition sthal_rtc.c:224
HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:315
HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:43
void HAL_RTC_DST_Add1Hour(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:256
uint8_t RTC_ByteToBcd2(uint8_t number)
Definition sthal_rtc.c:284
HAL_StatusTypeDef RTC_ExitInitMode(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:279
uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister)
Definition sthal_rtc.c:421
HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue)
Definition sthal_rtc.c:438
HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format)
Definition sthal_rtc.c:230
HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper)
Definition sthal_rtc.c:336
HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper)
Definition sthal_rtc.c:329
HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc)
HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:274
HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:269
HAL_StatusTypeDef HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:394
void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:405
HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:251
HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, RTC_DateTypeDef *sTimeStampDate, uint32_t Format)
Definition sthal_rtc.c:320
HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format)
Definition sthal_rtc.c:200
void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:350
HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:474
HAL_StatusTypeDef HAL_RTCEx_DeactivateCoarseCalib(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:433
uint8_t RTC_Bcd2ToByte(uint8_t number)
Definition sthal_rtc.c:295
void HAL_RTC_DST_Sub1Hour(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:258
HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:468
void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:183
HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock)
Definition sthal_rtc.c:386
uint32_t HAL_RTC_DST_ReadStoreOperation(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:264
void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:486
HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t RTC_TimeStampEdge, uint32_t RTC_TimeStampPin)
Definition sthal_rtc.c:302
HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t RTC_TimeStampEdge, uint32_t RTC_TimeStampPin)
Definition sthal_rtc.c:308
HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:33
HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:480
HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock)
Definition sthal_rtc.c:378
HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format)
Definition sthal_rtc.c:218
void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:237
void HAL_RTC_DST_ClearStoreOperation(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:262
void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:407
void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:357
void HAL_RTC_DST_SetStoreOperation(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:260
HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:462
void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:352
HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
Definition sthal_rtc.c:365
uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:400
HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format)
Definition sthal_rtc.c:194
HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
Definition sthal_rtc.c:488
HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
Definition sthal_rtc.c:245
void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc)
Definition sthal_rtc.c:177
HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper)
Definition sthal_rtc.c:343
void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data)
Definition sthal_rtc.c:416
HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format)
Definition sthal_rtc.c:212
HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format)
Definition sthal_rtc.c:188
HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput)
Definition sthal_rtc.c:453
HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
Definition sthal_rtc.c:359
vsf_rtc_t RTC_TypeDef
Definition sthal_rtc.h:33
HAL_RTCStateTypeDef
Definition sthal_rtc.h:35
@ HAL_RTC_STATE_TIMEOUT
Definition sthal_rtc.h:39
@ HAL_RTC_STATE_ERROR
Definition sthal_rtc.h:40
@ HAL_RTC_STATE_READY
Definition sthal_rtc.h:37
@ HAL_RTC_STATE_BUSY
Definition sthal_rtc.h:38
@ HAL_RTC_STATE_RESET
Definition sthal_rtc.h:36
Definition sthal_rtc.h:70
uint8_t AlarmDateWeekDay
Definition sthal_rtc.h:75
RTC_TimeTypeDef AlarmTime
Definition sthal_rtc.h:71
uint32_t Alarm
Definition sthal_rtc.h:76
uint32_t AlarmDateWeekDaySel
Definition sthal_rtc.h:74
uint32_t AlarmMask
Definition sthal_rtc.h:72
uint32_t AlarmSubSecondMask
Definition sthal_rtc.h:73
Definition sthal_rtc.h:63
uint8_t Year
Definition sthal_rtc.h:67
uint8_t Month
Definition sthal_rtc.h:65
uint8_t Date
Definition sthal_rtc.h:66
uint8_t WeekDay
Definition sthal_rtc.h:64
Definition sthal_rtc.h:82
volatile HAL_RTCStateTypeDef State
Definition sthal_rtc.h:87
RTC_TypeDef * Instance
Definition sthal_rtc.h:84
RTC_InitTypeDef Init
Definition sthal_rtc.h:85
HAL_LockTypeDef Lock
Definition sthal_rtc.h:86
Definition sthal_rtc.h:43
uint32_t OutPutPolarity
Definition sthal_rtc.h:48
uint32_t OutPutType
Definition sthal_rtc.h:49
uint32_t AsynchPrediv
Definition sthal_rtc.h:45
uint32_t HourFormat
Definition sthal_rtc.h:44
uint32_t SynchPrediv
Definition sthal_rtc.h:46
uint32_t OutPut
Definition sthal_rtc.h:47
Definition sthal_rtc.h:119
uint32_t Trigger
Definition sthal_rtc.h:122
uint32_t SamplingFrequency
Definition sthal_rtc.h:124
uint32_t Filter
Definition sthal_rtc.h:123
uint32_t PinSelection
Definition sthal_rtc.h:121
uint32_t TamperPullUp
Definition sthal_rtc.h:126
uint32_t Tamper
Definition sthal_rtc.h:120
uint32_t PrechargeDuration
Definition sthal_rtc.h:125
uint32_t TimeStampOnTamperDetection
Definition sthal_rtc.h:127
Definition sthal_rtc.h:52
uint8_t Seconds
Definition sthal_rtc.h:55
uint8_t Minutes
Definition sthal_rtc.h:54
uint8_t TimeFormat
Definition sthal_rtc.h:56
uint32_t StoreOperation
Definition sthal_rtc.h:60
uint32_t SecondFraction
Definition sthal_rtc.h:58
uint32_t DayLightSaving
Definition sthal_rtc.h:59
uint32_t SubSeconds
Definition sthal_rtc.h:57
uint8_t Hours
Definition sthal_rtc.h:53
Definition vsf_template_rtc.h:160