Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Space_Invaders_Demo neopixels gpio_test_stm32f3_discovery gpio_test_systimer ... more
stm32f30x_rtc.h
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f30x_rtc.h 00004 * @author MCD Application Team 00005 * @version V1.2.3 00006 * @date 10-July-2015 00007 * @brief This file contains all the functions prototypes for the RTC firmware 00008 * library. 00009 ****************************************************************************** 00010 * @attention 00011 * 00012 * <h2><center>© COPYRIGHT 2015 STMicroelectronics</center></h2> 00013 * 00014 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 00015 * You may not use this file except in compliance with the License. 00016 * You may obtain a copy of the License at: 00017 * 00018 * http://www.st.com/software_license_agreement_liberty_v2 00019 * 00020 * Unless required by applicable law or agreed to in writing, software 00021 * distributed under the License is distributed on an "AS IS" BASIS, 00022 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00023 * See the License for the specific language governing permissions and 00024 * limitations under the License. 00025 * 00026 ****************************************************************************** 00027 */ 00028 00029 /* Define to prevent recursive inclusion -------------------------------------*/ 00030 #ifndef __STM32F30x_RTC_H 00031 #define __STM32F30x_RTC_H 00032 00033 #ifdef __cplusplus 00034 extern "C" { 00035 #endif 00036 00037 /* Includes ------------------------------------------------------------------*/ 00038 #include "stm32f30x.h" 00039 00040 /** @addtogroup STM32F30x_StdPeriph_Driver 00041 * @{ 00042 */ 00043 00044 /** @addtogroup RTC 00045 * @{ 00046 */ 00047 00048 /* Exported types ------------------------------------------------------------*/ 00049 00050 /** 00051 * @brief RTC Init structures definition 00052 */ 00053 typedef struct 00054 { 00055 uint32_t RTC_HourFormat; /*!< Specifies the RTC Hour Format. 00056 This parameter can be a value of @ref RTC_Hour_Formats */ 00057 00058 uint32_t RTC_AsynchPrediv; /*!< Specifies the RTC Asynchronous Predivider value. 00059 This parameter must be set to a value lower than 0x7F */ 00060 00061 uint32_t RTC_SynchPrediv; /*!< Specifies the RTC Synchronous Predivider value. 00062 This parameter must be set to a value lower than 0x1FFF */ 00063 }RTC_InitTypeDef; 00064 00065 /** 00066 * @brief RTC Time structure definition 00067 */ 00068 typedef struct 00069 { 00070 uint8_t RTC_Hours; /*!< Specifies the RTC Time Hour. 00071 This parameter must be set to a value in the 0-12 range 00072 if the RTC_HourFormat_12 is selected or 0-23 range if 00073 the RTC_HourFormat_24 is selected. */ 00074 00075 uint8_t RTC_Minutes; /*!< Specifies the RTC Time Minutes. 00076 This parameter must be set to a value in the 0-59 range. */ 00077 00078 uint8_t RTC_Seconds; /*!< Specifies the RTC Time Seconds. 00079 This parameter must be set to a value in the 0-59 range. */ 00080 00081 uint8_t RTC_H12; /*!< Specifies the RTC AM/PM Time. 00082 This parameter can be a value of @ref RTC_AM_PM_Definitions */ 00083 }RTC_TimeTypeDef; 00084 00085 /** 00086 * @brief RTC Date structure definition 00087 */ 00088 typedef struct 00089 { 00090 uint8_t RTC_WeekDay; /*!< Specifies the RTC Date WeekDay. 00091 This parameter can be a value of @ref RTC_WeekDay_Definitions */ 00092 00093 uint8_t RTC_Month; /*!< Specifies the RTC Date Month (in BCD format). 00094 This parameter can be a value of @ref RTC_Month_Date_Definitions */ 00095 00096 uint8_t RTC_Date; /*!< Specifies the RTC Date. 00097 This parameter must be set to a value in the 1-31 range. */ 00098 00099 uint8_t RTC_Year; /*!< Specifies the RTC Date Year. 00100 This parameter must be set to a value in the 0-99 range. */ 00101 }RTC_DateTypeDef; 00102 00103 /** 00104 * @brief RTC Alarm structure definition 00105 */ 00106 typedef struct 00107 { 00108 RTC_TimeTypeDef RTC_AlarmTime; /*!< Specifies the RTC Alarm Time members. */ 00109 00110 uint32_t RTC_AlarmMask; /*!< Specifies the RTC Alarm Masks. 00111 This parameter can be a value of @ref RTC_AlarmMask_Definitions */ 00112 00113 uint32_t RTC_AlarmDateWeekDaySel; /*!< Specifies the RTC Alarm is on Date or WeekDay. 00114 This parameter can be a value of @ref RTC_AlarmDateWeekDay_Definitions */ 00115 00116 uint8_t RTC_AlarmDateWeekDay; /*!< Specifies the RTC Alarm Date/WeekDay. 00117 If the Alarm Date is selected, this parameter 00118 must be set to a value in the 1-31 range. 00119 If the Alarm WeekDay is selected, this 00120 parameter can be a value of @ref RTC_WeekDay_Definitions */ 00121 }RTC_AlarmTypeDef; 00122 00123 /* Exported constants --------------------------------------------------------*/ 00124 00125 /** @defgroup RTC_Exported_Constants 00126 * @{ 00127 */ 00128 00129 00130 /** @defgroup RTC_Hour_Formats 00131 * @{ 00132 */ 00133 #define RTC_HourFormat_24 ((uint32_t)0x00000000) 00134 #define RTC_HourFormat_12 ((uint32_t)0x00000040) 00135 #define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HourFormat_12) || \ 00136 ((FORMAT) == RTC_HourFormat_24)) 00137 /** 00138 * @} 00139 */ 00140 00141 /** @defgroup RTC_Asynchronous_Predivider 00142 * @{ 00143 */ 00144 #define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7F) 00145 00146 /** 00147 * @} 00148 */ 00149 00150 00151 /** @defgroup RTC_Synchronous_Predivider 00152 * @{ 00153 */ 00154 #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7FFF) 00155 00156 /** 00157 * @} 00158 */ 00159 00160 /** @defgroup RTC_Time_Definitions 00161 * @{ 00162 */ 00163 #define IS_RTC_HOUR12(HOUR) (((HOUR) > 0) && ((HOUR) <= 12)) 00164 #define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23) 00165 #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59) 00166 #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59) 00167 00168 /** 00169 * @} 00170 */ 00171 00172 /** @defgroup RTC_AM_PM_Definitions 00173 * @{ 00174 */ 00175 #define RTC_H12_AM ((uint8_t)0x00) 00176 #define RTC_H12_PM ((uint8_t)0x40) 00177 #define IS_RTC_H12(PM) (((PM) == RTC_H12_AM) || ((PM) == RTC_H12_PM)) 00178 00179 /** 00180 * @} 00181 */ 00182 00183 /** @defgroup RTC_Year_Date_Definitions 00184 * @{ 00185 */ 00186 #define IS_RTC_YEAR(YEAR) ((YEAR) <= 99) 00187 00188 /** 00189 * @} 00190 */ 00191 00192 /** @defgroup RTC_Month_Date_Definitions 00193 * @{ 00194 */ 00195 00196 /* Coded in BCD format */ 00197 #define RTC_Month_January ((uint8_t)0x01) 00198 #define RTC_Month_February ((uint8_t)0x02) 00199 #define RTC_Month_March ((uint8_t)0x03) 00200 #define RTC_Month_April ((uint8_t)0x04) 00201 #define RTC_Month_May ((uint8_t)0x05) 00202 #define RTC_Month_June ((uint8_t)0x06) 00203 #define RTC_Month_July ((uint8_t)0x07) 00204 #define RTC_Month_August ((uint8_t)0x08) 00205 #define RTC_Month_September ((uint8_t)0x09) 00206 #define RTC_Month_October ((uint8_t)0x10) 00207 #define RTC_Month_November ((uint8_t)0x11) 00208 #define RTC_Month_December ((uint8_t)0x12) 00209 #define IS_RTC_MONTH(MONTH) (((MONTH) >= 1) && ((MONTH) <= 12)) 00210 #define IS_RTC_DATE(DATE) (((DATE) >= 1) && ((DATE) <= 31)) 00211 00212 /** 00213 * @} 00214 */ 00215 00216 /** @defgroup RTC_WeekDay_Definitions 00217 * @{ 00218 */ 00219 00220 #define RTC_Weekday_Monday ((uint8_t)0x01) 00221 #define RTC_Weekday_Tuesday ((uint8_t)0x02) 00222 #define RTC_Weekday_Wednesday ((uint8_t)0x03) 00223 #define RTC_Weekday_Thursday ((uint8_t)0x04) 00224 #define RTC_Weekday_Friday ((uint8_t)0x05) 00225 #define RTC_Weekday_Saturday ((uint8_t)0x06) 00226 #define RTC_Weekday_Sunday ((uint8_t)0x07) 00227 #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_Weekday_Monday) || \ 00228 ((WEEKDAY) == RTC_Weekday_Tuesday) || \ 00229 ((WEEKDAY) == RTC_Weekday_Wednesday) || \ 00230 ((WEEKDAY) == RTC_Weekday_Thursday) || \ 00231 ((WEEKDAY) == RTC_Weekday_Friday) || \ 00232 ((WEEKDAY) == RTC_Weekday_Saturday) || \ 00233 ((WEEKDAY) == RTC_Weekday_Sunday)) 00234 /** 00235 * @} 00236 */ 00237 00238 00239 /** @defgroup RTC_Alarm_Definitions 00240 * @{ 00241 */ 00242 #define IS_RTC_ALARM_DATE_WEEKDAY_DATE(DATE) (((DATE) > 0) && ((DATE) <= 31)) 00243 #define IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_Weekday_Monday) || \ 00244 ((WEEKDAY) == RTC_Weekday_Tuesday) || \ 00245 ((WEEKDAY) == RTC_Weekday_Wednesday) || \ 00246 ((WEEKDAY) == RTC_Weekday_Thursday) || \ 00247 ((WEEKDAY) == RTC_Weekday_Friday) || \ 00248 ((WEEKDAY) == RTC_Weekday_Saturday) || \ 00249 ((WEEKDAY) == RTC_Weekday_Sunday)) 00250 00251 /** 00252 * @} 00253 */ 00254 00255 00256 /** @defgroup RTC_AlarmDateWeekDay_Definitions 00257 * @{ 00258 */ 00259 #define RTC_AlarmDateWeekDaySel_Date ((uint32_t)0x00000000) 00260 #define RTC_AlarmDateWeekDaySel_WeekDay ((uint32_t)0x40000000) 00261 00262 #define IS_RTC_ALARM_DATE_WEEKDAY_SEL(SEL) (((SEL) == RTC_AlarmDateWeekDaySel_Date) || \ 00263 ((SEL) == RTC_AlarmDateWeekDaySel_WeekDay)) 00264 00265 /** 00266 * @} 00267 */ 00268 00269 00270 /** @defgroup RTC_AlarmMask_Definitions 00271 * @{ 00272 */ 00273 #define RTC_AlarmMask_None ((uint32_t)0x00000000) 00274 #define RTC_AlarmMask_DateWeekDay ((uint32_t)0x80000000) 00275 #define RTC_AlarmMask_Hours ((uint32_t)0x00800000) 00276 #define RTC_AlarmMask_Minutes ((uint32_t)0x00008000) 00277 #define RTC_AlarmMask_Seconds ((uint32_t)0x00000080) 00278 #define RTC_AlarmMask_All ((uint32_t)0x80808080) 00279 #define IS_ALARM_MASK(MASK) (((MASK) & 0x7F7F7F7F) == (uint32_t)RESET) 00280 00281 /** 00282 * @} 00283 */ 00284 00285 /** @defgroup RTC_Alarms_Definitions 00286 * @{ 00287 */ 00288 #define RTC_Alarm_A ((uint32_t)0x00000100) 00289 #define RTC_Alarm_B ((uint32_t)0x00000200) 00290 #define IS_RTC_ALARM(ALARM) (((ALARM) == RTC_Alarm_A) || ((ALARM) == RTC_Alarm_B)) 00291 #define IS_RTC_CMD_ALARM(ALARM) (((ALARM) & (RTC_Alarm_A | RTC_Alarm_B)) != (uint32_t)RESET) 00292 00293 /** 00294 * @} 00295 */ 00296 00297 /** @defgroup RTC_Alarm_Sub_Seconds_Masks_Definitions 00298 * @{ 00299 */ 00300 #define RTC_AlarmSubSecondMask_All ((uint32_t)0x00000000) /*!< All Alarm SS fields are masked. 00301 There is no comparison on sub seconds 00302 for Alarm */ 00303 #define RTC_AlarmSubSecondMask_SS14_1 ((uint32_t)0x01000000) /*!< SS[14:1] are don't care in Alarm 00304 comparison. Only SS[0] is compared. */ 00305 #define RTC_AlarmSubSecondMask_SS14_2 ((uint32_t)0x02000000) /*!< SS[14:2] are don't care in Alarm 00306 comparison. Only SS[1:0] are compared */ 00307 #define RTC_AlarmSubSecondMask_SS14_3 ((uint32_t)0x03000000) /*!< SS[14:3] are don't care in Alarm 00308 comparison. Only SS[2:0] are compared */ 00309 #define RTC_AlarmSubSecondMask_SS14_4 ((uint32_t)0x04000000) /*!< SS[14:4] are don't care in Alarm 00310 comparison. Only SS[3:0] are compared */ 00311 #define RTC_AlarmSubSecondMask_SS14_5 ((uint32_t)0x05000000) /*!< SS[14:5] are don't care in Alarm 00312 comparison. Only SS[4:0] are compared */ 00313 #define RTC_AlarmSubSecondMask_SS14_6 ((uint32_t)0x06000000) /*!< SS[14:6] are don't care in Alarm 00314 comparison. Only SS[5:0] are compared */ 00315 #define RTC_AlarmSubSecondMask_SS14_7 ((uint32_t)0x07000000) /*!< SS[14:7] are don't care in Alarm 00316 comparison. Only SS[6:0] are compared */ 00317 #define RTC_AlarmSubSecondMask_SS14_8 ((uint32_t)0x08000000) /*!< SS[14:8] are don't care in Alarm 00318 comparison. Only SS[7:0] are compared */ 00319 #define RTC_AlarmSubSecondMask_SS14_9 ((uint32_t)0x09000000) /*!< SS[14:9] are don't care in Alarm 00320 comparison. Only SS[8:0] are compared */ 00321 #define RTC_AlarmSubSecondMask_SS14_10 ((uint32_t)0x0A000000) /*!< SS[14:10] are don't care in Alarm 00322 comparison. Only SS[9:0] are compared */ 00323 #define RTC_AlarmSubSecondMask_SS14_11 ((uint32_t)0x0B000000) /*!< SS[14:11] are don't care in Alarm 00324 comparison. Only SS[10:0] are compared */ 00325 #define RTC_AlarmSubSecondMask_SS14_12 ((uint32_t)0x0C000000) /*!< SS[14:12] are don't care in Alarm 00326 comparison.Only SS[11:0] are compared */ 00327 #define RTC_AlarmSubSecondMask_SS14_13 ((uint32_t)0x0D000000) /*!< SS[14:13] are don't care in Alarm 00328 comparison. Only SS[12:0] are compared */ 00329 #define RTC_AlarmSubSecondMask_SS14 ((uint32_t)0x0E000000) /*!< SS[14] is don't care in Alarm 00330 comparison.Only SS[13:0] are compared */ 00331 #define RTC_AlarmSubSecondMask_None ((uint32_t)0x0F000000) /*!< SS[14:0] are compared and must match 00332 to activate alarm. */ 00333 #define IS_RTC_ALARM_SUB_SECOND_MASK(MASK) (((MASK) == RTC_AlarmSubSecondMask_All) || \ 00334 ((MASK) == RTC_AlarmSubSecondMask_SS14_1) || \ 00335 ((MASK) == RTC_AlarmSubSecondMask_SS14_2) || \ 00336 ((MASK) == RTC_AlarmSubSecondMask_SS14_3) || \ 00337 ((MASK) == RTC_AlarmSubSecondMask_SS14_4) || \ 00338 ((MASK) == RTC_AlarmSubSecondMask_SS14_5) || \ 00339 ((MASK) == RTC_AlarmSubSecondMask_SS14_6) || \ 00340 ((MASK) == RTC_AlarmSubSecondMask_SS14_7) || \ 00341 ((MASK) == RTC_AlarmSubSecondMask_SS14_8) || \ 00342 ((MASK) == RTC_AlarmSubSecondMask_SS14_9) || \ 00343 ((MASK) == RTC_AlarmSubSecondMask_SS14_10) || \ 00344 ((MASK) == RTC_AlarmSubSecondMask_SS14_11) || \ 00345 ((MASK) == RTC_AlarmSubSecondMask_SS14_12) || \ 00346 ((MASK) == RTC_AlarmSubSecondMask_SS14_13) || \ 00347 ((MASK) == RTC_AlarmSubSecondMask_SS14) || \ 00348 ((MASK) == RTC_AlarmSubSecondMask_None)) 00349 /** 00350 * @} 00351 */ 00352 00353 /** @defgroup RTC_Alarm_Sub_Seconds_Value 00354 * @{ 00355 */ 00356 00357 #define IS_RTC_ALARM_SUB_SECOND_VALUE(VALUE) ((VALUE) <= 0x00007FFF) 00358 00359 /** 00360 * @} 00361 */ 00362 00363 /** @defgroup RTC_Wakeup_Timer_Definitions 00364 * @{ 00365 */ 00366 #define RTC_WakeUpClock_RTCCLK_Div16 ((uint32_t)0x00000000) 00367 #define RTC_WakeUpClock_RTCCLK_Div8 ((uint32_t)0x00000001) 00368 #define RTC_WakeUpClock_RTCCLK_Div4 ((uint32_t)0x00000002) 00369 #define RTC_WakeUpClock_RTCCLK_Div2 ((uint32_t)0x00000003) 00370 #define RTC_WakeUpClock_CK_SPRE_16bits ((uint32_t)0x00000004) 00371 #define RTC_WakeUpClock_CK_SPRE_17bits ((uint32_t)0x00000006) 00372 #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WakeUpClock_RTCCLK_Div16) || \ 00373 ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div8) || \ 00374 ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div4) || \ 00375 ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div2) || \ 00376 ((CLOCK) == RTC_WakeUpClock_CK_SPRE_16bits) || \ 00377 ((CLOCK) == RTC_WakeUpClock_CK_SPRE_17bits)) 00378 #define IS_RTC_WAKEUP_COUNTER(COUNTER) ((COUNTER) <= 0xFFFF) 00379 /** 00380 * @} 00381 */ 00382 00383 /** @defgroup RTC_Time_Stamp_Edges_definitions 00384 * @{ 00385 */ 00386 #define RTC_TimeStampEdge_Rising ((uint32_t)0x00000000) 00387 #define RTC_TimeStampEdge_Falling ((uint32_t)0x00000008) 00388 #define IS_RTC_TIMESTAMP_EDGE(EDGE) (((EDGE) == RTC_TimeStampEdge_Rising) || \ 00389 ((EDGE) == RTC_TimeStampEdge_Falling)) 00390 /** 00391 * @} 00392 */ 00393 00394 /** @defgroup RTC_Output_selection_Definitions 00395 * @{ 00396 */ 00397 #define RTC_Output_Disable ((uint32_t)0x00000000) 00398 #define RTC_Output_AlarmA ((uint32_t)0x00200000) 00399 #define RTC_Output_AlarmB ((uint32_t)0x00400000) 00400 #define RTC_Output_WakeUp ((uint32_t)0x00600000) 00401 00402 #define IS_RTC_OUTPUT(OUTPUT) (((OUTPUT) == RTC_Output_Disable) || \ 00403 ((OUTPUT) == RTC_Output_AlarmA) || \ 00404 ((OUTPUT) == RTC_Output_AlarmB) || \ 00405 ((OUTPUT) == RTC_Output_WakeUp)) 00406 00407 /** 00408 * @} 00409 */ 00410 00411 /** @defgroup RTC_Output_Polarity_Definitions 00412 * @{ 00413 */ 00414 #define RTC_OutputPolarity_High ((uint32_t)0x00000000) 00415 #define RTC_OutputPolarity_Low ((uint32_t)0x00100000) 00416 #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OutputPolarity_High) || \ 00417 ((POL) == RTC_OutputPolarity_Low)) 00418 /** 00419 * @} 00420 */ 00421 00422 /** @defgroup RTC_Digital_Calibration_Definitions 00423 * @{ 00424 */ 00425 #define RTC_CalibSign_Positive ((uint32_t)0x00000000) 00426 #define RTC_CalibSign_Negative ((uint32_t)0x00000080) 00427 #define IS_RTC_CALIB_SIGN(SIGN) (((SIGN) == RTC_CalibSign_Positive) || \ 00428 ((SIGN) == RTC_CalibSign_Negative)) 00429 #define IS_RTC_CALIB_VALUE(VALUE) ((VALUE) < 0x20) 00430 00431 /** 00432 * @} 00433 */ 00434 00435 /** @defgroup RTC_Calib_Output_selection_Definitions 00436 * @{ 00437 */ 00438 #define RTC_CalibOutput_512Hz ((uint32_t)0x00000000) 00439 #define RTC_CalibOutput_1Hz ((uint32_t)0x00080000) 00440 #define IS_RTC_CALIB_OUTPUT(OUTPUT) (((OUTPUT) == RTC_CalibOutput_512Hz) || \ 00441 ((OUTPUT) == RTC_CalibOutput_1Hz)) 00442 /** 00443 * @} 00444 */ 00445 00446 /** @defgroup RTC_Smooth_calib_period_Definitions 00447 * @{ 00448 */ 00449 #define RTC_SmoothCalibPeriod_32sec ((uint32_t)0x00000000) /*!< if RTCCLK = 32768 Hz, Smooth calibation 00450 period is 32s, else 2exp20 RTCCLK seconds */ 00451 #define RTC_SmoothCalibPeriod_16sec ((uint32_t)0x00002000) /*!< if RTCCLK = 32768 Hz, Smooth calibation 00452 period is 16s, else 2exp19 RTCCLK seconds */ 00453 #define RTC_SmoothCalibPeriod_8sec ((uint32_t)0x00004000) /*!< if RTCCLK = 32768 Hz, Smooth calibation 00454 period is 8s, else 2exp18 RTCCLK seconds */ 00455 #define IS_RTC_SMOOTH_CALIB_PERIOD(PERIOD) (((PERIOD) == RTC_SmoothCalibPeriod_32sec) || \ 00456 ((PERIOD) == RTC_SmoothCalibPeriod_16sec) || \ 00457 ((PERIOD) == RTC_SmoothCalibPeriod_8sec)) 00458 00459 /** 00460 * @} 00461 */ 00462 00463 /** @defgroup RTC_Smooth_calib_Plus_pulses_Definitions 00464 * @{ 00465 */ 00466 #define RTC_SmoothCalibPlusPulses_Set ((uint32_t)0x00008000) /*!< The number of RTCCLK pulses added 00467 during a X -second window = Y - CALM[8:0]. 00468 with Y = 512, 256, 128 when X = 32, 16, 8 */ 00469 #define RTC_SmoothCalibPlusPulses_Reset ((uint32_t)0x00000000) /*!< The number of RTCCLK pulses subbstited 00470 during a 32-second window = CALM[8:0]. */ 00471 #define IS_RTC_SMOOTH_CALIB_PLUS(PLUS) (((PLUS) == RTC_SmoothCalibPlusPulses_Set) || \ 00472 ((PLUS) == RTC_SmoothCalibPlusPulses_Reset)) 00473 00474 /** 00475 * @} 00476 */ 00477 00478 /** @defgroup RTC_Smooth_calib_Minus_pulses_Definitions 00479 * @{ 00480 */ 00481 #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= 0x000001FF) 00482 00483 /** 00484 * @} 00485 */ 00486 00487 /** @defgroup RTC_DayLightSaving_Definitions 00488 * @{ 00489 */ 00490 #define RTC_DayLightSaving_SUB1H ((uint32_t)0x00020000) 00491 #define RTC_DayLightSaving_ADD1H ((uint32_t)0x00010000) 00492 #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DayLightSaving_SUB1H) || \ 00493 ((SAVE) == RTC_DayLightSaving_ADD1H)) 00494 00495 #define RTC_StoreOperation_Reset ((uint32_t)0x00000000) 00496 #define RTC_StoreOperation_Set ((uint32_t)0x00040000) 00497 #define IS_RTC_STORE_OPERATION(OPERATION) (((OPERATION) == RTC_StoreOperation_Reset) || \ 00498 ((OPERATION) == RTC_StoreOperation_Set)) 00499 /** 00500 * @} 00501 */ 00502 00503 /** @defgroup RTC_Tamper_Trigger_Definitions 00504 * @{ 00505 */ 00506 #define RTC_TamperTrigger_RisingEdge ((uint32_t)0x00000000) 00507 #define RTC_TamperTrigger_FallingEdge ((uint32_t)0x00000001) 00508 #define RTC_TamperTrigger_LowLevel ((uint32_t)0x00000000) 00509 #define RTC_TamperTrigger_HighLevel ((uint32_t)0x00000001) 00510 #define IS_RTC_TAMPER_TRIGGER(TRIGGER) (((TRIGGER) == RTC_TamperTrigger_RisingEdge) || \ 00511 ((TRIGGER) == RTC_TamperTrigger_FallingEdge) || \ 00512 ((TRIGGER) == RTC_TamperTrigger_LowLevel) || \ 00513 ((TRIGGER) == RTC_TamperTrigger_HighLevel)) 00514 00515 /** 00516 * @} 00517 */ 00518 00519 /** @defgroup RTC_Tamper_Filter_Definitions 00520 * @{ 00521 */ 00522 #define RTC_TamperFilter_Disable ((uint32_t)0x00000000) /*!< Tamper filter is disabled */ 00523 00524 #define RTC_TamperFilter_2Sample ((uint32_t)0x00000800) /*!< Tamper is activated after 2 00525 consecutive samples at the active level */ 00526 #define RTC_TamperFilter_4Sample ((uint32_t)0x00001000) /*!< Tamper is activated after 4 00527 consecutive samples at the active level */ 00528 #define RTC_TamperFilter_8Sample ((uint32_t)0x00001800) /*!< Tamper is activated after 8 00529 consecutive samples at the active leve. */ 00530 #define IS_RTC_TAMPER_FILTER(FILTER) (((FILTER) == RTC_TamperFilter_Disable) || \ 00531 ((FILTER) == RTC_TamperFilter_2Sample) || \ 00532 ((FILTER) == RTC_TamperFilter_4Sample) || \ 00533 ((FILTER) == RTC_TamperFilter_8Sample)) 00534 /** 00535 * @} 00536 */ 00537 00538 /** @defgroup RTC_Tamper_Sampling_Frequencies_Definitions 00539 * @{ 00540 */ 00541 #define RTC_TamperSamplingFreq_RTCCLK_Div32768 ((uint32_t)0x00000000) /*!< Each of the tamper inputs are sampled 00542 with a frequency = RTCCLK / 32768 */ 00543 #define RTC_TamperSamplingFreq_RTCCLK_Div16384 ((uint32_t)0x000000100) /*!< Each of the tamper inputs are sampled 00544 with a frequency = RTCCLK / 16384 */ 00545 #define RTC_TamperSamplingFreq_RTCCLK_Div8192 ((uint32_t)0x00000200) /*!< Each of the tamper inputs are sampled 00546 with a frequency = RTCCLK / 8192 */ 00547 #define RTC_TamperSamplingFreq_RTCCLK_Div4096 ((uint32_t)0x00000300) /*!< Each of the tamper inputs are sampled 00548 with a frequency = RTCCLK / 4096 */ 00549 #define RTC_TamperSamplingFreq_RTCCLK_Div2048 ((uint32_t)0x00000400) /*!< Each of the tamper inputs are sampled 00550 with a frequency = RTCCLK / 2048 */ 00551 #define RTC_TamperSamplingFreq_RTCCLK_Div1024 ((uint32_t)0x00000500) /*!< Each of the tamper inputs are sampled 00552 with a frequency = RTCCLK / 1024 */ 00553 #define RTC_TamperSamplingFreq_RTCCLK_Div512 ((uint32_t)0x00000600) /*!< Each of the tamper inputs are sampled 00554 with a frequency = RTCCLK / 512 */ 00555 #define RTC_TamperSamplingFreq_RTCCLK_Div256 ((uint32_t)0x00000700) /*!< Each of the tamper inputs are sampled 00556 with a frequency = RTCCLK / 256 */ 00557 #define IS_RTC_TAMPER_SAMPLING_FREQ(FREQ) (((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div32768) || \ 00558 ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div16384) || \ 00559 ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div8192) || \ 00560 ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div4096) || \ 00561 ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div2048) || \ 00562 ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div1024) || \ 00563 ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div512) || \ 00564 ((FREQ) ==RTC_TamperSamplingFreq_RTCCLK_Div256)) 00565 00566 /** 00567 * @} 00568 */ 00569 00570 /** @defgroup RTC_Tamper_Pin_Precharge_Duration_Definitions 00571 * @{ 00572 */ 00573 #define RTC_TamperPrechargeDuration_1RTCCLK ((uint32_t)0x00000000) /*!< Tamper pins are pre-charged before 00574 sampling during 1 RTCCLK cycle */ 00575 #define RTC_TamperPrechargeDuration_2RTCCLK ((uint32_t)0x00002000) /*!< Tamper pins are pre-charged before 00576 sampling during 2 RTCCLK cycles */ 00577 #define RTC_TamperPrechargeDuration_4RTCCLK ((uint32_t)0x00004000) /*!< Tamper pins are pre-charged before 00578 sampling during 4 RTCCLK cycles */ 00579 #define RTC_TamperPrechargeDuration_8RTCCLK ((uint32_t)0x00006000) /*!< Tamper pins are pre-charged before 00580 sampling during 8 RTCCLK cycles */ 00581 00582 #define IS_RTC_TAMPER_PRECHARGE_DURATION(DURATION) (((DURATION) == RTC_TamperPrechargeDuration_1RTCCLK) || \ 00583 ((DURATION) == RTC_TamperPrechargeDuration_2RTCCLK) || \ 00584 ((DURATION) == RTC_TamperPrechargeDuration_4RTCCLK) || \ 00585 ((DURATION) == RTC_TamperPrechargeDuration_8RTCCLK)) 00586 /** 00587 * @} 00588 */ 00589 00590 /** @defgroup RTC_Tamper_Pins_Definitions 00591 * @{ 00592 */ 00593 #define RTC_Tamper_1 RTC_TAFCR_TAMP1E /*!< Tamper detection enable for 00594 input tamper 1 */ 00595 #define RTC_Tamper_2 RTC_TAFCR_TAMP2E /*!< Tamper detection enable for 00596 input tamper 2 */ 00597 #define RTC_Tamper_3 RTC_TAFCR_TAMP3E /*!< Tamper detection enable for 00598 input tamper 3 */ 00599 00600 #define IS_RTC_TAMPER(TAMPER) ((((TAMPER) & (uint32_t)0xFFFFFFD6) == 0x00) && ((TAMPER) != (uint32_t)RESET)) 00601 00602 00603 /** 00604 * @} 00605 */ 00606 00607 /** @defgroup RTC_Output_Type_ALARM_OUT 00608 * @{ 00609 */ 00610 #define RTC_OutputType_OpenDrain ((uint32_t)0x00000000) 00611 #define RTC_OutputType_PushPull ((uint32_t)0x00040000) 00612 #define IS_RTC_OUTPUT_TYPE(TYPE) (((TYPE) == RTC_OutputType_OpenDrain) || \ 00613 ((TYPE) == RTC_OutputType_PushPull)) 00614 00615 /** 00616 * @} 00617 */ 00618 00619 /** @defgroup RTC_Add_1_Second_Parameter_Definitions 00620 * @{ 00621 */ 00622 #define RTC_ShiftAdd1S_Reset ((uint32_t)0x00000000) 00623 #define RTC_ShiftAdd1S_Set ((uint32_t)0x80000000) 00624 #define IS_RTC_SHIFT_ADD1S(SEL) (((SEL) == RTC_ShiftAdd1S_Reset) || \ 00625 ((SEL) == RTC_ShiftAdd1S_Set)) 00626 /** 00627 * @} 00628 */ 00629 00630 /** @defgroup RTC_Substract_Fraction_Of_Second_Value 00631 * @{ 00632 */ 00633 #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= 0x00007FFF) 00634 00635 /** 00636 * @} 00637 */ 00638 00639 /** @defgroup RTC_Backup_Registers_Definitions 00640 * @{ 00641 */ 00642 00643 #define RTC_BKP_DR0 ((uint32_t)0x00000000) 00644 #define RTC_BKP_DR1 ((uint32_t)0x00000001) 00645 #define RTC_BKP_DR2 ((uint32_t)0x00000002) 00646 #define RTC_BKP_DR3 ((uint32_t)0x00000003) 00647 #define RTC_BKP_DR4 ((uint32_t)0x00000004) 00648 #define RTC_BKP_DR5 ((uint32_t)0x00000005) 00649 #define RTC_BKP_DR6 ((uint32_t)0x00000006) 00650 #define RTC_BKP_DR7 ((uint32_t)0x00000007) 00651 #define RTC_BKP_DR8 ((uint32_t)0x00000008) 00652 #define RTC_BKP_DR9 ((uint32_t)0x00000009) 00653 #define RTC_BKP_DR10 ((uint32_t)0x0000000A) 00654 #define RTC_BKP_DR11 ((uint32_t)0x0000000B) 00655 #define RTC_BKP_DR12 ((uint32_t)0x0000000C) 00656 #define RTC_BKP_DR13 ((uint32_t)0x0000000D) 00657 #define RTC_BKP_DR14 ((uint32_t)0x0000000E) 00658 #define RTC_BKP_DR15 ((uint32_t)0x0000000F) 00659 #define IS_RTC_BKP(BKP) (((BKP) == RTC_BKP_DR0) || \ 00660 ((BKP) == RTC_BKP_DR1) || \ 00661 ((BKP) == RTC_BKP_DR2) || \ 00662 ((BKP) == RTC_BKP_DR3) || \ 00663 ((BKP) == RTC_BKP_DR4) || \ 00664 ((BKP) == RTC_BKP_DR5) || \ 00665 ((BKP) == RTC_BKP_DR6) || \ 00666 ((BKP) == RTC_BKP_DR7) || \ 00667 ((BKP) == RTC_BKP_DR8) || \ 00668 ((BKP) == RTC_BKP_DR9) || \ 00669 ((BKP) == RTC_BKP_DR10) || \ 00670 ((BKP) == RTC_BKP_DR11) || \ 00671 ((BKP) == RTC_BKP_DR12) || \ 00672 ((BKP) == RTC_BKP_DR13) || \ 00673 ((BKP) == RTC_BKP_DR14) || \ 00674 ((BKP) == RTC_BKP_DR15)) 00675 /** 00676 * @} 00677 */ 00678 00679 /** @defgroup RTC_Input_parameter_format_definitions 00680 * @{ 00681 */ 00682 #define RTC_Format_BIN ((uint32_t)0x000000000) 00683 #define RTC_Format_BCD ((uint32_t)0x000000001) 00684 #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_Format_BIN) || ((FORMAT) == RTC_Format_BCD)) 00685 00686 /** 00687 * @} 00688 */ 00689 00690 /** @defgroup RTC_Flags_Definitions 00691 * @{ 00692 */ 00693 #define RTC_FLAG_RECALPF ((uint32_t)0x00010000) 00694 #define RTC_FLAG_TAMP3F ((uint32_t)0x00008000) 00695 #define RTC_FLAG_TAMP2F ((uint32_t)0x00004000) 00696 #define RTC_FLAG_TAMP1F ((uint32_t)0x00002000) 00697 #define RTC_FLAG_TSOVF ((uint32_t)0x00001000) 00698 #define RTC_FLAG_TSF ((uint32_t)0x00000800) 00699 #define RTC_FLAG_WUTF ((uint32_t)0x00000400) 00700 #define RTC_FLAG_ALRBF ((uint32_t)0x00000200) 00701 #define RTC_FLAG_ALRAF ((uint32_t)0x00000100) 00702 #define RTC_FLAG_INITF ((uint32_t)0x00000040) 00703 #define RTC_FLAG_RSF ((uint32_t)0x00000020) 00704 #define RTC_FLAG_INITS ((uint32_t)0x00000010) 00705 #define RTC_FLAG_SHPF ((uint32_t)0x00000008) 00706 #define RTC_FLAG_WUTWF ((uint32_t)0x00000004) 00707 #define RTC_FLAG_ALRBWF ((uint32_t)0x00000002) 00708 #define RTC_FLAG_ALRAWF ((uint32_t)0x00000001) 00709 #define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_TSOVF) || ((FLAG) == RTC_FLAG_TSF) || \ 00710 ((FLAG) == RTC_FLAG_WUTF) || ((FLAG) == RTC_FLAG_ALRBF) || \ 00711 ((FLAG) == RTC_FLAG_ALRAF) || ((FLAG) == RTC_FLAG_INITF) || \ 00712 ((FLAG) == RTC_FLAG_RSF) || ((FLAG) == RTC_FLAG_WUTWF) || \ 00713 ((FLAG) == RTC_FLAG_ALRBWF) || ((FLAG) == RTC_FLAG_ALRAWF) || \ 00714 ((FLAG) == RTC_FLAG_TAMP1F) || ((FLAG) == RTC_FLAG_TAMP2F) || \ 00715 ((FLAG) == RTC_FLAG_TAMP3F) || ((FLAG) == RTC_FLAG_RECALPF) || \ 00716 ((FLAG) == RTC_FLAG_SHPF)) 00717 #define IS_RTC_CLEAR_FLAG(FLAG) (((FLAG) != (uint32_t)RESET) && (((FLAG) & 0xFFFF00DF) == (uint32_t)RESET)) 00718 00719 /** 00720 * @} 00721 */ 00722 00723 /** @defgroup RTC_Interrupts_Definitions 00724 * @{ 00725 */ 00726 #define RTC_IT_TS ((uint32_t)0x00008000) 00727 #define RTC_IT_WUT ((uint32_t)0x00004000) 00728 #define RTC_IT_ALRB ((uint32_t)0x00002000) 00729 #define RTC_IT_ALRA ((uint32_t)0x00001000) 00730 #define RTC_IT_TAMP ((uint32_t)0x00000004) /* Used only to Enable the Tamper Interrupt */ 00731 #define RTC_IT_TAMP1 ((uint32_t)0x00020000) 00732 #define RTC_IT_TAMP2 ((uint32_t)0x00040000) 00733 #define RTC_IT_TAMP3 ((uint32_t)0x00080000) 00734 00735 00736 #define IS_RTC_CONFIG_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFF0FFB) == (uint32_t)RESET)) 00737 #define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_TS) || ((IT) == RTC_IT_WUT) || \ 00738 ((IT) == RTC_IT_ALRB) || ((IT) == RTC_IT_ALRA) || \ 00739 ((IT) == RTC_IT_TAMP1) || ((IT) == RTC_IT_TAMP2) || \ 00740 ((IT) == RTC_IT_TAMP3)) 00741 #define IS_RTC_CLEAR_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFF10FFF) == (uint32_t)RESET)) 00742 00743 /** 00744 * @} 00745 */ 00746 00747 /** 00748 * @} 00749 */ 00750 00751 00752 /* Exported macro ------------------------------------------------------------*/ 00753 /* Exported functions ------------------------------------------------------- */ 00754 00755 /* Function used to set the RTC configuration to the default reset state *****/ 00756 ErrorStatus RTC_DeInit(void); 00757 00758 00759 /* Initialization and Configuration functions *********************************/ 00760 ErrorStatus RTC_Init(RTC_InitTypeDef* RTC_InitStruct); 00761 void RTC_StructInit(RTC_InitTypeDef* RTC_InitStruct); 00762 void RTC_WriteProtectionCmd(FunctionalState NewState); 00763 ErrorStatus RTC_EnterInitMode(void); 00764 void RTC_ExitInitMode(void); 00765 ErrorStatus RTC_WaitForSynchro(void); 00766 ErrorStatus RTC_RefClockCmd(FunctionalState NewState); 00767 void RTC_BypassShadowCmd(FunctionalState NewState); 00768 00769 /* Time and Date configuration functions **************************************/ 00770 ErrorStatus RTC_SetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct); 00771 void RTC_TimeStructInit(RTC_TimeTypeDef* RTC_TimeStruct); 00772 void RTC_GetTime(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct); 00773 uint32_t RTC_GetSubSecond(void); 00774 ErrorStatus RTC_SetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct); 00775 void RTC_DateStructInit(RTC_DateTypeDef* RTC_DateStruct); 00776 void RTC_GetDate(uint32_t RTC_Format, RTC_DateTypeDef* RTC_DateStruct); 00777 00778 /* Alarms (Alarm A and Alarm B) configuration functions **********************/ 00779 void RTC_SetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct); 00780 void RTC_AlarmStructInit(RTC_AlarmTypeDef* RTC_AlarmStruct); 00781 void RTC_GetAlarm(uint32_t RTC_Format, uint32_t RTC_Alarm, RTC_AlarmTypeDef* RTC_AlarmStruct); 00782 ErrorStatus RTC_AlarmCmd(uint32_t RTC_Alarm, FunctionalState NewState); 00783 void RTC_AlarmSubSecondConfig(uint32_t RTC_Alarm, uint32_t RTC_AlarmSubSecondValue, uint32_t RTC_AlarmSubSecondMask); 00784 uint32_t RTC_GetAlarmSubSecond(uint32_t RTC_Alarm); 00785 00786 /* WakeUp Timer configuration functions ***************************************/ 00787 void RTC_WakeUpClockConfig(uint32_t RTC_WakeUpClock); 00788 void RTC_SetWakeUpCounter(uint32_t RTC_WakeUpCounter); 00789 uint32_t RTC_GetWakeUpCounter(void); 00790 ErrorStatus RTC_WakeUpCmd(FunctionalState NewState); 00791 00792 /* Daylight Saving configuration functions ************************************/ 00793 void RTC_DayLightSavingConfig(uint32_t RTC_DayLightSaving, uint32_t RTC_StoreOperation); 00794 uint32_t RTC_GetStoreOperation(void); 00795 00796 /* Output pin Configuration function ******************************************/ 00797 void RTC_OutputConfig(uint32_t RTC_Output, uint32_t RTC_OutputPolarity); 00798 00799 /* Digital Calibration configuration functions ********************************/ 00800 void RTC_CalibOutputCmd(FunctionalState NewState); 00801 void RTC_CalibOutputConfig(uint32_t RTC_CalibOutput); 00802 ErrorStatus RTC_SmoothCalibConfig(uint32_t RTC_SmoothCalibPeriod, 00803 uint32_t RTC_SmoothCalibPlusPulses, 00804 uint32_t RTC_SmouthCalibMinusPulsesValue); 00805 00806 /* TimeStamp configuration functions ******************************************/ 00807 void RTC_TimeStampCmd(uint32_t RTC_TimeStampEdge, FunctionalState NewState); 00808 void RTC_GetTimeStamp(uint32_t RTC_Format, RTC_TimeTypeDef* RTC_StampTimeStruct, 00809 RTC_DateTypeDef* RTC_StampDateStruct); 00810 uint32_t RTC_GetTimeStampSubSecond(void); 00811 00812 /* Tampers configuration functions ********************************************/ 00813 void RTC_TamperTriggerConfig(uint32_t RTC_Tamper, uint32_t RTC_TamperTrigger); 00814 void RTC_TamperCmd(uint32_t RTC_Tamper, FunctionalState NewState); 00815 void RTC_TamperFilterConfig(uint32_t RTC_TamperFilter); 00816 void RTC_TamperSamplingFreqConfig(uint32_t RTC_TamperSamplingFreq); 00817 void RTC_TamperPinsPrechargeDuration(uint32_t RTC_TamperPrechargeDuration); 00818 void RTC_TimeStampOnTamperDetectionCmd(FunctionalState NewState); 00819 void RTC_TamperPullUpCmd(FunctionalState NewState); 00820 00821 /* Backup Data Registers configuration functions ******************************/ 00822 void RTC_WriteBackupRegister(uint32_t RTC_BKP_DR, uint32_t Data); 00823 uint32_t RTC_ReadBackupRegister(uint32_t RTC_BKP_DR); 00824 00825 /* Output Type Config configuration functions *********************************/ 00826 void RTC_OutputTypeConfig(uint32_t RTC_OutputType); 00827 00828 /* RTC_Shift_control_synchonisation_functions *********************************/ 00829 ErrorStatus RTC_SynchroShiftConfig(uint32_t RTC_ShiftAdd1S, uint32_t RTC_ShiftSubFS); 00830 00831 /* Interrupts and flags management functions **********************************/ 00832 void RTC_ITConfig(uint32_t RTC_IT, FunctionalState NewState); 00833 FlagStatus RTC_GetFlagStatus(uint32_t RTC_FLAG); 00834 void RTC_ClearFlag(uint32_t RTC_FLAG); 00835 ITStatus RTC_GetITStatus(uint32_t RTC_IT); 00836 void RTC_ClearITPendingBit(uint32_t RTC_IT); 00837 00838 #ifdef __cplusplus 00839 } 00840 #endif 00841 00842 #endif /*__STM32F30x_RTC_H */ 00843 00844 /** 00845 * @} 00846 */ 00847 00848 /** 00849 * @} 00850 */ 00851 00852 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 17:34:44 by
