Subversion Repositories DashDisplay

Rev

Rev 61 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
56 mjames 1
/**
2
  ******************************************************************************
3
  * @file    stm32l1xx_hal_rtc.h
4
  * @author  MCD Application Team
5
  * @brief   Header file of RTC HAL module.
6
  ******************************************************************************
7
  * @attention
8
  *
9
  * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
10
  * All rights reserved.</center></h2>
11
  *
12
  * This software component is licensed by ST under BSD 3-Clause license,
13
  * the "License"; You may not use this file except in compliance with the
14
  * License. You may obtain a copy of the License at:
15
  *                        opensource.org/licenses/BSD-3-Clause
16
  *
17
  ******************************************************************************
18
  */
19
 
20
/* Define to prevent recursive inclusion -------------------------------------*/
21
#ifndef __STM32L1xx_HAL_RTC_H
22
#define __STM32L1xx_HAL_RTC_H
23
 
24
#ifdef __cplusplus
25
extern "C" {
26
#endif
27
 
28
/* Includes ------------------------------------------------------------------*/
29
#include "stm32l1xx_hal_def.h"
30
 
31
/** @addtogroup STM32L1xx_HAL_Driver
32
  * @{
33
  */
34
 
35
/** @defgroup RTC RTC
36
  * @{
37
  */
38
 
39
/* Exported types ------------------------------------------------------------*/
40
/** @defgroup RTC_Exported_Types RTC Exported Types
41
  * @{
42
  */
43
 
44
/**
45
  * @brief  HAL State structures definition
46
  */
47
typedef enum
48
{
49
  HAL_RTC_STATE_RESET             = 0x00U,  /*!< RTC not yet initialized or disabled */
50
  HAL_RTC_STATE_READY             = 0x01U,  /*!< RTC initialized and ready for use   */
51
  HAL_RTC_STATE_BUSY              = 0x02U,  /*!< RTC process is ongoing              */
52
  HAL_RTC_STATE_TIMEOUT           = 0x03U,  /*!< RTC timeout state                   */
53
  HAL_RTC_STATE_ERROR             = 0x04U   /*!< RTC error state                     */
54
 
55
} HAL_RTCStateTypeDef;
56
 
57
/**
58
  * @brief  RTC Configuration Structure definition
59
  */
60
typedef struct
61
{
62
  uint32_t HourFormat;      /*!< Specifies the RTC Hour Format.
63
                                 This parameter can be a value of @ref RTC_Hour_Formats */
64
 
65
  uint32_t AsynchPrediv;    /*!< Specifies the RTC Asynchronous Predivider value.
66
                                 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F */
67
 
68
  uint32_t SynchPrediv;     /*!< Specifies the RTC Synchronous Predivider value.
69
                                 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF */
70
 
71
  uint32_t OutPut;          /*!< Specifies which signal will be routed to the RTC output.
72
                                 This parameter can be a value of @ref RTCEx_Output_selection_Definitions */
73
 
74
  uint32_t OutPutPolarity;  /*!< Specifies the polarity of the output signal.
75
                                 This parameter can be a value of @ref RTC_Output_Polarity_Definitions */
76
 
77
  uint32_t OutPutType;      /*!< Specifies the RTC Output Pin mode.
78
                                 This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */
79
} RTC_InitTypeDef;
80
 
81
/**
82
  * @brief  RTC Time structure definition
83
  */
84
typedef struct
85
{
86
  uint8_t Hours;            /*!< Specifies the RTC Time Hour.
87
                                 This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected.
88
                                 This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected  */
89
 
90
  uint8_t Minutes;          /*!< Specifies the RTC Time Minutes.
91
                                 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
92
 
93
  uint8_t Seconds;          /*!< Specifies the RTC Time Seconds.
94
                                 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
95
 
96
  uint8_t TimeFormat;       /*!< Specifies the RTC AM/PM Time.
97
                                 This parameter can be a value of @ref RTC_AM_PM_Definitions */
98
 
99
#if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
100
  uint32_t SubSeconds;     /*!< Specifies the RTC_SSR RTC Sub Second register content.
101
                                 This parameter corresponds to a time unit range between [0-1] Second
102
                                 with [1 Sec / SecondFraction +1] granularity */
103
 
104
  uint32_t SecondFraction;  /*!< Specifies the range or granularity of Sub Second register content
105
                                 corresponding to Synchronous pre-scaler factor value (PREDIV_S)
106
                                 This parameter corresponds to a time unit range between [0-1] Second
107
                                 with [1 Sec / SecondFraction +1] granularity.
108
                                 This field will be used only by HAL_RTC_GetTime function */
109
#endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
110
 
111
  uint32_t DayLightSaving;  /*!< Specifies RTC_DayLightSaveOperation: the value of hour adjustment.
112
                                 This parameter can be a value of @ref RTC_DayLightSaving_Definitions */
113
 
114
  uint32_t StoreOperation;  /*!< Specifies RTC_StoreOperation value to be written in the BCK bit
115
                                 in CR register to store the operation.
116
                                 This parameter can be a value of @ref RTC_StoreOperation_Definitions */
117
} RTC_TimeTypeDef;
118
 
119
/**
120
  * @brief  RTC Date structure definition
121
  */
122
typedef struct
123
{
124
  uint8_t WeekDay;  /*!< Specifies the RTC Date WeekDay.
125
                         This parameter can be a value of @ref RTC_WeekDay_Definitions */
126
 
127
  uint8_t Month;    /*!< Specifies the RTC Date Month (in BCD format).
128
                         This parameter can be a value of @ref RTC_Month_Date_Definitions */
129
 
130
  uint8_t Date;     /*!< Specifies the RTC Date.
131
                         This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
132
 
133
  uint8_t Year;     /*!< Specifies the RTC Date Year.
134
                         This parameter must be a number between Min_Data = 0 and Max_Data = 99 */
135
 
136
} RTC_DateTypeDef;
137
 
138
/**
139
  * @brief  RTC Alarm structure definition
140
  */
141
typedef struct
142
{
143
  RTC_TimeTypeDef AlarmTime;     /*!< Specifies the RTC Alarm Time members */
144
 
145
  uint32_t AlarmMask;            /*!< Specifies the RTC Alarm Masks.
146
                                      This parameter can be a value of @ref RTC_AlarmMask_Definitions */
147
 
148
#if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
149
  uint32_t AlarmSubSecondMask;   /*!< Specifies the RTC Alarm SubSeconds Masks.
150
                                      This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */
151
#endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
152
 
153
  uint32_t AlarmDateWeekDaySel;  /*!< Specifies the RTC Alarm is on Date or WeekDay.
154
                                      This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */
155
 
156
  uint8_t AlarmDateWeekDay;      /*!< Specifies the RTC Alarm Date/WeekDay.
157
                                      If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range.
158
                                      If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */
159
 
160
  uint32_t Alarm;                /*!< Specifies the alarm .
161
                                      This parameter can be a value of @ref RTC_Alarms_Definitions */
162
} RTC_AlarmTypeDef;
163
 
164
/**
165
  * @brief  RTC Handle Structure definition
166
  */
167
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
168
typedef struct __RTC_HandleTypeDef
169
#else
170
typedef struct
171
#endif
172
{
173
  RTC_TypeDef                 *Instance;  /*!< Register base address    */
174
 
175
  RTC_InitTypeDef             Init;       /*!< RTC required parameters  */
176
 
177
  HAL_LockTypeDef             Lock;       /*!< RTC locking object       */
178
 
179
  __IO HAL_RTCStateTypeDef    State;      /*!< Time communication state */
180
 
181
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
182
  void (* AlarmAEventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Alarm A Event callback         */
183
 
184
  void (* AlarmBEventCallback)(struct __RTC_HandleTypeDef *hrtc);           /*!< RTC Alarm B Event callback         */
185
 
186
  void (* TimeStampEventCallback)(struct __RTC_HandleTypeDef *hrtc);        /*!< RTC TimeStamp Event callback       */
187
 
188
  void (* WakeUpTimerEventCallback)(struct __RTC_HandleTypeDef *hrtc);      /*!< RTC WakeUpTimer Event callback     */
189
 
190
  void (* Tamper1EventCallback)(struct __RTC_HandleTypeDef *hrtc);          /*!< RTC Tamper 1 Event callback        */
191
 
192
#if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
193
  void (* Tamper2EventCallback)(struct __RTC_HandleTypeDef *hrtc);          /*!< RTC Tamper 2 Event callback        */
194
 
195
  void (* Tamper3EventCallback)(struct __RTC_HandleTypeDef *hrtc);          /*!< RTC Tamper 3 Event callback        */
196
#endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
197
 
198
  void (* MspInitCallback)(struct __RTC_HandleTypeDef *hrtc);               /*!< RTC Msp Init callback              */
199
 
200
  void (* MspDeInitCallback)(struct __RTC_HandleTypeDef *hrtc);             /*!< RTC Msp DeInit callback            */
201
 
202
#endif /* (USE_HAL_RTC_REGISTER_CALLBACKS) */
203
 
204
} RTC_HandleTypeDef;
205
 
206
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
207
/**
208
  * @brief  HAL LPTIM Callback ID enumeration definition
209
  */
210
typedef enum
211
{
212
  HAL_RTC_ALARM_A_EVENT_CB_ID           = 0x00U,    /*!< RTC Alarm A Event Callback ID      */
213
  HAL_RTC_ALARM_B_EVENT_CB_ID           = 0x01U,    /*!< RTC Alarm B Event Callback ID      */
214
  HAL_RTC_TIMESTAMP_EVENT_CB_ID         = 0x02U,    /*!< RTC TimeStamp Event Callback ID    */
215
  HAL_RTC_WAKEUPTIMER_EVENT_CB_ID       = 0x03U,    /*!< RTC WakeUp Timer Event Callback ID */
216
  HAL_RTC_TAMPER1_EVENT_CB_ID           = 0x04U,    /*!< RTC Tamper 1 Callback ID           */
217
#if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
218
  HAL_RTC_TAMPER2_EVENT_CB_ID           = 0x05U,    /*!< RTC Tamper 2 Callback ID           */
219
  HAL_RTC_TAMPER3_EVENT_CB_ID           = 0x06U,    /*!< RTC Tamper 3 Callback ID           */
220
#endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
221
  HAL_RTC_MSPINIT_CB_ID                 = 0x0EU,    /*!< RTC Msp Init callback ID           */
222
  HAL_RTC_MSPDEINIT_CB_ID               = 0x0FU     /*!< RTC Msp DeInit callback ID         */
223
} HAL_RTC_CallbackIDTypeDef;
224
 
225
/**
226
  * @brief  HAL RTC Callback pointer definition
227
  */
228
typedef  void (*pRTC_CallbackTypeDef)(RTC_HandleTypeDef *hrtc);  /*!< pointer to an RTC callback function */
229
#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
230
 
231
/**
232
  * @}
233
  */
234
 
235
/* Exported constants --------------------------------------------------------*/
236
/** @defgroup RTC_Exported_Constants RTC Exported Constants
237
  * @{
238
  */
239
 
240
/** @defgroup RTC_Hour_Formats RTC Hour Formats
241
  * @{
242
  */
243
#define RTC_HOURFORMAT_24              (0x00000000U)
244
#define RTC_HOURFORMAT_12              (0x00000040U)
245
 
246
#define IS_RTC_HOUR_FORMAT(FORMAT)     (((FORMAT) == RTC_HOURFORMAT_12) || \
247
                                        ((FORMAT) == RTC_HOURFORMAT_24))
248
/**
249
  * @}
250
  */
251
 
252
 
253
/** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions
254
  * @{
255
  */
256
#define RTC_OUTPUT_POLARITY_HIGH       (0x00000000U)
257
#define RTC_OUTPUT_POLARITY_LOW        (0x00100000U)
258
 
259
#define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OUTPUT_POLARITY_HIGH) || \
260
                                ((POL) == RTC_OUTPUT_POLARITY_LOW))
