The official mbed C/C SDK provides the software platform and libraries to build your applications.

Fork of mbed by mbed official

Committer:
Mikchel
Date:
Sun May 03 16:04:42 2015 +0000
Revision:
99:7f6c6de930c0
Parent:
93:e188a91d3eaa
12

Who changed what in which revision?

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