Soundharrajan

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Wed Jun 11 15:14:05 2014 +0100
Revision:
85:024bf7f99721
Release 85 of the mbed library

Main changes:

- K64F Ethernet fixes
- Updated tests
- Fixes for various mbed targets
- Code cleanup: fixed warnings, more consistent code style
- GCC support for K64F

There is a known issue with the I2C interface on some ST targets. If you
find the I2C interface problematic on your ST board, please log a bug
against this on mbed.org.

Who changed what in which revision?

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