261
/**
262
  * @}
263
  */
264
 
265
/** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT
266
  * @{
267
  */
268
#define RTC_OUTPUT_TYPE_OPENDRAIN      (0x00000000U)
269
#define RTC_OUTPUT_TYPE_PUSHPULL       (0x00040000U)
270
 
271
#define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OUTPUT_TYPE_OPENDRAIN) || \
272
                                  ((TYPE) == RTC_OUTPUT_TYPE_PUSHPULL))
273
 
274
/**
275
  * @}
276
  */
277
 
278
/** @defgroup RTC_Asynchronous_Predivider Asynchronous Predivider
279
  * @{
280
  */
281
#define IS_RTC_ASYNCH_PREDIV(PREDIV)   ((PREDIV) <= 0x7FU)
282
/**
283
  * @}
284
  */
285
 
286
/** @defgroup RTC_Time_Definitions Time Definitions
287
  * @{
288
  */
289
#define IS_RTC_HOUR12(HOUR)            (((HOUR) > 0U) && ((HOUR) <= 12U))
290
#define IS_RTC_HOUR24(HOUR)            ((HOUR) <= 23U)
291
#define IS_RTC_MINUTES(MINUTES)        ((MINUTES) <= 59U)
292
#define IS_RTC_SECONDS(SECONDS)        ((SECONDS) <= 59U)
293
/**
294
  * @}
295
  */
