I2C_EEPROM

Committer:
jhon309
Date:
Thu Aug 13 00:23:16 2015 +0000
Revision:
0:ac8863619623
I2C

Who changed what in which revision?

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