mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
shaoziyang
Date:
Sat Sep 13 14:25:46 2014 +0000
Revision:
323:9e901b0a5aa1
Parent:
235:685d5f11838f
test with CLOCK_SETUP = 0

Who changed what in which revision?

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