296
 
297
/** @defgroup RTC_AM_PM_Definitions AM PM Definitions
298
  * @{
299
  */
300
#define RTC_HOURFORMAT12_AM            ((uint8_t)0x00)
301
#define RTC_HOURFORMAT12_PM            ((uint8_t)0x40)
302
 
303
#define IS_RTC_HOURFORMAT12(PM)  (((PM) == RTC_HOURFORMAT12_AM) || ((PM) == RTC_HOURFORMAT12_PM))
304
/**
305
  * @}
306
  */
307
 
308
/** @defgroup RTC_DayLightSaving_Definitions DayLightSaving
309
  * @{
310
  */
311
#define RTC_DAYLIGHTSAVING_SUB1H       (0x00020000U)
312
#define RTC_DAYLIGHTSAVING_ADD1H       (0x00010000U)
313
#define RTC_DAYLIGHTSAVING_NONE        (0x00000000U)
314
 
315
#define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DAYLIGHTSAVING_SUB1H) || \
316
                                      ((SAVE) == RTC_DAYLIGHTSAVING_ADD1H) || \
317
                                      ((SAVE) == RTC_DAYLIGHTSAVING_NONE))
318
/**
319
  * @}
320
  */
321
 
322
/** @defgroup RTC_StoreOperation_Definitions StoreOperation
323
  * @{
324
  */
