Dataloger

Committer:
jhon309
Date:
Thu Aug 20 00:37:14 2015 +0000
Revision:
0:666850d06c9f
ok

Who changed what in which revision?

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