Subversion Repositories DashDisplay

Rev

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