325
#define RTC_STOREOPERATION_RESET        (0x00000000U)
326
#define RTC_STOREOPERATION_SET          (0x00040000U)
327
 
328
#define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_STOREOPERATION_RESET) || \
329
                                           ((OPERATION) == RTC_STOREOPERATION_SET))
330
/**
331
  * @}
332
  */
333
 
334
/** @defgroup RTC_Input_parameter_format_definitions Input Parameter Format
335
  * @{
336
  */
337
#define RTC_FORMAT_BIN                      (0x000000000U)
338
#define RTC_FORMAT_BCD                      (0x000000001U)
339
 
340
#define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_FORMAT_BIN) || ((FORMAT) == RTC_FORMAT_BCD))
341
/**
342
  * @}
343
  */
344
 
345
/** @defgroup RTC_Year_Date_Definitions Year Definitions
346
  * @{
347
  */
348
#define IS_RTC_YEAR(YEAR)              ((YEAR) <= 99U)
349
/**
350
  * @}
351
  */
352
 
353
/** @defgroup RTC_Month_Date_Definitions Month Definitions
354
  * @{
355
  */
356
 
357
/* Coded in BCD format */
358
#define RTC_MONTH_JANUARY              ((uint8_t)0x01)
359
#define RTC_MONTH_FEBRUARY             ((uint8_t)0x02)
360
#define RTC_MONTH_MARCH                ((uint8_t)0x03)
361
#define RTC_MONTH_APRIL                ((uint8_t)0x04)
362
#define RTC_MONTH_MAY                  ((uint8_t)0x05)
363
#define RTC_MONTH_JUNE                 ((uint8_t)0x06)
364
#define RTC_MONTH_JULY                 ((uint8_t)0x07)
365
#define RTC_MONTH_AUGUST               ((uint8_t)0x08)
366
#define RTC_MONTH_SEPTEMBER            ((uint8_t)0x09)
367
#define RTC_MONTH_OCTOBER              ((uint8_t)0x10)
368
#define RTC_MONTH_NOVEMBER             ((uint8_t)0x11)
369
#define RTC_MONTH_DECEMBER             ((uint8_t)0x12)
370
 
