STM8L15x Standard Peripherals Drivers
|
stm8l15x_rtc.h
Go to the documentation of this file.
00001 /** 00002 ****************************************************************************** 00003 * @file stm8l15x_rtc.h 00004 * @author MCD Application Team 00005 * @version V1.5.0 00006 * @date 13-May-2011 00007 * @brief This file contains all the functions prototypes for the RTC 00008 * firmware library. 00009 ****************************************************************************** 00010 * @attention 00011 * 00012 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 00013 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 00014 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 00015 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 00016 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 00017 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 00018 * 00019 * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2> 00020 ****************************************************************************** 00021 */ 00022 /* Define to prevent recursive inclusion -------------------------------------*/ 00023 #ifndef __STM8L15x_RTC_H 00024 #define __STM8L15x_RTC_H 00025 00026 /* Includes ------------------------------------------------------------------*/ 00027 #include "stm8l15x.h" 00028 00029 /** @addtogroup STM8L15x_StdPeriph_Driver 00030 * @{ 00031 */ 00032 00033 /** @addtogroup RTC 00034 * @{ 00035 */ 00036 00037 /* Exported types ------------------------------------------------------------*/ 00038 /** @defgroup RTC_Exported_Types 00039 * @{ 00040 */ 00041 00042 /** @defgroup RTC_Weekdays 00043 * @{ 00044 */ 00045 typedef enum 00046 { 00047 RTC_Weekday_Monday = ((uint8_t)0x01), /*!< WeekDay is Monday */ 00048 RTC_Weekday_Tuesday = ((uint8_t)0x02), /*!< WeekDay is Tuesday */ 00049 RTC_Weekday_Wednesday = ((uint8_t)0x03), /*!< WeekDay is Wednesday */ 00050 RTC_Weekday_Thursday = ((uint8_t)0x04), /*!< WeekDay is Thursday */ 00051 RTC_Weekday_Friday = ((uint8_t)0x05), /*!< WeekDay is Friday */ 00052 RTC_Weekday_Saturday = ((uint8_t)0x06), /*!< WeekDay is Saturday */ 00053 RTC_Weekday_Sunday = ((uint8_t)0x07) /*!< WeekDay is Sunday */ 00054 } 00055 RTC_Weekday_TypeDef; 00056 00057 /** 00058 * @} 00059 */ 00060 00061 /** @defgroup RTC_Months 00062 * @{ 00063 */ 00064 typedef enum 00065 { 00066 RTC_Month_January = ((uint8_t)0x01), /*!< Month is January */ 00067 RTC_Month_February = ((uint8_t)0x02), /*!< Month is February */ 00068 RTC_Month_March = ((uint8_t)0x03), /*!< Month is March */ 00069 RTC_Month_April = ((uint8_t)0x04), /*!< Month is April */ 00070 RTC_Month_May = ((uint8_t)0x05), /*!< Month is May */ 00071 RTC_Month_June = ((uint8_t)0x06), /*!< Month is June */ 00072 RTC_Month_July = ((uint8_t)0x07), /*!< Month is July */ 00073 RTC_Month_August = ((uint8_t)0x08), /*!< Month is August */ 00074 RTC_Month_September = ((uint8_t)0x09), /*!< Month is September */ 00075 RTC_Month_October = ((uint8_t)0x10), /*!< Month is October */ 00076 RTC_Month_November = ((uint8_t)0x11), /*!< Month is November */ 00077 RTC_Month_December = ((uint8_t)0x12) /*!< Month is December */ 00078 } 00079 RTC_Month_TypeDef; 00080 00081 /** 00082 * @} 00083 */ 00084 00085 /** @defgroup RTC_Hour_Format 00086 * @{ 00087 */ 00088 typedef enum 00089 { 00090 RTC_HourFormat_24 = ((uint8_t)0x00), /*!< Hour Format is 24H */ 00091 RTC_HourFormat_12 = ((uint8_t)0x40) /*!< Hour Format is 12H (using AM/PM) */ 00092 } 00093 RTC_HourFormat_TypeDef; 00094 00095 /** 00096 * @} 00097 */ 00098 00099 /** @defgroup RTC_Time 00100 * @{ 00101 */ 00102 typedef enum 00103 { 00104 RTC_H12_AM = ((uint8_t)0x00), /*!< AM/PM notation is AM or 24 hour format */ 00105 RTC_H12_PM = ((uint8_t)0x40) /*!< AM/PM notation is PM */ 00106 } 00107 RTC_H12_TypeDef; 00108 00109 /** 00110 * @} 00111 */ 00112 00113 /** @defgroup RTC_Alarm_WeekDay_Selection 00114 * @{ 00115 */ 00116 typedef enum 00117 { 00118 RTC_AlarmDateWeekDaySel_Date = ((uint8_t)0x00), /*!< Date/WeekDay selection is Date */ 00119 RTC_AlarmDateWeekDaySel_WeekDay = ((uint8_t)0x40) /*!< Date/WeekDay selection is WeekDay */ 00120 } 00121 RTC_AlarmDateWeekDaySel_TypeDef; 00122 00123 /** 00124 * @} 00125 */ 00126 00127 /** @defgroup RTC_Alarm_Mask 00128 * @{ 00129 */ 00130 typedef enum 00131 { 00132 RTC_AlarmMask_None = ((uint8_t)0x00), /*!< Alarm Masks disabled */ 00133 RTC_AlarmMask_Seconds = ((uint8_t)0x80), /*!< Alarm Seconds Mask */ 00134 RTC_AlarmMask_Minutes = ((uint8_t)0x40), /*!< Alarm Minutes Mask */ 00135 RTC_AlarmMask_Hours = ((uint8_t)0x20), /*!< Alarm Hours Mask */ 00136 RTC_AlarmMask_DateWeekDay = ((uint8_t)0x10), /*!< Alarm Date/WeekDay Mask */ 00137 RTC_AlarmMask_All = ((uint8_t)0xF0) /*!< Alarm All Mask are enabled */ 00138 } 00139 RTC_AlarmMask_TypeDef; 00140 00141 /** 00142 * @} 00143 */ 00144 00145 /** @defgroup RTC_Sub_Second_Alarm_Mask 00146 * @{ 00147 */ 00148 typedef enum 00149 { 00150 RTC_AlarmSubSecondMask_All = ((uint8_t)0x00), /*!< All Alarm SS fields are masked. There is no comparison on sub seconds for Alarm */ 00151 RTC_AlarmSubSecondMask_None = ((uint8_t)0x0F), /*!< SS[14:0] are compared and must match to activate alarm. */ 00152 RTC_AlarmSubSecondMask_SS14_1 = ((uint8_t)0x01), /*!< SS[14:1] are not used in Alarm comparison. Only SS[0] is compared. */ 00153 RTC_AlarmSubSecondMask_SS14_2 = ((uint8_t)0x02), /*!< SS[14:2] are not used in Alarm comparison. Only SS[1:0] are compared */ 00154 RTC_AlarmSubSecondMask_SS14_3 = ((uint8_t)0x03), /*!< SS[14:3] are not used in Alarm comparison. Only SS[1:0] are compared */ 00155 RTC_AlarmSubSecondMask_SS14_4 = ((uint8_t)0x04), /*!< SS[14:4] are not used in Alarm comparison. Only SS[1:0] are compared */ 00156 RTC_AlarmSubSecondMask_SS14_5 = ((uint8_t)0x05), /*!< SS[14:5] are not used in Alarm comparison. Only SS[1:0] are compared */ 00157 RTC_AlarmSubSecondMask_SS14_6 = ((uint8_t)0x06), /*!< SS[14:6] are not used in Alarm comparison. Only SS[1:0] are compared */ 00158 RTC_AlarmSubSecondMask_SS14_7 = ((uint8_t)0x07), /*!< SS[14:7] are not used in Alarm comparison. Only SS[1:0] are compared */ 00159 RTC_AlarmSubSecondMask_SS14_8 = ((uint8_t)0x08), /*!< SS[14:8] are not used in Alarm comparison. Only SS[1:0] are compared */ 00160 RTC_AlarmSubSecondMask_SS14_9 = ((uint8_t)0x09), /*!< SS[14:9] are not used in Alarm comparison. Only SS[1:0] are compared */ 00161 RTC_AlarmSubSecondMask_SS14_10 = ((uint8_t)0x0A), /*!< SS[14:10] are not used in Alarm comparison. Only SS[1:0] are compared */ 00162 RTC_AlarmSubSecondMask_SS14_11 = ((uint8_t)0x0B), /*!< SS[14:11] are not used in Alarm comparison. Only SS[1:0] are compared */ 00163 RTC_AlarmSubSecondMask_SS14_12 = ((uint8_t)0x0C), /*!< SS[14:12] are not used in Alarm comparison. Only SS[1:0] are compared */ 00164 RTC_AlarmSubSecondMask_SS14_13 = ((uint8_t)0x0D), /*!< SS[14:13] are not used in Alarm comparison. Only SS[1:0] are compared */ 00165 RTC_AlarmSubSecondMask_SS14 = ((uint8_t)0x0E) /*!< SS[14] is not used in Alarm comparison. Only SS[13:0] are compared */ 00166 } 00167 RTC_AlarmSubSecondMask_TypeDef; 00168 00169 /** 00170 * @} 00171 */ 00172 00173 /** @defgroup RTC_Wakeup_Clock 00174 * @{ 00175 */ 00176 typedef enum 00177 { 00178 RTC_WakeUpClock_RTCCLK_Div16 = ((uint8_t)0x00), /*!< (RTC clock) div 16*/ 00179 RTC_WakeUpClock_RTCCLK_Div8 = ((uint8_t)0x01), /*!< (RTC clock) div 8*/ 00180 RTC_WakeUpClock_RTCCLK_Div4 = ((uint8_t)0x02), /*!< (RTC clock) div 4*/ 00181 RTC_WakeUpClock_RTCCLK_Div2 = ((uint8_t)0x03), /*!< (RTC clock) div 2*/ 00182 RTC_WakeUpClock_CK_SPRE_16bits = ((uint8_t)0x04), /*!< CK SPRE with a counter from 0x0000 to 0xFFFF */ 00183 RTC_WakeUpClock_CK_SPRE_17bits = ((uint8_t)0x06) /*!< CK SPRE with a counter from 0x10000 to 0x1FFFF */ 00184 } 00185 RTC_WakeUpClock_TypeDef; 00186 00187 /** 00188 * @} 00189 */ 00190 00191 /** @defgroup RTC_Output_Selection 00192 * @{ 00193 */ 00194 typedef enum 00195 { 00196 RTC_Output_Disable = ((uint8_t)0x00), /*!< RTC Alternate function Output is disabled */ 00197 RTC_Output_Alarm = ((uint8_t)0x20), /*!< RTC Alternate function Output is the Alarm A event*/ 00198 RTC_Output_WakeUp = ((uint8_t)0x60) /*!< RTC Alternate function Output is the WakeUp event */ 00199 } 00200 RTC_Output_TypeDef; 00201 00202 /** 00203 * @} 00204 */ 00205 00206 /** @defgroup RTC_Output_Polarity 00207 * @{ 00208 */ 00209 typedef enum 00210 { 00211 RTC_OutputPolarity_High = ((uint8_t)0x00), /*!< RTC Alternate function Output Polarity is High */ 00212 RTC_OutputPolarity_Low = ((uint8_t)0x10) /*!< RTC Alternate function Output Polarity is Low */ 00213 } 00214 RTC_OutputPolarity_TypeDef; 00215 00216 /** 00217 * @} 00218 */ 00219 00220 /** @defgroup RTC_Calibration_Output 00221 * @{ 00222 */ 00223 typedef enum 00224 { 00225 RTC_CalibOutput_512Hz = ((uint8_t)0x00), /*!< RTC Calibration Output is 512Hz */ 00226 RTC_CalibOutput_1Hz = ((uint8_t)0x80) /*!< RTC Calibration Output is 1Hz */ 00227 } 00228 RTC_CalibOutput_TypeDef; 00229 00230 /** 00231 * @} 00232 */ 00233 00234 /** @defgroup RTC_DayLight_Saving 00235 * @{ 00236 */ 00237 typedef enum 00238 { 00239 RTC_DayLightSaving_SUB1H = ((uint8_t)0x02), /*!< Substract 1 hour to the current Time (Winter Time Adjustment) */ 00240 RTC_DayLightSaving_ADD1H = ((uint8_t)0x01) /*!< Add 1 hour to the current Time (Summer Time Adjustment) */ 00241 } 00242 RTC_DayLightSaving_TypeDef; 00243 00244 /** 00245 * @} 00246 */ 00247 00248 /** @defgroup RTC_Store_Operation 00249 * @{ 00250 */ 00251 typedef enum 00252 { 00253 RTC_StoreOperation_Set = ((uint8_t)0x04), /*!< Store Operation Set */ 00254 RTC_StoreOperation_Reset = ((uint8_t)0x00) /*!< Store Operation Reset */ 00255 } 00256 RTC_StoreOperation_TypeDef; 00257 00258 /** 00259 * @} 00260 */ 00261 00262 /** @defgroup RTC_Input_Parameter_Format 00263 * @{ 00264 */ 00265 typedef enum 00266 { 00267 RTC_Format_BIN = ((uint8_t)0x00), /*!< Binary Format is used */ 00268 RTC_Format_BCD = ((uint8_t)0x01) /*!< BCD Format is used */ 00269 } 00270 RTC_Format_TypeDef; 00271 00272 /** 00273 * @} 00274 */ 00275 00276 /** @defgroup RTC_Flags 00277 * @{ 00278 */ 00279 typedef enum 00280 { 00281 RTC_FLAG_TAMP3F = ((uint16_t)0x0080), /*!< TAMPER3 detection Flag. If set, tamper detection event is detected on tamper input 3 */ 00282 RTC_FLAG_TAMP2F = ((uint16_t)0x0040), /*!< TAMPER2 detection Flag. If set, tamper detection event is detected on tamper input 2 */ 00283 RTC_FLAG_TAMP1F = ((uint16_t)0x0020), /*!< TAMPER1 detection Flag. If set, tamper detection event is detected on tamper input 1 */ 00284 00285 RTC_FLAG_WUTF = ((uint16_t)0x0004), /*!< Wake up Timer Flag. If set, the Wake Up down counter reaches 0 */ 00286 RTC_FLAG_ALRAF = ((uint16_t)0x0001), /*!< Alarm A Flag. If set, the Time/Date registers matches Alarm A registers */ 00287 00288 RTC_FLAG_INITF = ((uint16_t)0x4000), /*!< Initialisation Flag. If set,Calender registers has been initialized */ 00289 RTC_FLAG_RSF = ((uint16_t)0x2000), /*!< Registers Synchronization Flag. If set,Calender registers synchronized */ 00290 RTC_FLAG_INITS = ((uint16_t)0x1000), /*!< Initialisation Status Flag. If set,Calender update is allowed */ 00291 00292 RTC_FLAG_SHPF = ((uint16_t)0x0800), /*!< Shift operation pending Flag. This flag is set by hardware as soon as a shift operation is 00293 initiated by a write to the RTC_SHIFTRL. It is cleared by hardware as soon as the corresponding 00294 shift operation has completed. */ 00295 00296 RTC_FLAG_WUTWF = ((uint16_t)0x0400), /*!< Wake up Timer write Flag. If set, Wake up Timer update is allowed */ 00297 RTC_FLAG_RECALPF = ((uint16_t)0x0200), /*!< Recalibration pending Flag, The status flag RECALPF is automatically set to �1� when software 00298 writes to the register RTC_CALRL, indicating that the RTC_CALRx registers are blocked. 00299 When the new calibration settings are taken into account, this Flag returns by hardware to �0�. */ 00300 RTC_FLAG_ALRAWF = ((uint16_t)0x0100) /*!< Alarm A write Flag. If set, Alarm A update is allowed */ 00301 } 00302 RTC_Flag_TypeDef; 00303 00304 /** 00305 * @} 00306 */ 00307 00308 /** @defgroup RTC_Interrupts 00309 * @{ 00310 */ 00311 typedef enum 00312 { 00313 RTC_IT_WUT = ((uint16_t)0x0040), /*!< Wake up Timer Interrupt */ 00314 RTC_IT_ALRA = ((uint16_t)0x0010), /*!< Alarm A Interrupt */ 00315 RTC_IT_TAMP = ((uint16_t)0x0F01) /*!< Tamper Interrupt */ 00316 } 00317 RTC_IT_TypeDef; 00318 00319 /** 00320 * @} 00321 */ 00322 00323 /** @defgroup RTC_Tamper_Level 00324 * @{ 00325 */ 00326 typedef enum 00327 { 00328 RTC_TamperLevel_Low = ((uint8_t)0x00), /*!< Tamper staying low triggers a tamper detection event. */ 00329 RTC_TamperLevel_High = ((uint8_t)0x54) /*!< Tamper staying high triggers a tamper detection event. */ 00330 } 00331 RTC_TamperLevel_TypeDef; 00332 00333 /** 00334 * @} 00335 */ 00336 00337 /** @defgroup RTC_Tamper_State 00338 * @{ 00339 */ 00340 typedef enum 00341 { 00342 RTC_TamperState_Disable = ((uint8_t)0x00), /*!< Tamper State is Disable */ 00343 RTC_TamperState_Enable = ((uint8_t)0x01) /*!< Tamper State is Enable */ 00344 } 00345 RTC_TamperState_TypeDef; 00346 00347 /** 00348 * @} 00349 */ 00350 00351 /** @defgroup RTC_Tamper_definition 00352 * @{ 00353 */ 00354 typedef enum 00355 { 00356 RTC_Tamper_1 = ((uint8_t)0x02), /*!< Tamper 1 selection */ 00357 RTC_Tamper_2 = ((uint8_t)0x08), /*!< Tamper 2 selection */ 00358 RTC_Tamper_3 = ((uint8_t)0x20) /*!< Tamper 3 selection */ 00359 } 00360 RTC_Tamper_TypeDef; 00361 00362 /** 00363 * @} 00364 */ 00365 00366 /** @defgroup RTC_Tamper_Precharge_Duration 00367 * @{ 00368 */ 00369 typedef enum 00370 { 00371 RTC_TamperPrechargeDuration_None = ((uint8_t)0x80), /*!< Tamper pins are not precharged before sampling */ 00372 RTC_TamperPrechargeDuration_1RTCCLK = ((uint8_t)0x00), /*!< Tamper pins are precharged before sampling during 1 RTCCLK cycle */ 00373 RTC_TamperPrechargeDuration_2RTCCLK = ((uint8_t)0x20), /*!< Tamper pins are precharged before sampling during 2 RTCCLK cycles */ 00374 RTC_TamperPrechargeDuration_4RTCCLK = ((uint8_t)0x40), /*!< Tamper pins are precharged before sampling during 4 RTCCLK cycles */ 00375 RTC_TamperPrechargeDuration_8RTCCLK = ((uint8_t)0x60) /*!< Tamper pins are precharged before sampling during 8 RTCCLK cycles */ 00376 } 00377 RTC_TamperPrechargeDuration_TypeDef; 00378 00379 /** 00380 * @} 00381 */ 00382 00383 /** @defgroup RTC_Tamper_Filter 00384 * @{ 00385 */ 00386 typedef enum 00387 { 00388 RTC_TamperFilter_1Sample = ((uint8_t)0x00), /*!< Tamper is activated after 1 sample at the active level */ 00389 RTC_TamperFilter_2Sample = ((uint8_t)0x08), /*!< Tamper is activated after 2 consecutive samples at the active level. */ 00390 RTC_TamperFilter_4Sample = ((uint8_t)0x10), /*!< Tamper is activated after 4 consecutive samples at the active level. */ 00391 RTC_TamperFilter_8Sample = ((uint8_t)0x18) /*!< Tamper is activated after 8 consecutive samples at the active level. */ 00392 } 00393 RTC_TamperFilter_TypeDef; 00394 00395 /** 00396 * @} 00397 */ 00398 00399 /** @defgroup RTC_Tamper_Sampling_Frequency 00400 * @{ 00401 */ 00402 typedef enum 00403 { 00404 RTC_TamperSamplingFreq_RTCCLK_Div32768 = ((uint8_t)0x00), /*!< Tamper inputs are sampled with a frequency = RTCCLK / 32768 */ 00405 RTC_TamperSamplingFreq_RTCCLK_Div16384 = ((uint8_t)0x01), /*!< Tamper inputs are sampled with a frequency = RTCCLK / 16384 */ 00406 RTC_TamperSamplingFreq_RTCCLK_Div8192 = ((uint8_t)0x02), /*!< Tamper inputs are sampled with a frequency = RTCCLK / 8192 */ 00407 RTC_TamperSamplingFreq_RTCCLK_Div4096 = ((uint8_t)0x03), /*!< Tamper inputs are sampled with a frequency = RTCCLK / 4096 */ 00408 RTC_TamperSamplingFreq_RTCCLK_Div2048 = ((uint8_t)0x04), /*!< Tamper inputs are sampled with a frequency = RTCCLK / 2048 */ 00409 RTC_TamperSamplingFreq_RTCCLK_Div1024 = ((uint8_t)0x05), /*!< Tamper inputs are sampled with a frequency = RTCCLK / 1024 */ 00410 RTC_TamperSamplingFreq_RTCCLK_Div512 = ((uint8_t)0x06), /*!< Tamper inputs are sampled with a frequency = RTCCLK / 512 */ 00411 RTC_TamperSamplingFreq_RTCCLK_Div256 = ((uint8_t)0x07) /*!< Tamper inputs are sampled with a frequency = RTCCLK / 256 */ 00412 } 00413 RTC_TamperSamplingFreq_TypeDef; 00414 00415 /** 00416 * @} 00417 */ 00418 00419 /** @defgroup RTC_Shift_Add_1s 00420 * @{ 00421 */ 00422 typedef enum 00423 { 00424 RTC_ShiftAdd1S_Set = ((uint8_t)0x80), /*!< Add 1 Second */ 00425 RTC_ShiftAdd1S_Reset = ((uint8_t)0x00) /*!< Do not Add 1 Second */ 00426 } 00427 RTC_ShiftAdd1S_TypeDef; 00428 00429 /** 00430 * @} 00431 */ 00432 00433 /** @defgroup RTC_Smooth_Calibration_Period 00434 * @{ 00435 */ 00436 typedef enum 00437 { 00438 RTC_SmoothCalibPeriod_32sec = ((uint8_t)0x00), /*!< if RTCCLK = 32768 Hz, Smooth calibration period is 32s, else 2exp20 RTCCLK seconds */ 00439 RTC_SmoothCalibPeriod_16sec = ((uint8_t)0x20), /*!< if RTCCLK = 32768 Hz, Smooth calibration period is 16s, else 2exp19 RTCCLK seconds */ 00440 RTC_SmoothCalibPeriod_8sec = ((uint8_t)0x40) /*!< if RTCCLK = 32768 Hz, Smooth calibration period is 8s, else 2exp18 RTCCLK seconds */ 00441 } 00442 RTC_SmoothCalibPeriod_TypeDef; 00443 00444 /** 00445 * @} 00446 */ 00447 00448 /** @defgroup RTC_Smooth_Calibration_Pulses 00449 * @{ 00450 */ 00451 typedef enum 00452 { 00453 RTC_SmoothCalibPlusPulses_Set = ((uint8_t)0x80), /*!< The number of RTCCLK pulses added during a X -second window = Y - CALM[8:0]. 00454 with Y = 512, 256, 128 when X = 32, 16, 8 */ 00455 RTC_SmoothCalibPlusPulses_Reset = ((uint8_t)0x00) /*!< The number of RTCCLK pulses substituted during a 32-second window = CALM[8:0]. */ 00456 00457 } 00458 RTC_SmoothCalibPlusPulses_TypeDef; 00459 00460 /** 00461 * @} 00462 */ 00463 00464 /** 00465 * @brief RTC Init structure definition 00466 */ 00467 00468 typedef struct 00469 { 00470 00471 RTC_HourFormat_TypeDef RTC_HourFormat; /*!< RTC Hour Format */ 00472 00473 uint8_t RTC_AsynchPrediv; /*!< RTC Asynchronous Predivider. 00474 This parameter can be any value from 00475 0x00 to 0x7F.*/ 00476 00477 uint16_t RTC_SynchPrediv; /*!< RTC Synchronous Predivider. 00478 This parameter can be any value from 00479 0x0000 to 0x7FFF.*/ 00480 } 00481 RTC_InitTypeDef; 00482 00483 00484 /** 00485 * @brief RTC Time structure definition 00486 */ 00487 typedef struct 00488 { 00489 uint8_t RTC_Hours; /*!< RTC Hours. 00490 If Binary format is selected : 00491 - If RTC_Hour format is RTC_Hour format_12, 00492 this parameter can be any value from 1 to 12. 00493 - If RTC_Hour format is RTC_Hour format_24, 00494 this parameter can be any value from 0 to 23. 00495 If BCD format is selected : 00496 - If RTC_Hour format is RTC_Hour format_12, 00497 this parameter can be any BCD value from 00498 0x01 to 0x12. 00499 - If RTC_Hour format is RTC_Hour format_24, 00500 this parameter can be any BCD value from 00501 0x00 to 0x23.*/ 00502 uint8_t RTC_Minutes; /*!< RTC Minutes. 00503 If Binary format is selected, this parameter can 00504 be any value from 0 to 59. 00505 If BCD format is selected, this parameter can 00506 be any BCD value from 0x00 to 0x59.*/ 00507 uint8_t RTC_Seconds; /*!< RTC Seconds. 00508 If Binary format is selected, this parameter can 00509 be any value from 0 to 59. 00510 If BCD format is selected, this parameter can 00511 be any BCD value from 0x00 to 0x59.*/ 00512 RTC_H12_TypeDef RTC_H12; /*!< RTC 12-hour clock period (AM/PM) */ 00513 } 00514 RTC_TimeTypeDef; 00515 00516 /** 00517 * @brief RTC Date structure definition 00518 */ 00519 typedef struct 00520 { 00521 RTC_Weekday_TypeDef RTC_WeekDay; /*!< The RTC Calender Weekday. */ 00522 00523 RTC_Month_TypeDef RTC_Month; /*!< The RTC Calender Month. */ 00524 00525 uint8_t RTC_Date; /*!< The RTC Calender Date. 00526 If Binary format is selected, this 00527 parameter can be any value from 1 to 31. 00528 If BCD format is selected, this parameter 00529 can be any BCD value from 0x01 to 0x31.*/ 00530 00531 uint8_t RTC_Year; /*!< The RTC Calender Date. 00532 If Binary format is selected, this parameter 00533 can be any value from 0 to 99. 00534 If BCD format is selected, this parameter 00535 can be any BCD value from 0x00 to 0x99.*/ 00536 } 00537 RTC_DateTypeDef; 00538 00539 /** 00540 * @brief RTC Alarm structure definition 00541 */ 00542 typedef struct 00543 { 00544 RTC_TimeTypeDef RTC_AlarmTime; /*!< RTC Alarm Time */ 00545 00546 uint8_t RTC_AlarmMask; /*!< The RTC Alarm Fields Masks. */ 00547 00548 RTC_AlarmDateWeekDaySel_TypeDef RTC_AlarmDateWeekDaySel; /*!< The RTC Alarm Date/WeekDay selection. */ 00549 00550 uint8_t RTC_AlarmDateWeekDay; /*!< The RTC Alarm Date/WeekDay value. 00551 - If RTC Alarm Date/WeekDay selection is Date 00552 and if If Binary format is selected, this 00553 parameter can be any value from 1 to 31. 00554 - If RTC Alarm Date/WeekDay selection is WeekDay, 00555 this parameter can be one of the 00556 @ref RTC_Weekday_TypeDef enumeration.*/ 00557 } 00558 RTC_AlarmTypeDef; 00559 /** 00560 * @} 00561 */ 00562 /* Exported constants --------------------------------------------------------*/ 00563 /* Exported macros -----------------------------------------------------------*/ 00564 /** @defgroup RTC_Exported_Macros 00565 * @{ 00566 */ 00567 00568 /** 00569 * @brief Macro used by the assert_param function in order to check the used 00570 * Calender Hour format 00571 */ 00572 00573 #define IS_RTC_HOUR_FORMAT(FORMAT) (((FORMAT) == RTC_HourFormat_12) || \ 00574 ((FORMAT) == RTC_HourFormat_24)) 00575 00576 /** 00577 * @brief Macro used by the assert_param function in order to check the used 00578 * Asynchronous Predivider 00579 */ 00580 #define IS_RTC_ASYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7F) 00581 00582 /** 00583 * @brief Macro used by the assert_param function in order to check the used 00584 * Synchronous Predivider 00585 */ 00586 #define IS_RTC_SYNCH_PREDIV(PREDIV) ((PREDIV) <= 0x7FFF) 00587 00588 /** 00589 * @brief Macro used by the assert_param function in order to check the used 00590 * Calender Hours value (format 12h) 00591 */ 00592 #define IS_RTC_HOUR12_MAX(HOUR) ((HOUR) <= (uint8_t)12) 00593 #define IS_RTC_HOUR12_MIN(HOUR) ((HOUR) > (uint8_t)0) 00594 00595 /** 00596 * @brief Macro used by the assert_param function in order to check the used 00597 * Calender Hours value (format 24h) 00598 */ 00599 #define IS_RTC_HOUR24(HOUR) ((HOUR) <= 23) 00600 00601 /** 00602 * @brief Macro used by the assert_param function in order to check the used 00603 * Calender minutes value 00604 */ 00605 #define IS_RTC_MINUTES(MINUTES) ((MINUTES) <= 59) 00606 00607 /** 00608 * @brief Macro used by the assert_param function in order to check the used 00609 * Calender seconds value 00610 */ 00611 #define IS_RTC_SECONDS(SECONDS) ((SECONDS) <= 59) 00612 00613 /** 00614 * @brief Macro used by the assert_param function in order to check the used 00615 * Calender H12 mode 00616 */ 00617 #define IS_RTC_H12(PM) (((PM) == (RTC_H12_AM)) || ((PM) == (RTC_H12_PM))) 00618 00619 00620 /** 00621 * @brief Macro used by the assert_param function in order to check the used 00622 * Calender Year value 00623 */ 00624 #define IS_RTC_YEAR(YEAR) ((YEAR) <= 99) 00625 00626 /** 00627 * @brief Macro used by the assert_param function in order to check the used 00628 * Calender month value 00629 */ 00630 #define IS_RTC_MONTH_MAX(MONTH) ((MONTH) <= (uint8_t)12) 00631 #define IS_RTC_MONTH_MIN(MONTH) ((MONTH) >= (uint8_t)1) 00632 00633 /** 00634 * @brief Macro used by the assert_param function in order to check the used 00635 * Calender Date value 00636 */ 00637 #define IS_RTC_DATE_MAX(DATE) ((DATE) <= (uint8_t)31) 00638 #define IS_RTC_DATE_MIN(DATE) ((DATE) >= (uint8_t)1) 00639 00640 /** 00641 * @brief Macro used by the assert_param function in order to check the used 00642 * Calender Week day value 00643 */ 00644 #define IS_RTC_WEEKDAY(WEEKDAY) (((WEEKDAY) == RTC_Weekday_Monday) || \ 00645 ((WEEKDAY) == RTC_Weekday_Tuesday) || \ 00646 ((WEEKDAY) == RTC_Weekday_Wednesday) || \ 00647 ((WEEKDAY) == RTC_Weekday_Thursday) || \ 00648 ((WEEKDAY) == RTC_Weekday_Friday) || \ 00649 ((WEEKDAY) == RTC_Weekday_Saturday) || \ 00650 ((WEEKDAY) == RTC_Weekday_Sunday)) 00651 00652 /** 00653 * @brief Macro used by the assert_param function in order to check the used 00654 * Alarm Date/week day selection 00655 */ 00656 #define IS_RTC_ALARM_DATEWEEKDAY_SEL(SEL) (((SEL) == RTC_AlarmDateWeekDaySel_Date) || \ 00657 ((SEL) == RTC_AlarmDateWeekDaySel_WeekDay)) 00658 00659 /** 00660 * @brief Macro used by the assert_param function in order to check the used 00661 * Alarm Mask 00662 */ 00663 #define IS_RTC_ALARM_MASK(MASK) (((MASK) & 0x0F) == (uint8_t)(RESET)) 00664 00665 /** 00666 * @brief Macro used by the assert_param function in order to check the used 00667 * wakeup clock source 00668 */ 00669 #define IS_RTC_WAKEUP_CLOCK(CLOCK) (((CLOCK) == RTC_WakeUpClock_RTCCLK_Div16) || \ 00670 ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div8) || \ 00671 ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div4) || \ 00672 ((CLOCK) == RTC_WakeUpClock_RTCCLK_Div2) || \ 00673 ((CLOCK) == RTC_WakeUpClock_CK_SPRE_16bits) || \ 00674 ((CLOCK) == RTC_WakeUpClock_CK_SPRE_17bits)) 00675 00676 /** 00677 * @brief Macro used by the assert_param function in order to check the used 00678 * Output selection 00679 */ 00680 #define IS_RTC_OUTPUT_SEL(SEL) (((SEL) == RTC_Output_Disable) || \ 00681 ((SEL) == RTC_Output_Alarm) || \ 00682 ((SEL) == RTC_Output_WakeUp)) 00683 /** 00684 * @brief Macro used by the assert_param function in order to check the used 00685 * Output polarity 00686 */ 00687 #define IS_RTC_OUTPUT_POL(POL) (((POL) == RTC_OutputPolarity_High) || \ 00688 ((POL) == RTC_OutputPolarity_Low)) 00689 00690 /** 00691 * @brief Macro used by the assert_param function in order to check the used 00692 * Daylight saving mode 00693 */ 00694 #define IS_RTC_DAYLIGHT_SAVING(SAVE) (((SAVE) == RTC_DayLightSaving_SUB1H) || \ 00695 ((SAVE) == RTC_DayLightSaving_ADD1H)) 00696 00697 /** 00698 * @brief Macro used by the assert_param function in order to check the used 00699 * Store Operation status 00700 */ 00701 #define IS_RTC_STORE_OPERATION(OP) (((OP) == RTC_StoreOperation_Set) || \ 00702 ((OP) == RTC_StoreOperation_Reset)) 00703 00704 00705 /** 00706 * @brief Macro used by the assert_param function in order to check the used 00707 * format (bin/bcd) for data user insert 00708 */ 00709 #define IS_RTC_FORMAT(FORMAT) (((FORMAT) == RTC_Format_BIN) || \ 00710 ((FORMAT) == RTC_Format_BCD)) 00711 00712 /** 00713 * @brief Macro used by the assert_param function in order to check the used 00714 * Flag to get 00715 */ 00716 #define IS_RTC_GET_FLAG(FLAG) (((FLAG) == RTC_FLAG_WUTF) || \ 00717 ((FLAG) == RTC_FLAG_ALRAF) || \ 00718 ((FLAG) == RTC_FLAG_INITF) || \ 00719 ((FLAG) == RTC_FLAG_RSF) || \ 00720 ((FLAG) == RTC_FLAG_INITS) || \ 00721 ((FLAG) == RTC_FLAG_WUTWF) || \ 00722 ((FLAG) == RTC_FLAG_TAMP3F)|| \ 00723 ((FLAG) == RTC_FLAG_TAMP2F)|| \ 00724 ((FLAG) == RTC_FLAG_TAMP1F)|| \ 00725 ((FLAG) == RTC_FLAG_SHPF) || \ 00726 ((FLAG) == RTC_FLAG_RECALPF) || \ 00727 ((FLAG) == RTC_FLAG_ALRAWF)) 00728 00729 /* RTC_FLAG_ALRAWF is for Medium Density only but supported by High Density 00730 Devices*/ 00731 00732 /** 00733 * @brief Macro used by the assert_param function in order to check the used 00734 * Flag to clear 00735 */ 00736 #define RTC_FLAG_CLRBLE (RTC_FLAG_RSF | RTC_FLAG_ALRAF | RTC_FLAG_WUTF| RTC_FLAG_TAMP1F|RTC_FLAG_TAMP2F|RTC_FLAG_TAMP3F) 00737 #define IS_RTC_CLEAR_FLAG(FLAG) (((FLAG) != RESET) && ((uint16_t)((FLAG) & (uint16_t)(~(RTC_FLAG_CLRBLE))) == RESET)) 00738 00739 /** 00740 * @brief Macro used by the assert_param function in order to check the used 00741 * Interrupt to configure 00742 */ 00743 #define IS_RTC_CONFIG_IT(IT) (((uint16_t)(IT) != (uint8_t)RESET) && ((uint16_t)((uint16_t)(IT) & (uint16_t)(~(uint16_t)(RTC_IT_WUT|RTC_IT_ALRA|RTC_IT_TAMP))) == (uint8_t)RESET)) 00744 00745 /** 00746 * @brief Macro used by the assert_param function in order to check the used 00747 * Interrupt to get 00748 */ 00749 #define IS_RTC_GET_IT(IT) (((IT) == RTC_IT_WUT) || \ 00750 ((IT) == RTC_IT_ALRA)|| \ 00751 ((IT) == RTC_IT_TAMP) ) 00752 00753 /** 00754 * @brief Macro used by the assert_param function in order to check the used 00755 * Interrupt to clear 00756 */ 00757 #define IS_RTC_CLEAR_IT(IT) (((IT) != RESET) && ((uint16_t)((IT) & (uint16_t)(~(uint16_t)(RTC_IT_WUT|RTC_IT_ALRA|RTC_IT_TAMP))) == RESET)) 00758 00759 /** 00760 * @brief Macro used by the assert_param function in order to check the used 00761 * Tamper Levels 00762 */ 00763 #define IS_RTC_TAMPER_LEVEL(LEVEL) (((LEVEL) == RTC_TamperLevel_Low) || \ 00764 ((LEVEL) == RTC_TamperLevel_High)) 00765 00766 /** 00767 * @brief Macro used by the assert_param function in order to check the used 00768 * Tamper 00769 */ 00770 #define NOT_CORRECT_TAMPER (uint8_t)~(uint8_t)( RTC_Tamper_1 | \ 00771 RTC_Tamper_2 | \ 00772 RTC_Tamper_3) 00773 #define IS_RTC_TAMPER(TAMPER) (((uint8_t)((TAMPER) & NOT_CORRECT_TAMPER) == RESET) && ((TAMPER) != RESET)) 00774 00775 /** 00776 * @brief Macro used by the assert_param function in order to check the used 00777 * Tampers Filter 00778 */ 00779 #define IS_RTC_TAMPER_FILTER(SEL) (((SEL) == RTC_TamperFilter_1Sample) || \ 00780 ((SEL) == RTC_TamperFilter_2Sample) || \ 00781 ((SEL) == RTC_TamperFilter_4Sample) || \ 00782 ((SEL) == RTC_TamperFilter_8Sample)) 00783 00784 /** 00785 * @brief Macro used by the assert_param function in order to check the used 00786 * Tampers Sampling Frequencies 00787 */ 00788 #define IS_RTC_TAMPER_SAMPLING_FREQ(SEL) ((SEL) <= RTC_TamperSamplingFreq_RTCCLK_Div256) 00789 00790 00791 /** 00792 * @brief Macro used by the assert_param function in order to check the used 00793 * Tampers Pins precharge duration 00794 */ 00795 #define IS_RTC_TAMPER_PINS_PRECHAR_DURATION(SEL) (((SEL) == RTC_TamperPrechargeDuration_None) || \ 00796 ((SEL) == RTC_TamperPrechargeDuration_1RTCCLK) || \ 00797 ((SEL) == RTC_TamperPrechargeDuration_2RTCCLK) || \ 00798 ((SEL) == RTC_TamperPrechargeDuration_4RTCCLK) || \ 00799 ((SEL) == RTC_TamperPrechargeDuration_8RTCCLK)) 00800 00801 /** 00802 * @brief Macro used by the assert_param function in order to check the used 00803 * Smooth calibration period 00804 */ 00805 #define IS_RTC_SMOOTH_CALIB_PERIOD(SEL) (((SEL) == RTC_SmoothCalibPeriod_32sec) || \ 00806 ((SEL) == RTC_SmoothCalibPeriod_16sec) || \ 00807 ((SEL) == RTC_SmoothCalibPeriod_8sec)) 00808 00809 /** 00810 * @brief Macro used by the assert_param function in order to check the used 00811 * Smooth calibration Plus pulses 00812 */ 00813 #define IS_RTC_SMOOTH_CALIB_PLUS(SEL) (((SEL) == RTC_SmoothCalibPlusPulses_Set) || \ 00814 ((SEL) == RTC_SmoothCalibPlusPulses_Reset)) 00815 /** 00816 * @brief Macro used by the assert_param function in order to check the used 00817 * Smooth calibration Minus pulses 00818 */ 00819 #define IS_RTC_SMOOTH_CALIB_MINUS(VALUE) ((VALUE) <= 0x01FF) 00820 00821 /** 00822 * @brief Macro used by the assert_param function in order to check the used 00823 * Output Selection 00824 */ 00825 #define IS_RTC_OUTPUT_SELECT(SEL) (((SEL) == RTC_Output_Disable) || \ 00826 ((SEL) == RTC_Output_Alarm) || \ 00827 ((SEL) == RTC_Output_WakeUp)) 00828 00829 /** 00830 * @brief Macro used by the assert_param function in order to check the 00831 * used calibration Output Selection 00832 */ 00833 #define IS_RTC_CALOUTPUT_SELECT(SEL) (((SEL) == RTC_CalibOutput_512Hz) || \ 00834 ((SEL) == RTC_CalibOutput_1Hz)) 00835 00836 /** 00837 * @brief Macro used by the assert_param function in order to check the used 00838 * Alarm sub second value 00839 */ 00840 #define IS_RTC_ALARM_SS_VALUE(SS) ((SS) <= 0x7FFF) 00841 00842 /** 00843 * @brief Macro used by the assert_param function in order to check the used 00844 * Alarm sub second mask 00845 */ 00846 #define IS_RTC_ALARM_SS_MASK(MASK) ((MASK) <= 0x0F) 00847 00848 /** 00849 * @brief Macro used by the assert_param function in order to check the used 00850 * fraction of seconds to sub 00851 */ 00852 #define IS_RTC_SHIFT_SUBFS(FS) ((FS) <= 0x7FFF) 00853 00854 /** 00855 * @brief Macro used by the assert_param function in order to check the 00856 * parameter of 1 second to add 00857 */ 00858 #define IS_RTC_SHIFT_ADD1S(VAL) (((VAL) == RTC_ShiftAdd1S_Set) || \ 00859 ((VAL) == RTC_ShiftAdd1S_Reset)) 00860 00861 /** 00862 * @} 00863 */ 00864 /* Exported functions ------------------------------------------------------- */ 00865 00866 /* Function used to set the RTC configuration to the default reset state *****/ 00867 ErrorStatus RTC_DeInit(void); 00868 00869 /* Initialization and Configuration functions *********************************/ 00870 ErrorStatus RTC_Init(RTC_InitTypeDef* RTC_InitStruct); 00871 void RTC_StructInit(RTC_InitTypeDef* RTC_InitStruct); 00872 void RTC_WriteProtectionCmd(FunctionalState NewState); 00873 ErrorStatus RTC_EnterInitMode(void); 00874 void RTC_ExitInitMode(void); 00875 ErrorStatus RTC_WaitForSynchro(void); 00876 void RTC_RatioCmd(FunctionalState NewState); 00877 void RTC_BypassShadowCmd(FunctionalState NewState); 00878 00879 /* Time and Date configuration functions **************************************/ 00880 ErrorStatus RTC_SetTime(RTC_Format_TypeDef RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct); 00881 void RTC_TimeStructInit(RTC_TimeTypeDef* RTC_TimeStruct); 00882 void RTC_GetTime(RTC_Format_TypeDef RTC_Format, RTC_TimeTypeDef* RTC_TimeStruct); 00883 uint16_t RTC_GetSubSecond(void); 00884 ErrorStatus RTC_SetDate(RTC_Format_TypeDef RTC_Format, RTC_DateTypeDef* RTC_DateStruct); 00885 void RTC_DateStructInit(RTC_DateTypeDef* RTC_DateStruct); 00886 void RTC_GetDate(RTC_Format_TypeDef RTC_Format, RTC_DateTypeDef* RTC_DateStruct); 00887 00888 /* Alarm configuration functions *********************************************/ 00889 void RTC_SetAlarm(RTC_Format_TypeDef RTC_Format, RTC_AlarmTypeDef* RTC_AlarmStruct); 00890 void RTC_AlarmStructInit(RTC_AlarmTypeDef* RTC_AlarmStruct); 00891 void RTC_GetAlarm(RTC_Format_TypeDef RTC_Format, RTC_AlarmTypeDef* RTC_AlarmStruct); 00892 ErrorStatus RTC_AlarmCmd(FunctionalState NewState); 00893 ErrorStatus RTC_AlarmSubSecondConfig(uint16_t RTC_AlarmSubSecondValue, 00894 RTC_AlarmSubSecondMask_TypeDef RTC_AlarmSubSecondMask); 00895 00896 /* WakeUp Timer configuration functions ***************************************/ 00897 void RTC_WakeUpClockConfig(RTC_WakeUpClock_TypeDef RTC_WakeUpClock); 00898 void RTC_SetWakeUpCounter(uint16_t RTC_WakeupCounter); 00899 uint16_t RTC_GetWakeUpCounter(void); 00900 ErrorStatus RTC_WakeUpCmd(FunctionalState NewState); 00901 00902 /* Daylight Saving configuration functions ************************************/ 00903 void RTC_DayLightSavingConfig(RTC_DayLightSaving_TypeDef RTC_DayLightSaving, 00904 RTC_StoreOperation_TypeDef RTC_StoreOperation); 00905 RTC_StoreOperation_TypeDef RTC_GetStoreOperation(void); 00906 00907 /* Output pin Configuration function ******************************************/ 00908 void RTC_OutputConfig(RTC_Output_TypeDef RTC_Output, 00909 RTC_OutputPolarity_TypeDef RTC_OutputPolarity); 00910 00911 /* Shift control synchronisation function ************************************/ 00912 ErrorStatus RTC_SynchroShiftConfig(RTC_ShiftAdd1S_TypeDef RTC_ShiftAdd1S, 00913 uint16_t RTC_ShiftSubFS); 00914 00915 /* Smooth Calibration functions **********************************************/ 00916 ErrorStatus RTC_SmoothCalibConfig(RTC_SmoothCalibPeriod_TypeDef RTC_SmoothCalibPeriod, 00917 RTC_SmoothCalibPlusPulses_TypeDef RTC_SmoothCalibPlusPulses, 00918 uint16_t RTC_SmouthCalibMinusPulsesValue); 00919 00920 /* Calibration configuration functions ****************************************/ 00921 void RTC_CalibOutputConfig(RTC_CalibOutput_TypeDef RTC_CalibOutput); 00922 void RTC_CalibOutputCmd(FunctionalState NewState); 00923 00924 /* Tampers configuration functions ********************************************/ 00925 void RTC_TamperLevelConfig(RTC_Tamper_TypeDef RTC_Tamper, 00926 RTC_TamperLevel_TypeDef RTC_TamperLevel); 00927 void RTC_TamperFilterConfig(RTC_TamperFilter_TypeDef RTC_TamperFilter); 00928 void RTC_TamperSamplingFreqConfig(RTC_TamperSamplingFreq_TypeDef RTC_TamperSamplingFreq); 00929 void RTC_TamperPinsPrechargeDuration(RTC_TamperPrechargeDuration_TypeDef RTC_TamperPrechargeDuration); 00930 void RTC_TamperCmd(RTC_Tamper_TypeDef RTC_Tamper, 00931 FunctionalState NewState); 00932 00933 /* Interrupts and flags management functions **********************************/ 00934 void RTC_ITConfig(RTC_IT_TypeDef RTC_IT, FunctionalState NewState); 00935 FlagStatus RTC_GetFlagStatus(RTC_Flag_TypeDef RTC_FLAG); 00936 void RTC_ClearFlag(RTC_Flag_TypeDef RTC_FLAG); 00937 ITStatus RTC_GetITStatus(RTC_IT_TypeDef RTC_IT); 00938 void RTC_ClearITPendingBit(RTC_IT_TypeDef RTC_IT); 00939 00940 #endif /*__STM8L15x_RTC_H */ 00941 00942 /** 00943 * @} 00944 */ 00945 00946 /** 00947 * @} 00948 */ 00949 00950 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/