]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32L0/stm32l0xx_hal_rtc.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32L0 / stm32l0xx_hal_rtc.h
1 /**
2 ******************************************************************************
3 * @file stm32l0xx_hal_rtc.h
4 * @author MCD Application Team
5 * @version V1.2.0
6 * @date 06-February-2015
7 * @brief Header file of RTC HAL module.
8 ******************************************************************************
9 * @attention
10 *
11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
12 *
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 ******************************************************************************
36 */
37
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32L0xx_HAL_RTC_H
40 #define __STM32L0xx_HAL_RTC_H
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32l0xx_hal_def.h"
48
49 /** @addtogroup STM32L0xx_HAL_Driver
50 * @{
51 */
52
53 /** @defgroup RTC RTC
54 * @{
55 */
56
57 /* Exported types ------------------------------------------------------------*/
58 /** @defgroup RTC_Exported_Types RTC Exported Types
59 * @{
60 */
61
62 /**
63 * @brief HAL State structures definition
64 */
65 typedef enum
66 {
67 HAL_RTC_STATE_RESET = 0x00, /*!< RTC not yet initialized or disabled */
68 HAL_RTC_STATE_READY = 0x01, /*!< RTC initialized and ready for use */
69 HAL_RTC_STATE_BUSY = 0x02, /*!< RTC process is ongoing */
70 HAL_RTC_STATE_TIMEOUT = 0x03, /*!< RTC timeout state */
71 HAL_RTC_STATE_ERROR = 0x04 /*!< RTC error state */
72
73 }HAL_RTCStateTypeDef;
74
75 /**
76 * @brief RTC Configuration Structure definition
77 */
78 typedef struct
79 {
80 uint32_t HourFormat; /*!< Specifies the RTC Hour Format.
81 This parameter can be a value of @ref RTC_Hour_Formats */
82
83 uint32_t AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value.
84 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7F */
85
86 uint32_t SynchPrediv; /*!< Specifies the RTC Synchronous Predivider value.
87 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x7FFF */
88
89 uint32_t OutPut; /*!< Specifies which signal will be routed to the RTC output.
90 This parameter can be a value of @ref RTC_Output_selection_Definitions */
91
92 uint32_t OutPutRemap; /*!< Specifies the remap for RTC output.
93 This parameter can be a value of @ref RTC_Output_ALARM_OUT_Remap */
94
95 uint32_t OutPutPolarity; /*!< Specifies the polarity of the output signal.
96 This parameter can be a value of @ref RTC_Output_Polarity_Definitions */
97
98 uint32_t OutPutType; /*!< Specifies the RTC Output Pin mode.
99 This parameter can be a value of @ref RTC_Output_Type_ALARM_OUT */
100 }RTC_InitTypeDef;
101
102 /**
103 * @brief RTC Time structure definition
104 */
105 typedef struct
106 {
107 uint8_t Hours; /*!< Specifies the RTC Time Hour.
108 This parameter must be a number between Min_Data = 0 and Max_Data = 12 if the RTC_HourFormat_12 is selected.
109 This parameter must be a number between Min_Data = 0 and Max_Data = 23 if the RTC_HourFormat_24 is selected */
110
111 uint8_t Minutes; /*!< Specifies the RTC Time Minutes.
112 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
113
114 uint8_t Seconds; /*!< Specifies the RTC Time Seconds.
115 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
116
117 uint32_t SubSeconds; /*!< Specifies the RTC Time SubSeconds.
118 This parameter must be a number between Min_Data = 0 and Max_Data = 59 */
119
120 uint8_t TimeFormat; /*!< Specifies the RTC AM/PM Time.
121 This parameter can be a value of @ref RTC_AM_PM_Definitions */
122
123 uint32_t DayLightSaving; /*!< Specifies RTC_DayLightSaveOperation: the value of hour adjustment.
124 This parameter can be a value of @ref RTC_DayLightSaving_Definitions */
125
126 uint32_t StoreOperation; /*!< Specifies RTC_StoreOperation value to be written in the BCK bit
127 in CR register to store the operation.
128 This parameter can be a value of @ref RTC_StoreOperation_Definitions */
129 }RTC_TimeTypeDef;
130
131 /**
132 * @brief RTC Date structure definition
133 */
134 typedef struct
135 {
136 uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay.
137 This parameter can be a value of @ref RTC_WeekDay_Definitions */
138
139 uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format).
140 This parameter can be a value of @ref RTC_Month_Date_Definitions */
141
142 uint8_t Date; /*!< Specifies the RTC Date.
143 This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
144
145 uint8_t Year; /*!< Specifies the RTC Date Year.
146 This parameter must be a number between Min_Data = 0 and Max_Data = 99 */
147
148 }RTC_DateTypeDef;
149
150 /**
151 * @brief RTC Alarm structure definition
152 */
153 typedef struct
154 {
155 RTC_TimeTypeDef AlarmTime; /*!< Specifies the RTC Alarm Time members */
156
157 uint32_t AlarmMask; /*!< Specifies the RTC Alarm Masks.
158 This parameter can be a value of @ref RTC_AlarmMask_Definitions */
159
160 uint32_t AlarmSubSecondMask; /*!< Specifies the RTC Alarm SubSeconds Masks.
161 This parameter can be a value of @ref RTC_Alarm_Sub_Seconds_Masks_Definitions */
162
163 uint32_t AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on Date or WeekDay.
164 This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */
165
166 uint8_t AlarmDateWeekDay; /*!< Specifies the RTC Alarm Date/WeekDay.
167 If the Alarm Date is selected, this parameter must be set to a value in the 1-31 range.
168 If the Alarm WeekDay is selected, this parameter can be a value of @ref RTC_WeekDay_Definitions */
169
170 uint32_t Alarm; /*!< Specifies the alarm .
171 This parameter can be a value of @ref RTC_Alarms_Definitions */
172 }RTC_AlarmTypeDef;
173
174 /**
175 * @brief Time Handle Structure definition
176 */
177 typedef struct
178 {
179 RTC_TypeDef *Instance; /*!< Register base address */
180
181 RTC_InitTypeDef Init; /*!< RTC required parameters */
182
183 HAL_LockTypeDef Lock; /*!< RTC locking object */
184
185 __IO HAL_RTCStateTypeDef State; /*!< Time communication state */
186
187 }RTC_HandleTypeDef;
188 /**
189 * @}
190 */
191
192 /* Exported constants --------------------------------------------------------*/
193 /** @defgroup RTC_Exported_Constants RTC Exported Constants
194 * @{
195 */
196
197 /** @defgroup RTC_Mask_Definition RTC Mask Definition
198 * @{
199 */
200 /* Masks Definition */
201 #define RTC_TR_RESERVED_MASK ((uint32_t) (RTC_TR_PM | RTC_TR_HT | RTC_TR_HU | \
202 RTC_TR_MNT | RTC_TR_MNU| RTC_TR_ST | \
203 RTC_TR_SU))
204 #define RTC_DR_RESERVED_MASK ((uint32_t) (RTC_DR_YT | RTC_DR_YU | RTC_DR_WDU | \
205 RTC_DR_MT | RTC_DR_MU | RTC_DR_DT | \
206 RTC_DR_DU))
207
208 #define RTC_INIT_MASK ((uint32_t)0xFFFFFFFF)
209
210 #define RTC_RSF_MASK ((uint32_t)~(RTC_ISR_INIT | RTC_ISR_RSF))
211
212 #define RTC_TIMEOUT_VALUE 1000
213 /**
214 * @}
215 */
216
217 /** @defgroup RTC_Hour_Formats RTC Hour Formats
218 * @{
219 */
220 #define RTC_HOURFORMAT_24 ((uint32_t)0x00000000)
221 #define RTC_HOURFORMAT_12 ((uint32_t)RTC_CR_FMT)
222
223 #define IS_RTC_HOUR_FORMAT(__FORMAT__) (((__FORMAT__) == RTC_HOURFORMAT_12) || \
224 ((__FORMAT__) == RTC_HOURFORMAT_24))
225 /**
226 * @}
227 */
228
229 /** @defgroup RTC_Output_selection_Definitions RTC Output selection Definitions
230 * @{
231 */
232 #define RTC_OUTPUT_DISABLE ((uint32_t)0x00000000)
233 #define RTC_OUTPUT_ALARMA ((uint32_t)RTC_CR_OSEL_0)
234 #define RTC_OUTPUT_ALARMB ((uint32_t)RTC_CR_OSEL_1)
235 #define RTC_OUTPUT_WAKEUP ((uint32_t)RTC_CR_OSEL)
236
237 #define IS_RTC_OUTPUT(__OUTPUT__) (((__OUTPUT__) == RTC_OUTPUT_DISABLE) || \
238 ((__OUTPUT__) == RTC_OUTPUT_ALARMA) || \
239 ((__OUTPUT__) == RTC_OUTPUT_ALARMB) || \
240 ((__OUTPUT__) == RTC_OUTPUT_WAKEUP))
241 /**
242 * @}
243 */
244
245 /** @defgroup RTC_Output_Polarity_Definitions RTC Output Polarity Definitions
246 * @{
247 */
248 #define RTC_OUTPUT_POLARITY_HIGH ((uint32_t)0x00000000)
249 #define RTC_OUTPUT_POLARITY_LOW ((uint32_t)RTC_CR_POL)
250
251 #define IS_RTC_OUTPUT_POL(__POL__) (((__POL__) == RTC_OUTPUT_POLARITY_HIGH) || \
252 ((__POL__) == RTC_OUTPUT_POLARITY_LOW))
253 /**
254 * @}
255 */
256
257 /** @defgroup RTC_Output_Type_ALARM_OUT RTC Output Type ALARM OUT
258 * @{
259 */
260 #define RTC_OUTPUT_TYPE_OPENDRAIN ((uint32_t)0x00000000)
261 #define RTC_OUTPUT_TYPE_PUSHPULL ((uint32_t)RTC_OR_ALARMOUTTYPE)
262
263 #define IS_RTC_OUTPUT_TYPE(__TYPE__) (((__TYPE__) == RTC_OUTPUT_TYPE_OPENDRAIN) || \
264 ((__TYPE__) == RTC_OUTPUT_TYPE_PUSHPULL))
265
266 /**
267 * @}
268 */
269
270 /** @defgroup RTC_Output_ALARM_OUT_Remap RTC Output ALARM OUT Remap
271 * @{
272 */
273 #define RTC_OUTPUT_REMAP_PC13 ((uint32_t)0x00000000)
274 #define RTC_OUTPUT_REMAP_PB14 ((uint32_t)RTC_OR_OUT_RMP)
275 #define IS_RTC_OUTPUT_REMAP(__REMAP__) (((__REMAP__) == RTC_OUTPUT_REMAP_PC13) || \
276 ((__REMAP__) == RTC_OUTPUT_REMAP_PB14))
277
278 /**
279 * @}
280 */
281
282 /** @defgroup RTC_Asynchronous_Predivider RTC Asynchronous Predivider
283 * @{
284 */
285 #define IS_RTC_ASYNCH_PREDIV(__PREDIV__) ((__PREDIV__) <= (uint32_t)0x7F)
286 /**
287 * @}
288 */
289
290
291 /** @defgroup RTC_Synchronous_Predivider RTC Synchronous Predivider
292 * @{
293 */
294 #define IS_RTC_SYNCH_PREDIV(__PREDIV__) ((__PREDIV__) <= (uint32_t)RTC_PRER_PREDIV_S)
295 /**
296 * @}
297 */
298
299 /** @defgroup RTC_Time_Definitions RTC Time Definitions
300 * @{
301 */
302 #define IS_RTC_HOUR12(__HOUR__) (((__HOUR__) > (uint32_t)0) && ((__HOUR__) <= (uint32_t)12))
303 #define IS_RTC_HOUR24(__HOUR__) ((__HOUR__) <= (uint32_t)23)
304 #define IS_RTC_MINUTES(__MINUTES__) ((__MINUTES__) <= (uint32_t)59)
305 #define IS_RTC_SECONDS(__SECONDS__) ((__SECONDS__) <= (uint32_t)59)
306 /**
307 * @}
308 */
309
310 /** @defgroup RTC_AM_PM_Definitions RTC AM PM Definitions
311 * @{
312 */
313 #define RTC_HOURFORMAT12_AM ((uint8_t)0x00)
314 #define RTC_HOURFORMAT12_PM ((uint8_t)0x40)
315
316 #define IS_RTC_HOURFORMAT12(__PM__) (((__PM__) == RTC_HOURFORMAT12_AM) || \
317 ((__PM__) == RTC_HOURFORMAT12_PM))
318 /**
319 * @}
320 */
321
322 /** @defgroup RTC_DayLightSaving_Definitions RTC DayLightSaving Definitions
323 * @{
324 */
325 #define RTC_DAYLIGHTSAVING_SUB1H ((uint32_t)RTC_CR_SUB1H)
326 #define RTC_DAYLIGHTSAVING_ADD1H ((uint32_t)RTC_CR_ADD1H)
327 #define RTC_DAYLIGHTSAVING_NONE ((uint32_t)0x00000000)
328
329 #define IS_RTC_DAYLIGHT_SAVING(__SAVE__) (((__SAVE__) == RTC_DAYLIGHTSAVING_SUB1H) || \
330 ((__SAVE__) == RTC_DAYLIGHTSAVING_ADD1H) || \
331 ((__SAVE__) == RTC_DAYLIGHTSAVING_NONE))
332 /**
333 * @}
334 */
335
336 /** @defgroup RTC_StoreOperation_Definitions RTC StoreOperation Definitions
337 * @{
338 */
339 #define RTC_STOREOPERATION_RESET ((uint32_t)0x00000000)
340 #define RTC_STOREOPERATION_SET ((uint32_t)RTC_CR_BCK)
341
342 #define IS_RTC_STORE_OPERATION(__OPERATION__) (((__OPERATION__) == RTC_STOREOPERATION_RESET) || \
343 ((__OPERATION__) == RTC_STOREOPERATION_SET))
344 /**
345 * @}
346 */
347
348
349 /** @defgroup RTC_Input_parameter_format_definitions RTC Input parameter format definitions
350 * @{
351 */
352 #define RTC_FORMAT_BIN ((uint32_t)0x000000000)
353 #define RTC_FORMAT_BCD ((uint32_t)0x000000001)
354
355 #define IS_RTC_FORMAT(__FORMAT__) (((__FORMAT__) == RTC_FORMAT_BIN) || ((__FORMAT__) == RTC_FORMAT_BCD))
356
357 /**
358 * @}
359 */
360
361 /** @defgroup RTC_Year_Date_Definitions RTC Year Date Definitions
362 * @{
363 */
364 #define IS_RTC_YEAR(__YEAR__) ((__YEAR__) <= (uint32_t)99)
365 /**
366 * @}
367 */
368
369 /** @defgroup RTC_Month_Date_Definitions RTC Month Date Definitions
370 * @{
371 */
372
373 /* Coded in BCD format */
374 #define RTC_MONTH_JANUARY ((uint8_t)0x01)
375 #define RTC_MONTH_FEBRUARY ((uint8_t)0x02)
376 #define RTC_MONTH_MARCH ((uint8_t)0x03)
377 #define RTC_MONTH_APRIL ((uint8_t)0x04)
378 #define RTC_MONTH_MAY ((uint8_t)0x05)
379 #define RTC_MONTH_JUNE ((uint8_t)0x06)
380 #define RTC_MONTH_JULY ((uint8_t)0x07)
381 #define RTC_MONTH_AUGUST ((uint8_t)0x08)
382 #define RTC_MONTH_SEPTEMBER ((uint8_t)0x09)
383 #define RTC_MONTH_OCTOBER ((uint8_t)0x10)
384 #define RTC_MONTH_NOVEMBER ((uint8_t)0x11)
385 #define RTC_MONTH_DECEMBER ((uint8_t)0x12)
386
387 #define IS_RTC_MONTH(__MONTH__) (((__MONTH__) >= (uint32_t)1) && ((__MONTH__) <= (uint32_t)12))
388 #define IS_RTC_DATE(__DATE__) (((__DATE__) >= (uint32_t)1) && ((__DATE__) <= (uint32_t)31))
389 /**
390 * @}
391 */
392
393 /** @defgroup RTC_WeekDay_Definitions RTC WeekDay Definitions
394 * @{
395 */
396 #define RTC_WEEKDAY_MONDAY ((uint8_t)0x01)
397 #define RTC_WEEKDAY_TUESDAY ((uint8_t)0x02)
398 #define RTC_WEEKDAY_WEDNESDAY ((uint8_t)0x03)
399 #define RTC_WEEKDAY_THURSDAY ((uint8_t)0x04)
400 #define RTC_WEEKDAY_FRIDAY ((uint8_t)0x05)
401 #define RTC_WEEKDAY_SATURDAY ((uint8_t)0x06)
402 #define RTC_WEEKDAY_SUNDAY ((uint8_t)0x07)
403
404 #define IS_RTC_WEEKDAY(__WEEKDAY__) (((__WEEKDAY__) == RTC_WEEKDAY_MONDAY) || \
405 ((__WEEKDAY__) == RTC_WEEKDAY_TUESDAY) || \
406 ((__WEEKDAY__) == RTC_WEEKDAY_WEDNESDAY) || \
407 ((__WEEKDAY__) == RTC_WEEKDAY_THURSDAY) || \
408 ((__WEEKDAY__) == RTC_WEEKDAY_FRIDAY) || \
409 ((__WEEKDAY__) == RTC_WEEKDAY_SATURDAY) || \
410 ((__WEEKDAY__) == RTC_WEEKDAY_SUNDAY))
411 /**
412 * @}
413 */
414
415 /** @defgroup RTC_Alarm_Definitions RTC Alarm Definitions
416 * @{
417 */
418 #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(__DATE__) (((__DATE__) >(uint32_t) 0) && ((__DATE__) <= (uint32_t)31))
419 #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(__WEEKDAY__) (((__WEEKDAY__) == RTC_WEEKDAY_MONDAY) || \
420 ((__WEEKDAY__) == RTC_WEEKDAY_TUESDAY) || \
421 ((__WEEKDAY__) == RTC_WEEKDAY_WEDNESDAY) || \
422 ((__WEEKDAY__) == RTC_WEEKDAY_THURSDAY) || \
423 ((__WEEKDAY__) == RTC_WEEKDAY_FRIDAY) || \
424 ((__WEEKDAY__) == RTC_WEEKDAY_SATURDAY) || \
425 ((__WEEKDAY__) == RTC_WEEKDAY_SUNDAY))
426 /**
427 * @}
428 */
429
430 /** @defgroup RTC_AlarmDateWeekDay_Definitions RTC AlarmDateWeekDay Definitions
431 * @{
432 */
433 #define RTC_ALARMDATEWEEKDAYSEL_DATE ((uint32_t)0x00000000)
434 #define RTC_ALARMDATEWEEKDAYSEL_WEEKDAY RTC_ALRMAR_WDSEL
435
436 #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(__SEL__) (((__SEL__) == RTC_ALARMDATEWEEKDAYSEL_DATE) || \
437 ((__SEL__) == RTC_ALARMDATEWEEKDAYSEL_WEEKDAY))
438 /**
439 * @}
440 */
441
442 /** @defgroup RTC_AlarmMask_Definitions RTC AlarmMask Definitions
443 * @{
444 */
445 #define RTC_ALARMMASK_NONE ((uint32_t)0x00000000)
446 #define RTC_ALARMMASK_DATEWEEKDAY RTC_ALRMAR_MSK4
447 #define RTC_ALARMMASK_HOURS RTC_ALRMAR_MSK3
448 #define RTC_ALARMMASK_MINUTES RTC_ALRMAR_MSK2
449 #define RTC_ALARMMASK_SECONDS RTC_ALRMAR_MSK1
450 #define RTC_ALARMMASK_ALL ((uint32_t) (RTC_ALARMMASK_NONE | \
451 RTC_ALARMMASK_DATEWEEKDAY | \
452 RTC_ALARMMASK_HOURS | \
453 RTC_ALARMMASK_MINUTES | \
454 RTC_ALARMMASK_SECONDS))
455
456 #define IS_RTC_ALARM_MASK(__MASK__) (((__MASK__) & ~(RTC_ALARMMASK_ALL)) == (uint32_t)RESET)
457 /**
458 * @}
459 */
460
461 /** @defgroup RTC_Alarms_Definitions RTC Alarms Definitions
462 * @{
463 */
464 #define RTC_ALARM_A RTC_CR_ALRAE
465 #define RTC_ALARM_B RTC_CR_ALRBE
466
467 #define IS_RTC_ALARM(__ALARM__) (((__ALARM__) == RTC_ALARM_A) || ((__ALARM__) == RTC_ALARM_B))
468 /**
469 * @}
470 */
471
472 /** @defgroup RTC_Alarm_Sub_Seconds_Value RTC Alarm Sub Seconds Value
473 * @{
474 */
475 #define IS_RTC_ALARM_SUB_SECOND_VALUE(__VALUE__) ((__VALUE__) <= RTC_ALRMASSR_SS)
476 /**
477 * @}
478 */
479
480 /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions RTC Alarm Sub Seconds Masks Definitions
481 * @{
482 */
483 #define RTC_ALARMSUBSECONDMASK_ALL ((uint32_t)0x00000000) /*!< All Alarm SS fields are masked.
484 There is no comparison on sub seconds
485 for Alarm */
486 #define RTC_ALARMSUBSECONDMASK_SS14_1 RTC_ALRMASSR_MASKSS_0 /*!< SS[14:1] are don't care in Alarm
487 comparison. Only SS[0] is compared. */
488 #define RTC_ALARMSUBSECONDMASK_SS14_2 RTC_ALRMASSR_MASKSS_1 /*!< SS[14:2] are don't care in Alarm
489 comparison. Only SS[1:0] are compared */
490 #define RTC_ALARMSUBSECONDMASK_SS14_3 ((uint32_t) (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1)) /*!< SS[14:3] are don't care in Alarm
491 comparison. Only SS[2:0] are compared */
492 #define RTC_ALARMSUBSECONDMASK_SS14_4 RTC_ALRMASSR_MASKSS_2 /*!< SS[14:4] are don't care in Alarm
493 comparison. Only SS[3:0] are compared */
494 #define RTC_ALARMSUBSECONDMASK_SS14_5 ((uint32_t) (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2)) /*!< SS[14:5] are don't care in Alarm
495 comparison. Only SS[4:0] are compared */
496 #define RTC_ALARMSUBSECONDMASK_SS14_6 ((uint32_t) (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)) /*!< SS[14:6] are don't care in Alarm
497 comparison. Only SS[5:0] are compared */
498 #define RTC_ALARMSUBSECONDMASK_SS14_7 ((uint32_t) (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2)) /*!< SS[14:7] are don't care in Alarm
499 ` comparison. Only SS[6:0] are compared */
500 #define RTC_ALARMSUBSECONDMASK_SS14_8 RTC_ALRMASSR_MASKSS_3 /*!< SS[14:8] are don't care in Alarm
501 comparison. Only SS[7:0] are compared */
502 #define RTC_ALARMSUBSECONDMASK_SS14_9 ((uint32_t) (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_3)) /*!< SS[14:9] are don't care in Alarm
503 comparison. Only SS[8:0] are compared */
504 #define RTC_ALARMSUBSECONDMASK_SS14_10 ((uint32_t) (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)) /*!< SS[14:10] are don't care in Alarm
505 comparison. Only SS[9:0] are compared */
506 #define RTC_ALARMSUBSECONDMASK_SS14_11 ((uint32_t) (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_3)) /*!< SS[14:11] are don't care in Alarm
507 comparison. Only SS[10:0] are compared */
508 #define RTC_ALARMSUBSECONDMASK_SS14_12 ((uint32_t) (RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)) /*!< SS[14:12] are don't care in Alarm
509 comparison.Only SS[11:0] are compared */
510 #define RTC_ALARMSUBSECONDMASK_SS14_13 ((uint32_t) (RTC_ALRMASSR_MASKSS_0 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)) /*!< SS[14:13] are don't care in Alarm
511 comparison. Only SS[12:0] are compared */
512 #define RTC_ALARMSUBSECONDMASK_SS14 ((uint32_t) (RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3)) /*!< SS[14] is don't care in Alarm
513 comparison.Only SS[13:0] are compared */
514 #define RTC_ALARMSUBSECONDMASK_NONE RTC_ALRMASSR_MASKSS /*!< SS[14:0] are compared and must match
515 to activate alarm. */
516
517 #define IS_RTC_ALARM_SUB_SECOND_MASK(__MASK__) (((__MASK__) == RTC_ALARMSUBSECONDMASK_ALL) || \
518 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_1) || \
519 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_2) || \
520 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_3) || \
521 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_4) || \
522 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_5) || \
523 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_6) || \
524 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_7) || \
525 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_8) || \
526 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_9) || \
527 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_10) || \
528 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_11) || \
529 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_12) || \
530 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14_13) || \
531 ((__MASK__) == RTC_ALARMSUBSECONDMASK_SS14) || \
532 ((__MASK__) == RTC_ALARMSUBSECONDMASK_NONE))
533 /**
534 * @}
535 */
536
537 /** @defgroup RTC_Interrupts_Definitions RTC Interrupts Definitions
538 * @{
539 */
540 #define RTC_IT_TS ((uint32_t)RTC_CR_TSIE)
541 #define RTC_IT_WUT ((uint32_t)RTC_CR_WUTIE)
542 #define RTC_IT_ALRB ((uint32_t)RTC_CR_ALRBIE)
543 #define RTC_IT_ALRA ((uint32_t)RTC_CR_ALRAIE)
544 #define RTC_IT_TAMP ((uint32_t)RTC_TAMPCR_TAMPIE) /* Used only to Enable the Tamper Interrupt */
545 #define RTC_IT_TAMP1 ((uint32_t)RTC_TAMPCR_TAMP1IE)
546 #define RTC_IT_TAMP2 ((uint32_t)RTC_TAMPCR_TAMP2IE)
547 /**
548 * @}
549 */
550
551 /** @defgroup RTC_Flags_Definitions RTC Flags Definitions
552 * @{
553 */
554 #define RTC_FLAG_RECALPF ((uint32_t)RTC_ISR_RECALPF)
555 #define RTC_FLAG_TAMP2F ((uint32_t)RTC_ISR_TAMP2F)
556 #define RTC_FLAG_TAMP1F ((uint32_t)RTC_ISR_TAMP1F)
557 #define RTC_FLAG_TSOVF ((uint32_t)RTC_ISR_TSOVF)
558 #define RTC_FLAG_TSF ((uint32_t)RTC_ISR_TSF)
559 #define RTC_FLAG_WUTF ((uint32_t)RTC_ISR_WUTF)
560 #define RTC_FLAG_ALRBF ((uint32_t)RTC_ISR_ALRBF)
561 #define RTC_FLAG_ALRAF ((uint32_t)RTC_ISR_ALRAF)
562 #define RTC_FLAG_INIT ((uint32_t)RTC_ISR_INIT)
563 #define RTC_FLAG_INITF ((uint32_t)RTC_ISR_INITF)
564 #define RTC_FLAG_RSF ((uint32_t)RTC_ISR_RSF)
565 #define RTC_FLAG_INITS ((uint32_t)RTC_ISR_INITS)
566 #define RTC_FLAG_SHPF ((uint32_t)RTC_ISR_SHPF)
567 #define RTC_FLAG_WUTWF ((uint32_t)RTC_ISR_WUTWF)
568 #define RTC_FLAG_ALRBWF ((uint32_t)RTC_ISR_ALRBWF)
569 #define RTC_FLAG_ALRAWF ((uint32_t)RTC_ISR_ALRAWF)
570 /**
571 * @}
572 */
573
574 /**
575 * @}
576 */
577
578 /* Exported macros -----------------------------------------------------------*/
579 /** @defgroup RTC_Exported_Macros RTC Exported Macros
580 * @{
581 */
582
583 /** @brief Reset RTC handle state
584 * @param __HANDLE__: RTC handle.
585 * @retval None
586 */
587 #define __HAL_RTC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RTC_STATE_RESET)
588
589 /**
590 * @brief Disable the write protection for RTC registers.
591 * @param __HANDLE__: specifies the RTC handle.
592 * @retval None
593 */
594 #define __HAL_RTC_WRITEPROTECTION_DISABLE(__HANDLE__) \
595 do{ \
596 (__HANDLE__)->Instance->WPR = 0xCA; \
597 (__HANDLE__)->Instance->WPR = 0x53; \
598 } while(0)
599
600 /**
601 * @brief Enable the write protection for RTC registers.
602 * @param __HANDLE__: specifies the RTC handle.
603 * @retval None
604 */
605 #define __HAL_RTC_WRITEPROTECTION_ENABLE(__HANDLE__) \
606 do{ \
607 (__HANDLE__)->Instance->WPR = 0xFF; \
608 } while(0)
609
610 /**
611 * @brief Enable the RTC ALARMA peripheral.
612 * @param __HANDLE__: specifies the RTC handle.
613 * @retval None
614 */
615 #define __HAL_RTC_ALARMA_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRAE))
616
617 /**
618 * @brief Disable the RTC ALARMA peripheral.
619 * @param __HANDLE__: specifies the RTC handle.
620 * @retval None
621 */
622 #define __HAL_RTC_ALARMA_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRAE))
623
624 /**
625 * @brief Enable the RTC ALARMB peripheral.
626 * @param __HANDLE__: specifies the RTC handle.
627 * @retval None
628 */
629 #define __HAL_RTC_ALARMB_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= (RTC_CR_ALRBE))
630
631 /**
632 * @brief Disable the RTC ALARMB peripheral.
633 * @param __HANDLE__: specifies the RTC handle.
634 * @retval None
635 */
636 #define __HAL_RTC_ALARMB_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(RTC_CR_ALRBE))
637
638 /**
639 * @brief Enable the RTC Alarm interrupt.
640 * @param __HANDLE__: specifies the RTC handle.
641 * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled.
642 * This parameter can be any combination of the following values:
643 * @arg RTC_IT_ALRA: Alarm A interrupt
644 * @arg RTC_IT_ALRB: Alarm B interrupt
645 * @retval None
646 */
647 #define __HAL_RTC_ALARM_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
648
649 /**
650 * @brief Disable the RTC Alarm interrupt.
651 * @param __HANDLE__: specifies the RTC handle.
652 * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to be enabled or disabled.
653 * This parameter can be any combination of the following values:
654 * @arg RTC_IT_ALRA: Alarm A interrupt
655 * @arg RTC_IT_ALRB: Alarm B interrupt
656 * @retval None
657 */
658 #define __HAL_RTC_ALARM_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
659
660 /**
661 * @brief Check whether the specified RTC Alarm interrupt has occurred or not.
662 * @param __HANDLE__: specifies the RTC handle.
663 * @param __INTERRUPT__: specifies the RTC Alarm interrupt sources to check.
664 * This parameter can be:
665 * @arg RTC_IT_ALRA: Alarm A interrupt
666 * @arg RTC_IT_ALRB: Alarm B interrupt
667 * @retval None
668 */
669 #define __HAL_RTC_ALARM_GET_IT(__HANDLE__, __INTERRUPT__) ((((((__HANDLE__)->Instance->ISR)& ((__INTERRUPT__)>> 4)) & RTC_FLAGS_MASK) != RESET)? SET : RESET)
670
671 /**
672 * @brief Get the selected RTC Alarm's flag status.
673 * @param __HANDLE__: specifies the RTC handle.
674 * @param __FLAG__: specifies the RTC Alarm Flag sources to check.
675 * This parameter can be:
676 * @arg RTC_FLAG_ALRAF
677 * @arg RTC_FLAG_ALRBF
678 * @arg RTC_FLAG_ALRAWF
679 * @arg RTC_FLAG_ALRBWF
680 * @retval None
681 */
682 #define __HAL_RTC_ALARM_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) != RESET)? SET : RESET)
683
684 /**
685 * @brief Clear the RTC Alarm's pending flags.
686 * @param __HANDLE__: specifies the RTC handle.
687 * @param __FLAG__: specifies the RTC Alarm Flag sources to clear.
688 * This parameter can be:
689 * @arg RTC_FLAG_ALRAF
690 * @arg RTC_FLAG_ALRBF
691 * @retval None
692 */
693 #define __HAL_RTC_ALARM_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR) = (~(((__FLAG__) | RTC_ISR_INIT)& RTC_FLAGS_MASK) | ((__HANDLE__)->Instance->ISR & RTC_ISR_INIT))
694
695 #define RTC_EXTI_LINE_ALARM_EVENT ((uint32_t)EXTI_IMR_IM17) /*!< External interrupt line 17 Connected to the RTC Alarm event */
696 #define RTC_EXTI_LINE_TAMPER_TIMESTAMP_EVENT ((uint32_t)EXTI_IMR_IM19) /*!< External interrupt line 19 Connected to the RTC Tamper and Time Stamp events */
697 #define RTC_EXTI_LINE_WAKEUPTIMER_EVENT ((uint32_t)EXTI_IMR_IM20) /*!< External interrupt line 20 Connected to the RTC Wakeup event */
698
699 /**
700 * @brief Enable interrupt on the RTC Alarm associated Exti line.
701 * @retval None
702 */
703 #define __HAL_RTC_ALARM_EXTI_ENABLE_IT() (EXTI->IMR |= RTC_EXTI_LINE_ALARM_EVENT)
704
705 /**
706 * @brief Disable interrupt on the RTC Alarm associated Exti line.
707 * @retval None
708 */
709 #define __HAL_RTC_ALARM_EXTI_DISABLE_IT() (EXTI->IMR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
710
711 /**
712 * @brief Enable event on the RTC Alarm associated Exti line.
713 * @retval None.
714 */
715 #define __HAL_RTC_ALARM_EXTI_ENABLE_EVENT() (EXTI->EMR |= RTC_EXTI_LINE_ALARM_EVENT)
716
717 /**
718 * @brief Disable event on the RTC Alarm associated Exti line.
719 * @retval None.
720 */
721 #define __HAL_RTC_ALARM_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
722
723 /**
724 * @brief Enable falling edge trigger on the RTC Alarm associated Exti line.
725 * @retval None.
726 */
727 #define __HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE() (EXTI->FTSR |= RTC_EXTI_LINE_ALARM_EVENT)
728
729 /**
730 * @brief Disable falling edge trigger on the RTC Alarm associated Exti line.
731 * @retval None.
732 */
733 #define __HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE() (EXTI->FTSR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
734
735 /**
736 * @brief Enable rising edge trigger on the RTC Alarm associated Exti line.
737 * @retval None.
738 */
739 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE() (EXTI->RTSR |= RTC_EXTI_LINE_ALARM_EVENT)
740
741 /**
742 * @brief Disable rising edge trigger on the RTC Alarm associated Exti line.
743 * @retval None.
744 */
745 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE() (EXTI->RTSR &= ~(RTC_EXTI_LINE_ALARM_EVENT))
746
747 /**
748 * @brief Enable rising & falling edge trigger on the RTC Alarm associated Exti line.
749 * @retval None.
750 */
751 #define __HAL_RTC_ALARM_EXTI_ENABLE_RISING_FALLING_EDGE() __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE();__HAL_RTC_ALARM_EXTI_ENABLE_FALLING_EDGE();
752
753 /**
754 * @brief Disable rising & falling edge trigger on the RTC Alarm associated Exti line.
755 * @retval None.
756 */
757 #define __HAL_RTC_ALARM_EXTI_DISABLE_RISING_FALLING_EDGE() __HAL_RTC_ALARM_EXTI_DISABLE_RISING_EDGE();__HAL_RTC_ALARM_EXTI_DISABLE_FALLING_EDGE();
758
759 /**
760 * @brief Check whether the RTC Alarm associated Exti line interrupt flag is set or not.
761 * @retval Line Status.
762 */
763 #define __HAL_RTC_ALARM_EXTI_GET_FLAG() (EXTI->PR & RTC_EXTI_LINE_ALARM_EVENT)
764
765 /**
766 * @brief Clear the RTC Alarm associated Exti line flag.
767 * @retval None.
768 */
769 #define __HAL_RTC_ALARM_EXTI_CLEAR_FLAG() (EXTI->PR = RTC_EXTI_LINE_ALARM_EVENT)
770
771 /**
772 * @brief Generate a Software interrupt on RTC Alarm associated Exti line.
773 * @retval None.
774 */
775 #define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_ALARM_EVENT)
776
777 /**
778 * @brief Generate a Software interrupt on RTC Alarm associated Exti line.
779 * @retval None.
780 */
781 #define __HAL_RTC_ALARM_EXTI_GENERATE_SWIT() (EXTI->SWIER |= RTC_EXTI_LINE_ALARM_EVENT)
782
783
784 /**
785 * @}
786 */
787
788 /* Include RTC HAL Extended module */
789 #include "stm32l0xx_hal_rtc_ex.h"
790
791 /* Exported functions --------------------------------------------------------*/
792 /** @defgroup RTC_Exported_Functions RTC Exported Functions
793 * @{
794 */
795
796 /** @defgroup RTC_Exported_Functions_Group1 Initialization and de-initialization functions
797 * @{
798 */
799 /* Initialization and de-initialization functions ****************************/
800 HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc);
801 HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc);
802 void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc);
803 void HAL_RTC_MspDeInit(RTC_HandleTypeDef *hrtc);
804 /**
805 * @}
806 */
807
808 /** @defgroup RTC_Exported_Functions_Group2 RTC Time and Date functions
809 * @{
810 */
811 /* RTC Time and Date functions ************************************************/
812 HAL_StatusTypeDef HAL_RTC_SetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
813 HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format);
814 HAL_StatusTypeDef HAL_RTC_SetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
815 HAL_StatusTypeDef HAL_RTC_GetDate(RTC_HandleTypeDef *hrtc, RTC_DateTypeDef *sDate, uint32_t Format);
816 /**
817 * @}
818 */
819
820 /** @defgroup RTC_Exported_Functions_Group3 RTC Alarm functions
821 * @{
822 */
823 /* RTC Alarm functions ********************************************************/
824 HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
825 HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format);
826 HAL_StatusTypeDef HAL_RTC_DeactivateAlarm(RTC_HandleTypeDef *hrtc, uint32_t Alarm);
827 HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format);
828 void HAL_RTC_AlarmIRQHandler(RTC_HandleTypeDef *hrtc);
829 HAL_StatusTypeDef HAL_RTC_PollForAlarmAEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout);
830 void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc);
831 /**
832 * @}
833 */
834
835 /** @defgroup RTC_Exported_Functions_Group4 Peripheral Control functions
836 * @{
837 */
838 /* Peripheral Control functions ***********************************************/
839 HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef* hrtc);
840 /**
841 * @}
842 */
843
844 /** @defgroup RTC_Exported_Functions_Group5 Peripheral State functions
845 * @{
846 */
847 /* Peripheral State functions *************************************************/
848 HAL_RTCStateTypeDef HAL_RTC_GetState(RTC_HandleTypeDef *hrtc);
849 /**
850 * @}
851 */
852
853 /**
854 * @}
855 */
856
857 /** @defgroup RTC_Private_Functions RTC Private Functions
858 * @{
859 */
860 HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef* hrtc);
861 uint8_t RTC_ByteToBcd2(uint8_t Value);
862 uint8_t RTC_Bcd2ToByte(uint8_t Value);
863 /**
864 * @}
865 */
866
867 /**
868 * @}
869 */
870
871 /**
872 * @}
873 */
874
875 #ifdef __cplusplus
876 }
877 #endif
878
879 #endif /* __STM32L0xx_HAL_RTC_H */
880
881 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
882
Imprint / Impressum