371
#define IS_RTC_MONTH(MONTH)            (((MONTH) >= 1U) && ((MONTH) <= 12U))
372
#define IS_RTC_DATE(DATE)              (((DATE) >= 1U) && ((DATE) <= 31U))
373
/**
374
  * @}
375
  */
376
 
377
/** @defgroup RTC_WeekDay_Definitions WeekDay Definitions
378
  * @{
379
  */
380
#define RTC_WEEKDAY_MONDAY             ((uint8_t)0x01)
381
#define RTC_WEEKDAY_TUESDAY            ((uint8_t)0x02)
382
#define RTC_WEEKDAY_WEDNESDAY          ((uint8_t)0x03)
383
#define RTC_WEEKDAY_THURSDAY           ((uint8_t)0x04)
384
#define RTC_WEEKDAY_FRIDAY             ((uint8_t)0x05)
385
#define RTC_WEEKDAY_SATURDAY           ((uint8_t)0x06)
386
#define RTC_WEEKDAY_SUNDAY             ((uint8_t)0x07)
387
 
388
#define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY)    || \
389
                                 ((WEEKDAY) == RTC_WEEKDAY_TUESDAY)   || \
390
                                 ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
391
                                 ((WEEKDAY) == RTC_WEEKDAY_THURSDAY)  || \
392
                                 ((WEEKDAY) == RTC_WEEKDAY_FRIDAY)    || \
393
                                 ((WEEKDAY) == RTC_WEEKDAY_SATURDAY)  || \
394
                                 ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
395
/**
396
  * @}
397
  */
398
 
399
/** @defgroup RTC_Alarm_Definitions Alarm Definitions
400
  * @{
401
  */
402
#define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0U) && ((DATE) <= 31U))
403
#define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_WEEKDAY_MONDAY)    || \
404
                                                    ((WEEKDAY) == RTC_WEEKDAY_TUESDAY)   || \
405
                                                    ((WEEKDAY) == RTC_WEEKDAY_WEDNESDAY) || \
406
                                                    ((WEEKDAY) == RTC_WEEKDAY_THURSDAY)  || \
407
                                                    ((WEEKDAY) == RTC_WEEKDAY_FRIDAY)    || \
408
                                                    ((WEEKDAY) == RTC_WEEKDAY_SATURDAY)  || \
409
                                                    ((WEEKDAY) == RTC_WEEKDAY_SUNDAY))
410
/**
411
  * @}
412
  */
413
 
414
 
415
/** @defgroup RTC_AlarmDateWeekDay_Definitions AlarmDateWeekDay Definitions
416
  * @{
417
  */
418
#define RTC_ALARMDATEWEEKDAYSEL_DATE      (0x00000000U)
419
#define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY   (0x40000000U)
420
 
421
#define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \
422
                                            ((SEL) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY))
423
/**
424
  * @}
425
  */
426
 
427
 
428
/** @defgroup RTC_AlarmMask_Definitions Alarm Mask Definitions
429
  * @{
430
  */
431
#define RTC_ALARMMASK_NONE                (0x00000000U)
432
#define RTC_ALARMMASK_DATEWEEKDAY         RTC_ALRMAR_MSK4
433
#define RTC_ALARMMASK_HOURS               RTC_ALRMAR_MSK3
434
#define RTC_ALARMMASK_MINUTES             RTC_ALRMAR_MSK2
435
#define RTC_ALARMMASK_SECONDS             RTC_ALRMAR_MSK1
436
#define RTC_ALARMMASK_ALL                 (0x80808080U)
437
 
438
#define IS_RTC_ALARM_MASK(MASK)  (((MASK) & 0x7F7F7F7F) == (uint32_t)RESET)
439
/**
440
  * @}
441
  */
442
 
443
/** @defgroup RTC_Alarms_Definitions Alarms Definitions
444
  * @{
445
  */
446
#define RTC_ALARM_A                       RTC_CR_ALRAE
447
#define RTC_ALARM_B                       RTC_CR_ALRBE
448
 
449
#define IS_RTC_ALARM(ALARM)      (((ALARM) == RTC_ALARM_A) || ((ALARM) == RTC_ALARM_B))
450
/**
451
  * @}
452
  */
453
 
454
/**
455
  * @}
456
  */
457
 
458
/* Exported macros -----------------------------------------------------------*/
459
/** @defgroup RTC_Exported_macros RTC Exported Macros
460
  * @{
461
  */
462
 
463
/** @brief  Reset RTC handle state
464
  * @param  __HANDLE__ RTC handle.
465
  * @retval None
466
  */
467
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
468
#define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) do{\
469
                                                      (__HANDLE__)->State = HAL_RTC_STATE_RESET;\
470
                                                      (__HANDLE__)->MspInitCallback = NULL;\
471
                                                      (__HANDLE__)->MspDeInitCallback = NULL;\
472
                                                     }while(0)
473
#else
474
#define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
475
#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
476
 
477
/**
478
  * @brief  Disable the write protection for RTC registers.
479
  * @param  __HANDLE__ specifies the RTC handle.
480
  * @retval None
481
  */
482
#define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__)             \
483
                        do{                                       \
484
                            (__HANDLE__)->Instance->WPR = 0xCAU;   \
485
                            (__HANDLE__)->Instance->WPR = 0x53U;   \
486
                          } while(0U)
487
 
488
/**
489
  * @brief  Enable the write protection for RTC registers.
490
  * @param  __HANDLE__ specifies the RTC handle.
491
  * @retval None
492
  */
493
#define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__)              \
494
                        do{                                       \
495
                            (__HANDLE__)->Instance->WPR = 0xFFU;   \
496
                          } while(0U)
497
 
498
/**
499
  * @brief  Enable the RTC ALARMA peripheral.
500
  * @param  __HANDLE__ specifies the RTC handle.
501
  * @retval None
502
  */
503
#define __HAL_RTC_ALARMA_ENABLE(__HANDLE__)                           ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE))
504
 
505
/**
506
  * @brief  Disable the RTC ALARMA peripheral.
507
  * @param  __HANDLE__ specifies the RTC handle.
508
  * @retval None
509
  */
510
#define __HAL_RTC_ALARMA_DISABLE(__HANDLE__)                          ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE))
511
 
512
/**
513
  * @brief  Enable the RTC ALARMB peripheral.
514
  * @param  __HANDLE__ specifies the RTC handle.
515
  * @retval None
516
  */
517
#define __HAL_RTC_ALARMB_ENABLE(__HANDLE__)                           ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE))
518
 
519
/**
520
  * @brief  Disable the RTC ALARMB peripheral.
521
  * @param  __HANDLE__ specifies the RTC handle.
522
  * @retval None
523
  */
524
#define __HAL_RTC_ALARMB_DISABLE(__HANDLE__)                          ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE))
525
 
526
/**
527
  * @brief  Enable the RTC Alarm interrupt.
528
  * @param  __HANDLE__ specifies the RTC handle.
529
  * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
530
  *          This parameter can be any combination of the following values:
531
  *             @arg RTC_IT_ALRA: Alarm A interrupt
532
  *             @arg RTC_IT_ALRB: Alarm B interrupt
533
  * @retval None
534
  */
535
#define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__)          ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
536
 
537
/**
538
  * @brief  Disable the RTC Alarm interrupt.
539
  * @param  __HANDLE__ specifies the RTC handle.
540
  * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to be enabled or disabled.
541
  *         This parameter can be any combination of the following values:
542
  *            @arg RTC_IT_ALRA: Alarm A interrupt
543
  *            @arg RTC_IT_ALRB: Alarm B interrupt
544
  * @retval None
545
  */
546
#define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__)         ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
547
 
548
/**
549
  * @brief  Check whether the specified RTC Alarm interrupt has occurred or not.
550
  * @param  __HANDLE__ specifies the RTC handle.
551
  * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to check.
552
  *         This parameter can be:
553
  *            @arg RTC_IT_ALRA: Alarm A interrupt
554
  *            @arg RTC_IT_ALRB: Alarm B interrupt
555
  * @retval None
556
  */
557
#define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__)  (((((__HANDLE__)->Instance->ISR)& ((__INTERRUPT__)>> 4U)) != 0U)? 1U : 0U)
558
 
559
/**
560
  * @brief  Check whether the specified RTC Alarm interrupt has been enabled or not.
561
  * @param  __HANDLE__ specifies the RTC handle.
562
  * @param  __INTERRUPT__ specifies the RTC Alarm interrupt sources to check.
563
  *         This parameter can be:
564
  *            @arg RTC_IT_ALRA: Alarm A interrupt
565
  *            @arg RTC_IT_ALRB: Alarm B interrupt
566
  * @retval None
567
  */
568
#define __HAL_RTC_ALARM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)     (((((__HANDLE__)->Instance->CR) & (__INTERRUPT__)) != 0U) ? 1U : 0U)
569
 
570
/**
571
  * @brief  Get the selected RTC Alarm's flag status.
572
  * @param  __HANDLE__ specifies the RTC handle.
573
  * @param  __FLAG__ specifies the RTC Alarm Flag sources to check.
574
  *         This parameter can be:
575
  *            @arg RTC_FLAG_ALRAF
576
  *            @arg RTC_FLAG_ALRBF
577
  *            @arg RTC_FLAG_ALRAWF
578
  *            @arg RTC_FLAG_ALRBWF
579
  * @retval None
580
  */
581
#define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__)   (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != 0U)? 1U : 0U)
582
 
583
/**
584
  * @brief  Clear the RTC Alarm's pending flags.
585
  * @param  __HANDLE__ specifies the RTC handle.
586
  * @param  __FLAG__ specifies the RTC Alarm Flag sources to clear.
587
  *          This parameter can be:
588
  *             @arg RTC_FLAG_ALRAF
589
  *             @arg RTC_FLAG_ALRBF
590
  * @retval None
591
  */
592
#define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__)   ((__HANDLE__)->Instance->ISR) = (~((__FLAG__) | RTC_ISR_INIT) | ((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
593
 
594
/**
595
  * @brief  Enable interrupt on the RTC Alarm associated Exti line.
596
  * @retval None
597
  */
598
#define __HAL_RTC_ALARM_EXTI_ENABLE_IT()            (EXTI->IMR |= RTC_EXTI_LINE_ALARM_EVENT)
599
 
600
/**
601
  * @brief  Disable interrupt on the RTC Alarm associated Exti line.
602
  * @retval None
603
  */
604
#define __HAL_RTC_ALARM_EXTI_DISABLE_IT()           (EXTI->IMR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
605
 
606
/**
607
  * @brief  Enable event on the RTC Alarm associated Exti line.
608
  * @retval None.
609
  */
610
#define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT()         (EXTI->EMR |= RTC_EXTI_LINE_ALARM_EVENT)
611
 
612
/**
613
  * @brief  Disable event on the RTC Alarm associated Exti line.
614
  * @retval None.
615
  */
616
#define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT()         (EXTI->EMR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
617
 
618
/**
619
  * @brief  Enable falling edge trigger on the RTC Alarm associated Exti line.
620
  * @retval None.
621
  */
622
#define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE()   (EXTI->FTSR |= RTC_EXTI_LINE_ALARM_EVENT)
623
 
624
/**
625
  * @brief  Disable falling edge trigger on the RTC Alarm associated Exti line.
626
  * @retval None.
627
  */
628
#define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE()  (EXTI->FTSR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
629
 
630
/**
631
  * @brief  Enable rising edge trigger on the RTC Alarm associated Exti line.
632
  * @retval None.
633
  */
634
#define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE()    (EXTI->RTSR |= RTC_EXTI_LINE_ALARM_EVENT)
635
 
636
/**
637
  * @brief  Disable rising edge trigger on the RTC Alarm associated Exti line.
638
  * @retval None.
639
  */
640
#define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE()   (EXTI->RTSR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
641
 
642
/**
643
  * @brief  Enable rising & falling edge trigger on the RTC Alarm associated Exti line.
644
  * @retval None.
645
  */
646
#define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE()  do { \
647
                                                             __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE();  \
648
                                                             __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE(); \
649
                                                           } while(0U)
650
 
651
/**
652
  * @brief  Disable rising & falling edge trigger on the RTC Alarm associated Exti line.
653
  * @retval None.
654
  */
655
#define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
656
                                                             __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE();  \
657
                                                             __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE(); \
658
                                                           } while(0U)
659
 
660
/**
661
  * @brief Check whether the RTC Alarm associated Exti line interrupt flag is set or not.
662
  * @retval Line Status.
663
  */
664
#define __HAL_RTC_ALARM_EXTI_GET_FLAG()              (EXTI->PR & RTC_EXTI_LINE_ALARM_EVENT)
665
 
666
/**
667
  * @brief Clear the RTC Alarm associated Exti line flag.
668
  * @retval None.
669
  */
670
#define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG()            (EXTI->PR = RTC_EXTI_LINE_ALARM_EVENT)
671
 
672
/**
673
  * @brief Generate a Software interrupt on RTC Alarm associated Exti line.
674
  * @retval None.
675
  */
676
#define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT()         (EXTI->SWIER |= RTC_EXTI_LINE_ALARM_EVENT)
677
 
678
/**
679
  * @}
680
  */
681
 
682
/* Include RTC HAL Extended module */
683
#include "stm32l1xx_hal_rtc_ex.h"
684
 
685
/* Exported functions --------------------------------------------------------*/
686
/** @defgroup RTC_Exported_Functions RTC Exported Functions
687
  * @{
688
  */
689
 
690
/** @defgroup RTC_Exported_Functions_Group1 Initialization and de-initialization functions
691
  * @{
692
  */
693
/* Initialization and de-initialization functions  ****************************/
694
HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc);
695
HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc);
696
 
697
void              HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc);
698
void              HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc);
699
 
700
/* Callbacks Register/UnRegister functions  ***********************************/
701
#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
702
HAL_StatusTypeDef HAL_RTC_RegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID, pRTC_CallbackTypeDef pCallback);
703
HAL_StatusTypeDef HAL_RTC_UnRegisterCallback(RTC_HandleTypeDef *hrtc, HAL_RTC_CallbackIDTypeDef CallbackID);
704
#endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
705
 
706
/**
707
  * @}
708
  */
709
 
710
/** @defgroup RTC_Exported_Functions_Group2 RTC Time and Date functions
711
  * @{
712
  */
713
/* RTC Time and Date functions ************************************************/
714
HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
715
HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
716
HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
717
HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
718
/**
719
  * @}
720
  */
721
 
722
/** @defgroup RTC_Exported_Functions_Group3 RTC Alarm functions
723
  * @{
724
  */
725
/* RTC Alarm functions ********************************************************/
726
HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
727
HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
728
HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm);
729
HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format);
730
void              HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc);
731
HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
732
void              HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc);
733
/**
734
  * @}
735
  */
736
 
737
/** @defgroup  RTC_Exported_Functions_Group4 Peripheral Control functions
738
  * @{
739
  */
740
/* Peripheral Control functions ***********************************************/
741
HAL_StatusTypeDef   HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc);
742
/**
743
  * @}
744
  */
745
 
746
/** @defgroup RTC_Exported_Functions_Group5 Peripheral State functions
747
  * @{
748
  */
749
/* Peripheral State functions *************************************************/
750
HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc);
751
/**
752
  * @}
753
  */
754
 
755
/**
756
  * @}
757
  */
758
 
759
/* Private types -------------------------------------------------------------*/
760
/* Private variables ---------------------------------------------------------*/
761
/* Private constants ---------------------------------------------------------*/
762
/** @defgroup RTC_Private_Constants RTC Private Constants
763
  * @{
764
  */
765
#define RTC_TIMEOUT_VALUE  1000U
766
 
767
#define RTC_EXTI_LINE_ALARM_EVENT             ((uint32_t)EXTI_IMR_MR17)  /*!< External interrupt line 17 Connected to the RTC Alarm event */
768
 
769
/**
770
  * @}
771
  */
772
 
773
/* Private macros ------------------------------------------------------------*/
774
/** @defgroup RTC_Private_Macros RTC Private Macros
775
  * @{
776
  */
777
 
778
/**
779
  * @}
780
  */
781
 
782
/* Private functions -------------------------------------------------------------*/
783
/** @defgroup RTC_Private_Functions RTC Private Functions
784
  * @{
785
  */
786
HAL_StatusTypeDef  RTC_EnterInitMode(RTC_HandleTypeDef *hrtc);
787
uint8_t            RTC_ByteToBcd2(uint8_t Value);
788
uint8_t            RTC_Bcd2ToByte(uint8_t Value);
789
/**
790
  * @}
791
  */
792
 
793
 
794
/**
795
  * @}
796
  */
797
 
798
/**
799
  * @}
800
  */
801
 
802
#ifdef __cplusplus
803
}
804
#endif
805
 
806
#endif /* __STM32L1xx_HAL_RTC_H */
807
 
808
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/