mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_ll_rtc.c@165:e614a9f1c9e2, 2017-05-26 (annotated)
- Committer:
- AnnaBridge
- Date:
- Fri May 26 12:39:01 2017 +0100
- Revision:
- 165:e614a9f1c9e2
- Parent:
- 161:2cc1468da177
- Child:
- 182:a56a73fd2a6f
This updates the lib to the mbed lib v 143
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 161:2cc1468da177 | 1 | /** |
<> | 161:2cc1468da177 | 2 | ****************************************************************************** |
<> | 161:2cc1468da177 | 3 | * @file stm32f7xx_ll_rtc.c |
<> | 161:2cc1468da177 | 4 | * @author MCD Application Team |
<> | 161:2cc1468da177 | 5 | * @version V1.2.0 |
<> | 161:2cc1468da177 | 6 | * @date 30-December-2016 |
<> | 161:2cc1468da177 | 7 | * @brief RTC LL module driver. |
<> | 161:2cc1468da177 | 8 | ****************************************************************************** |
<> | 161:2cc1468da177 | 9 | * @attention |
<> | 161:2cc1468da177 | 10 | * |
<> | 161:2cc1468da177 | 11 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
<> | 161:2cc1468da177 | 12 | * |
<> | 161:2cc1468da177 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
<> | 161:2cc1468da177 | 14 | * are permitted provided that the following conditions are met: |
<> | 161:2cc1468da177 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
<> | 161:2cc1468da177 | 16 | * this list of conditions and the following disclaimer. |
<> | 161:2cc1468da177 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
<> | 161:2cc1468da177 | 18 | * this list of conditions and the following disclaimer in the documentation |
<> | 161:2cc1468da177 | 19 | * and/or other materials provided with the distribution. |
<> | 161:2cc1468da177 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
<> | 161:2cc1468da177 | 21 | * may be used to endorse or promote products derived from this software |
<> | 161:2cc1468da177 | 22 | * without specific prior written permission. |
<> | 161:2cc1468da177 | 23 | * |
<> | 161:2cc1468da177 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
<> | 161:2cc1468da177 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
<> | 161:2cc1468da177 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
<> | 161:2cc1468da177 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
<> | 161:2cc1468da177 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
<> | 161:2cc1468da177 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
<> | 161:2cc1468da177 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
<> | 161:2cc1468da177 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
<> | 161:2cc1468da177 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
<> | 161:2cc1468da177 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
<> | 161:2cc1468da177 | 34 | * |
<> | 161:2cc1468da177 | 35 | ****************************************************************************** |
<> | 161:2cc1468da177 | 36 | */ |
<> | 161:2cc1468da177 | 37 | #if defined(USE_FULL_LL_DRIVER) |
<> | 161:2cc1468da177 | 38 | |
<> | 161:2cc1468da177 | 39 | /* Includes ------------------------------------------------------------------*/ |
<> | 161:2cc1468da177 | 40 | #include "stm32f7xx_ll_rtc.h" |
<> | 161:2cc1468da177 | 41 | #include "stm32f7xx_ll_cortex.h" |
<> | 161:2cc1468da177 | 42 | #ifdef USE_FULL_ASSERT |
<> | 161:2cc1468da177 | 43 | #include "stm32_assert.h" |
<> | 161:2cc1468da177 | 44 | #else |
<> | 161:2cc1468da177 | 45 | #define assert_param(expr) ((void)0U) |
<> | 161:2cc1468da177 | 46 | #endif |
<> | 161:2cc1468da177 | 47 | |
<> | 161:2cc1468da177 | 48 | /** @addtogroup STM32F7xx_LL_Driver |
<> | 161:2cc1468da177 | 49 | * @{ |
<> | 161:2cc1468da177 | 50 | */ |
<> | 161:2cc1468da177 | 51 | |
<> | 161:2cc1468da177 | 52 | #if defined(RTC) |
<> | 161:2cc1468da177 | 53 | |
<> | 161:2cc1468da177 | 54 | /** @addtogroup RTC_LL |
<> | 161:2cc1468da177 | 55 | * @{ |
<> | 161:2cc1468da177 | 56 | */ |
<> | 161:2cc1468da177 | 57 | |
<> | 161:2cc1468da177 | 58 | /* Private types -------------------------------------------------------------*/ |
<> | 161:2cc1468da177 | 59 | /* Private variables ---------------------------------------------------------*/ |
<> | 161:2cc1468da177 | 60 | /* Private constants ---------------------------------------------------------*/ |
<> | 161:2cc1468da177 | 61 | /** @addtogroup RTC_LL_Private_Constants |
<> | 161:2cc1468da177 | 62 | * @{ |
<> | 161:2cc1468da177 | 63 | */ |
<> | 161:2cc1468da177 | 64 | /* Default values used for prescaler */ |
<> | 161:2cc1468da177 | 65 | #define RTC_ASYNCH_PRESC_DEFAULT 0x0000007FU |
<> | 161:2cc1468da177 | 66 | #define RTC_SYNCH_PRESC_DEFAULT 0x000000FFU |
<> | 161:2cc1468da177 | 67 | |
<> | 161:2cc1468da177 | 68 | /* Values used for timeout */ |
<> | 161:2cc1468da177 | 69 | #define RTC_INITMODE_TIMEOUT 1000U /* 1s when tick set to 1ms */ |
<> | 161:2cc1468da177 | 70 | #define RTC_SYNCHRO_TIMEOUT 1000U /* 1s when tick set to 1ms */ |
<> | 161:2cc1468da177 | 71 | /** |
<> | 161:2cc1468da177 | 72 | * @} |
<> | 161:2cc1468da177 | 73 | */ |
<> | 161:2cc1468da177 | 74 | |
<> | 161:2cc1468da177 | 75 | /* Private macros ------------------------------------------------------------*/ |
<> | 161:2cc1468da177 | 76 | /** @addtogroup RTC_LL_Private_Macros |
<> | 161:2cc1468da177 | 77 | * @{ |
<> | 161:2cc1468da177 | 78 | */ |
<> | 161:2cc1468da177 | 79 | |
<> | 161:2cc1468da177 | 80 | #define IS_LL_RTC_HOURFORMAT(__VALUE__) (((__VALUE__) == LL_RTC_HOURFORMAT_24HOUR) \ |
<> | 161:2cc1468da177 | 81 | || ((__VALUE__) == LL_RTC_HOURFORMAT_AMPM)) |
<> | 161:2cc1468da177 | 82 | |
<> | 161:2cc1468da177 | 83 | #define IS_LL_RTC_ASYNCH_PREDIV(__VALUE__) ((__VALUE__) <= 0x7FU) |
<> | 161:2cc1468da177 | 84 | |
<> | 161:2cc1468da177 | 85 | #define IS_LL_RTC_SYNCH_PREDIV(__VALUE__) ((__VALUE__) <= 0x7FFFU) |
<> | 161:2cc1468da177 | 86 | |
<> | 161:2cc1468da177 | 87 | #define IS_LL_RTC_FORMAT(__VALUE__) (((__VALUE__) == LL_RTC_FORMAT_BIN) \ |
<> | 161:2cc1468da177 | 88 | || ((__VALUE__) == LL_RTC_FORMAT_BCD)) |
<> | 161:2cc1468da177 | 89 | |
<> | 161:2cc1468da177 | 90 | #define IS_LL_RTC_TIME_FORMAT(__VALUE__) (((__VALUE__) == LL_RTC_TIME_FORMAT_AM_OR_24) \ |
<> | 161:2cc1468da177 | 91 | || ((__VALUE__) == LL_RTC_TIME_FORMAT_PM)) |
<> | 161:2cc1468da177 | 92 | |
<> | 161:2cc1468da177 | 93 | #define IS_LL_RTC_HOUR12(__HOUR__) (((__HOUR__) > 0U) && ((__HOUR__) <= 12U)) |
<> | 161:2cc1468da177 | 94 | #define IS_LL_RTC_HOUR24(__HOUR__) ((__HOUR__) <= 23U) |
<> | 161:2cc1468da177 | 95 | #define IS_LL_RTC_MINUTES(__MINUTES__) ((__MINUTES__) <= 59U) |
<> | 161:2cc1468da177 | 96 | #define IS_LL_RTC_SECONDS(__SECONDS__) ((__SECONDS__) <= 59U) |
<> | 161:2cc1468da177 | 97 | |
<> | 161:2cc1468da177 | 98 | #define IS_LL_RTC_WEEKDAY(__VALUE__) (((__VALUE__) == LL_RTC_WEEKDAY_MONDAY) \ |
<> | 161:2cc1468da177 | 99 | || ((__VALUE__) == LL_RTC_WEEKDAY_TUESDAY) \ |
<> | 161:2cc1468da177 | 100 | || ((__VALUE__) == LL_RTC_WEEKDAY_WEDNESDAY) \ |
<> | 161:2cc1468da177 | 101 | || ((__VALUE__) == LL_RTC_WEEKDAY_THURSDAY) \ |
<> | 161:2cc1468da177 | 102 | || ((__VALUE__) == LL_RTC_WEEKDAY_FRIDAY) \ |
<> | 161:2cc1468da177 | 103 | || ((__VALUE__) == LL_RTC_WEEKDAY_SATURDAY) \ |
<> | 161:2cc1468da177 | 104 | || ((__VALUE__) == LL_RTC_WEEKDAY_SUNDAY)) |
<> | 161:2cc1468da177 | 105 | |
<> | 161:2cc1468da177 | 106 | #define IS_LL_RTC_DAY(__DAY__) (((__DAY__) >= 1U) && ((__DAY__) <= 31U)) |
<> | 161:2cc1468da177 | 107 | |
<> | 161:2cc1468da177 | 108 | #define IS_LL_RTC_MONTH(__VALUE__) (((__VALUE__) == LL_RTC_MONTH_JANUARY) \ |
<> | 161:2cc1468da177 | 109 | || ((__VALUE__) == LL_RTC_MONTH_FEBRUARY) \ |
<> | 161:2cc1468da177 | 110 | || ((__VALUE__) == LL_RTC_MONTH_MARCH) \ |
<> | 161:2cc1468da177 | 111 | || ((__VALUE__) == LL_RTC_MONTH_APRIL) \ |
<> | 161:2cc1468da177 | 112 | || ((__VALUE__) == LL_RTC_MONTH_MAY) \ |
<> | 161:2cc1468da177 | 113 | || ((__VALUE__) == LL_RTC_MONTH_JUNE) \ |
<> | 161:2cc1468da177 | 114 | || ((__VALUE__) == LL_RTC_MONTH_JULY) \ |
<> | 161:2cc1468da177 | 115 | || ((__VALUE__) == LL_RTC_MONTH_AUGUST) \ |
<> | 161:2cc1468da177 | 116 | || ((__VALUE__) == LL_RTC_MONTH_SEPTEMBER) \ |
<> | 161:2cc1468da177 | 117 | || ((__VALUE__) == LL_RTC_MONTH_OCTOBER) \ |
<> | 161:2cc1468da177 | 118 | || ((__VALUE__) == LL_RTC_MONTH_NOVEMBER) \ |
<> | 161:2cc1468da177 | 119 | || ((__VALUE__) == LL_RTC_MONTH_DECEMBER)) |
<> | 161:2cc1468da177 | 120 | |
<> | 161:2cc1468da177 | 121 | #define IS_LL_RTC_YEAR(__YEAR__) ((__YEAR__) <= 99U) |
<> | 161:2cc1468da177 | 122 | |
<> | 161:2cc1468da177 | 123 | #define IS_LL_RTC_ALMA_MASK(__VALUE__) (((__VALUE__) == LL_RTC_ALMA_MASK_NONE) \ |
<> | 161:2cc1468da177 | 124 | || ((__VALUE__) == LL_RTC_ALMA_MASK_DATEWEEKDAY) \ |
<> | 161:2cc1468da177 | 125 | || ((__VALUE__) == LL_RTC_ALMA_MASK_HOURS) \ |
<> | 161:2cc1468da177 | 126 | || ((__VALUE__) == LL_RTC_ALMA_MASK_MINUTES) \ |
<> | 161:2cc1468da177 | 127 | || ((__VALUE__) == LL_RTC_ALMA_MASK_SECONDS) \ |
<> | 161:2cc1468da177 | 128 | || ((__VALUE__) == LL_RTC_ALMA_MASK_ALL)) |
<> | 161:2cc1468da177 | 129 | |
<> | 161:2cc1468da177 | 130 | #define IS_LL_RTC_ALMB_MASK(__VALUE__) (((__VALUE__) == LL_RTC_ALMB_MASK_NONE) \ |
<> | 161:2cc1468da177 | 131 | || ((__VALUE__) == LL_RTC_ALMB_MASK_DATEWEEKDAY) \ |
<> | 161:2cc1468da177 | 132 | || ((__VALUE__) == LL_RTC_ALMB_MASK_HOURS) \ |
<> | 161:2cc1468da177 | 133 | || ((__VALUE__) == LL_RTC_ALMB_MASK_MINUTES) \ |
<> | 161:2cc1468da177 | 134 | || ((__VALUE__) == LL_RTC_ALMB_MASK_SECONDS) \ |
<> | 161:2cc1468da177 | 135 | || ((__VALUE__) == LL_RTC_ALMB_MASK_ALL)) |
<> | 161:2cc1468da177 | 136 | |
<> | 161:2cc1468da177 | 137 | |
<> | 161:2cc1468da177 | 138 | #define IS_LL_RTC_ALMA_DATE_WEEKDAY_SEL(__SEL__) (((__SEL__) == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE) || \ |
<> | 161:2cc1468da177 | 139 | ((__SEL__) == LL_RTC_ALMA_DATEWEEKDAYSEL_WEEKDAY)) |
<> | 161:2cc1468da177 | 140 | |
<> | 161:2cc1468da177 | 141 | #define IS_LL_RTC_ALMB_DATE_WEEKDAY_SEL(__SEL__) (((__SEL__) == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE) || \ |
<> | 161:2cc1468da177 | 142 | ((__SEL__) == LL_RTC_ALMB_DATEWEEKDAYSEL_WEEKDAY)) |
<> | 161:2cc1468da177 | 143 | |
<> | 161:2cc1468da177 | 144 | |
<> | 161:2cc1468da177 | 145 | /** |
<> | 161:2cc1468da177 | 146 | * @} |
<> | 161:2cc1468da177 | 147 | */ |
<> | 161:2cc1468da177 | 148 | /* Private function prototypes -----------------------------------------------*/ |
<> | 161:2cc1468da177 | 149 | /* Exported functions --------------------------------------------------------*/ |
<> | 161:2cc1468da177 | 150 | /** @addtogroup RTC_LL_Exported_Functions |
<> | 161:2cc1468da177 | 151 | * @{ |
<> | 161:2cc1468da177 | 152 | */ |
<> | 161:2cc1468da177 | 153 | |
<> | 161:2cc1468da177 | 154 | /** @addtogroup RTC_LL_EF_Init |
<> | 161:2cc1468da177 | 155 | * @{ |
<> | 161:2cc1468da177 | 156 | */ |
<> | 161:2cc1468da177 | 157 | |
<> | 161:2cc1468da177 | 158 | /** |
<> | 161:2cc1468da177 | 159 | * @brief De-Initializes the RTC registers to their default reset values. |
<> | 161:2cc1468da177 | 160 | * @note This function doesn't reset the RTC Clock source and RTC Backup Data |
<> | 161:2cc1468da177 | 161 | * registers. |
<> | 161:2cc1468da177 | 162 | * @param RTCx RTC Instance |
<> | 161:2cc1468da177 | 163 | * @retval An ErrorStatus enumeration value: |
<> | 161:2cc1468da177 | 164 | * - SUCCESS: RTC registers are de-initialized |
<> | 161:2cc1468da177 | 165 | * - ERROR: RTC registers are not de-initialized |
<> | 161:2cc1468da177 | 166 | */ |
<> | 161:2cc1468da177 | 167 | ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx) |
<> | 161:2cc1468da177 | 168 | { |
<> | 161:2cc1468da177 | 169 | ErrorStatus status = ERROR; |
<> | 161:2cc1468da177 | 170 | |
<> | 161:2cc1468da177 | 171 | /* Check the parameter */ |
<> | 161:2cc1468da177 | 172 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
<> | 161:2cc1468da177 | 173 | |
<> | 161:2cc1468da177 | 174 | /* Disable the write protection for RTC registers */ |
<> | 161:2cc1468da177 | 175 | LL_RTC_DisableWriteProtection(RTCx); |
<> | 161:2cc1468da177 | 176 | |
<> | 161:2cc1468da177 | 177 | /* Set Initialization mode */ |
<> | 161:2cc1468da177 | 178 | if (LL_RTC_EnterInitMode(RTCx) != ERROR) |
<> | 161:2cc1468da177 | 179 | { |
<> | 161:2cc1468da177 | 180 | /* Reset TR, DR and CR registers */ |
<> | 161:2cc1468da177 | 181 | LL_RTC_WriteReg(RTCx, TR, 0x00000000U); |
<> | 161:2cc1468da177 | 182 | #if defined(RTC_WAKEUP_SUPPORT) |
<> | 161:2cc1468da177 | 183 | LL_RTC_WriteReg(RTCx, WUTR, RTC_WUTR_WUT); |
<> | 161:2cc1468da177 | 184 | #endif /* RTC_WAKEUP_SUPPORT */ |
<> | 161:2cc1468da177 | 185 | LL_RTC_WriteReg(RTCx, DR , (RTC_DR_WDU_0 | RTC_DR_MU_0 | RTC_DR_DU_0)); |
<> | 161:2cc1468da177 | 186 | /* Reset All CR bits except CR[2:0] */ |
<> | 161:2cc1468da177 | 187 | #if defined(RTC_WAKEUP_SUPPORT) |
<> | 161:2cc1468da177 | 188 | LL_RTC_WriteReg(RTCx, CR, (LL_RTC_ReadReg(RTCx, CR) & RTC_CR_WUCKSEL)); |
<> | 161:2cc1468da177 | 189 | #else |
<> | 161:2cc1468da177 | 190 | LL_RTC_WriteReg(RTCx, CR, 0x00000000U); |
<> | 161:2cc1468da177 | 191 | #endif /* RTC_WAKEUP_SUPPORT */ |
<> | 161:2cc1468da177 | 192 | LL_RTC_WriteReg(RTCx, PRER, (RTC_PRER_PREDIV_A | RTC_SYNCH_PRESC_DEFAULT)); |
<> | 161:2cc1468da177 | 193 | LL_RTC_WriteReg(RTCx, ALRMAR, 0x00000000U); |
<> | 161:2cc1468da177 | 194 | LL_RTC_WriteReg(RTCx, ALRMBR, 0x00000000U); |
<> | 161:2cc1468da177 | 195 | LL_RTC_WriteReg(RTCx, SHIFTR, 0x00000000U); |
<> | 161:2cc1468da177 | 196 | LL_RTC_WriteReg(RTCx, CALR, 0x00000000U); |
<> | 161:2cc1468da177 | 197 | LL_RTC_WriteReg(RTCx, ALRMASSR, 0x00000000U); |
<> | 161:2cc1468da177 | 198 | LL_RTC_WriteReg(RTCx, ALRMBSSR, 0x00000000U); |
<> | 161:2cc1468da177 | 199 | |
<> | 161:2cc1468da177 | 200 | /* Reset ISR register and exit initialization mode */ |
<> | 161:2cc1468da177 | 201 | LL_RTC_WriteReg(RTCx, ISR, 0x00000000U); |
<> | 161:2cc1468da177 | 202 | |
<> | 161:2cc1468da177 | 203 | /* Reset Tamper and alternate functions configuration register */ |
<> | 161:2cc1468da177 | 204 | LL_RTC_WriteReg(RTCx, TAMPCR, 0x00000000U); |
<> | 161:2cc1468da177 | 205 | |
<> | 161:2cc1468da177 | 206 | /* Reset Option register */ |
<> | 161:2cc1468da177 | 207 | LL_RTC_WriteReg(RTCx, OR, 0x00000000U); |
<> | 161:2cc1468da177 | 208 | |
<> | 161:2cc1468da177 | 209 | /* Wait till the RTC RSF flag is set */ |
<> | 161:2cc1468da177 | 210 | status = LL_RTC_WaitForSynchro(RTCx); |
<> | 161:2cc1468da177 | 211 | } |
<> | 161:2cc1468da177 | 212 | |
<> | 161:2cc1468da177 | 213 | /* Enable the write protection for RTC registers */ |
<> | 161:2cc1468da177 | 214 | LL_RTC_EnableWriteProtection(RTCx); |
<> | 161:2cc1468da177 | 215 | |
<> | 161:2cc1468da177 | 216 | return status; |
<> | 161:2cc1468da177 | 217 | } |
<> | 161:2cc1468da177 | 218 | |
<> | 161:2cc1468da177 | 219 | /** |
<> | 161:2cc1468da177 | 220 | * @brief Initializes the RTC registers according to the specified parameters |
<> | 161:2cc1468da177 | 221 | * in RTC_InitStruct. |
<> | 161:2cc1468da177 | 222 | * @param RTCx RTC Instance |
<> | 161:2cc1468da177 | 223 | * @param RTC_InitStruct pointer to a @ref LL_RTC_InitTypeDef structure that contains |
<> | 161:2cc1468da177 | 224 | * the configuration information for the RTC peripheral. |
<> | 161:2cc1468da177 | 225 | * @note The RTC Prescaler register is write protected and can be written in |
<> | 161:2cc1468da177 | 226 | * initialization mode only. |
<> | 161:2cc1468da177 | 227 | * @retval An ErrorStatus enumeration value: |
<> | 161:2cc1468da177 | 228 | * - SUCCESS: RTC registers are initialized |
<> | 161:2cc1468da177 | 229 | * - ERROR: RTC registers are not initialized |
<> | 161:2cc1468da177 | 230 | */ |
<> | 161:2cc1468da177 | 231 | ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct) |
<> | 161:2cc1468da177 | 232 | { |
<> | 161:2cc1468da177 | 233 | ErrorStatus status = ERROR; |
<> | 161:2cc1468da177 | 234 | |
<> | 161:2cc1468da177 | 235 | /* Check the parameters */ |
<> | 161:2cc1468da177 | 236 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
<> | 161:2cc1468da177 | 237 | assert_param(IS_LL_RTC_HOURFORMAT(RTC_InitStruct->HourFormat)); |
<> | 161:2cc1468da177 | 238 | assert_param(IS_LL_RTC_ASYNCH_PREDIV(RTC_InitStruct->AsynchPrescaler)); |
<> | 161:2cc1468da177 | 239 | assert_param(IS_LL_RTC_SYNCH_PREDIV(RTC_InitStruct->SynchPrescaler)); |
<> | 161:2cc1468da177 | 240 | |
<> | 161:2cc1468da177 | 241 | /* Disable the write protection for RTC registers */ |
<> | 161:2cc1468da177 | 242 | LL_RTC_DisableWriteProtection(RTCx); |
<> | 161:2cc1468da177 | 243 | |
<> | 161:2cc1468da177 | 244 | /* Set Initialization mode */ |
<> | 161:2cc1468da177 | 245 | if (LL_RTC_EnterInitMode(RTCx) != ERROR) |
<> | 161:2cc1468da177 | 246 | { |
<> | 161:2cc1468da177 | 247 | /* Set Hour Format */ |
<> | 161:2cc1468da177 | 248 | LL_RTC_SetHourFormat(RTCx, RTC_InitStruct->HourFormat); |
<> | 161:2cc1468da177 | 249 | |
<> | 161:2cc1468da177 | 250 | /* Configure Synchronous and Asynchronous prescaler factor */ |
<> | 161:2cc1468da177 | 251 | LL_RTC_SetSynchPrescaler(RTCx, RTC_InitStruct->SynchPrescaler); |
<> | 161:2cc1468da177 | 252 | LL_RTC_SetAsynchPrescaler(RTCx, RTC_InitStruct->AsynchPrescaler); |
<> | 161:2cc1468da177 | 253 | |
<> | 161:2cc1468da177 | 254 | /* Exit Initialization mode */ |
<> | 161:2cc1468da177 | 255 | LL_RTC_DisableInitMode(RTCx); |
<> | 161:2cc1468da177 | 256 | |
<> | 161:2cc1468da177 | 257 | status = SUCCESS; |
<> | 161:2cc1468da177 | 258 | } |
<> | 161:2cc1468da177 | 259 | /* Enable the write protection for RTC registers */ |
<> | 161:2cc1468da177 | 260 | LL_RTC_EnableWriteProtection(RTCx); |
<> | 161:2cc1468da177 | 261 | |
<> | 161:2cc1468da177 | 262 | return status; |
<> | 161:2cc1468da177 | 263 | } |
<> | 161:2cc1468da177 | 264 | |
<> | 161:2cc1468da177 | 265 | /** |
<> | 161:2cc1468da177 | 266 | * @brief Set each @ref LL_RTC_InitTypeDef field to default value. |
<> | 161:2cc1468da177 | 267 | * @param RTC_InitStruct pointer to a @ref LL_RTC_InitTypeDef structure which will be initialized. |
<> | 161:2cc1468da177 | 268 | * @retval None |
<> | 161:2cc1468da177 | 269 | */ |
<> | 161:2cc1468da177 | 270 | void LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct) |
<> | 161:2cc1468da177 | 271 | { |
<> | 161:2cc1468da177 | 272 | /* Set RTC_InitStruct fields to default values */ |
<> | 161:2cc1468da177 | 273 | RTC_InitStruct->HourFormat = LL_RTC_HOURFORMAT_24HOUR; |
<> | 161:2cc1468da177 | 274 | RTC_InitStruct->AsynchPrescaler = RTC_ASYNCH_PRESC_DEFAULT; |
<> | 161:2cc1468da177 | 275 | RTC_InitStruct->SynchPrescaler = RTC_SYNCH_PRESC_DEFAULT; |
<> | 161:2cc1468da177 | 276 | } |
<> | 161:2cc1468da177 | 277 | |
<> | 161:2cc1468da177 | 278 | /** |
<> | 161:2cc1468da177 | 279 | * @brief Set the RTC current time. |
<> | 161:2cc1468da177 | 280 | * @param RTCx RTC Instance |
<> | 161:2cc1468da177 | 281 | * @param RTC_Format This parameter can be one of the following values: |
<> | 161:2cc1468da177 | 282 | * @arg @ref LL_RTC_FORMAT_BIN |
<> | 161:2cc1468da177 | 283 | * @arg @ref LL_RTC_FORMAT_BCD |
<> | 161:2cc1468da177 | 284 | * @param RTC_TimeStruct pointer to a RTC_TimeTypeDef structure that contains |
<> | 161:2cc1468da177 | 285 | * the time configuration information for the RTC. |
<> | 161:2cc1468da177 | 286 | * @retval An ErrorStatus enumeration value: |
<> | 161:2cc1468da177 | 287 | * - SUCCESS: RTC Time register is configured |
<> | 161:2cc1468da177 | 288 | * - ERROR: RTC Time register is not configured |
<> | 161:2cc1468da177 | 289 | */ |
<> | 161:2cc1468da177 | 290 | ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct) |
<> | 161:2cc1468da177 | 291 | { |
<> | 161:2cc1468da177 | 292 | ErrorStatus status = ERROR; |
<> | 161:2cc1468da177 | 293 | |
<> | 161:2cc1468da177 | 294 | /* Check the parameters */ |
<> | 161:2cc1468da177 | 295 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
<> | 161:2cc1468da177 | 296 | assert_param(IS_LL_RTC_FORMAT(RTC_Format)); |
<> | 161:2cc1468da177 | 297 | |
<> | 161:2cc1468da177 | 298 | if (RTC_Format == LL_RTC_FORMAT_BIN) |
<> | 161:2cc1468da177 | 299 | { |
<> | 161:2cc1468da177 | 300 | if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) |
<> | 161:2cc1468da177 | 301 | { |
<> | 161:2cc1468da177 | 302 | assert_param(IS_LL_RTC_HOUR12(RTC_TimeStruct->Hours)); |
<> | 161:2cc1468da177 | 303 | assert_param(IS_LL_RTC_TIME_FORMAT(RTC_TimeStruct->TimeFormat)); |
<> | 161:2cc1468da177 | 304 | } |
<> | 161:2cc1468da177 | 305 | else |
<> | 161:2cc1468da177 | 306 | { |
<> | 161:2cc1468da177 | 307 | RTC_TimeStruct->TimeFormat = 0x00U; |
<> | 161:2cc1468da177 | 308 | assert_param(IS_LL_RTC_HOUR24(RTC_TimeStruct->Hours)); |
<> | 161:2cc1468da177 | 309 | } |
<> | 161:2cc1468da177 | 310 | assert_param(IS_LL_RTC_MINUTES(RTC_TimeStruct->Minutes)); |
<> | 161:2cc1468da177 | 311 | assert_param(IS_LL_RTC_SECONDS(RTC_TimeStruct->Seconds)); |
<> | 161:2cc1468da177 | 312 | } |
<> | 161:2cc1468da177 | 313 | else |
<> | 161:2cc1468da177 | 314 | { |
<> | 161:2cc1468da177 | 315 | if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) |
<> | 161:2cc1468da177 | 316 | { |
<> | 161:2cc1468da177 | 317 | assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Hours))); |
<> | 161:2cc1468da177 | 318 | assert_param(IS_LL_RTC_TIME_FORMAT(RTC_TimeStruct->TimeFormat)); |
<> | 161:2cc1468da177 | 319 | } |
<> | 161:2cc1468da177 | 320 | else |
<> | 161:2cc1468da177 | 321 | { |
<> | 161:2cc1468da177 | 322 | RTC_TimeStruct->TimeFormat = 0x00U; |
<> | 161:2cc1468da177 | 323 | assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Hours))); |
<> | 161:2cc1468da177 | 324 | } |
<> | 161:2cc1468da177 | 325 | assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Minutes))); |
<> | 161:2cc1468da177 | 326 | assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Seconds))); |
<> | 161:2cc1468da177 | 327 | } |
<> | 161:2cc1468da177 | 328 | |
<> | 161:2cc1468da177 | 329 | /* Disable the write protection for RTC registers */ |
<> | 161:2cc1468da177 | 330 | LL_RTC_DisableWriteProtection(RTCx); |
<> | 161:2cc1468da177 | 331 | |
<> | 161:2cc1468da177 | 332 | /* Set Initialization mode */ |
<> | 161:2cc1468da177 | 333 | if (LL_RTC_EnterInitMode(RTCx) != ERROR) |
<> | 161:2cc1468da177 | 334 | { |
<> | 161:2cc1468da177 | 335 | /* Check the input parameters format */ |
<> | 161:2cc1468da177 | 336 | if (RTC_Format != LL_RTC_FORMAT_BIN) |
<> | 161:2cc1468da177 | 337 | { |
<> | 161:2cc1468da177 | 338 | LL_RTC_TIME_Config(RTCx, RTC_TimeStruct->TimeFormat, RTC_TimeStruct->Hours, |
<> | 161:2cc1468da177 | 339 | RTC_TimeStruct->Minutes, RTC_TimeStruct->Seconds); |
<> | 161:2cc1468da177 | 340 | } |
<> | 161:2cc1468da177 | 341 | else |
<> | 161:2cc1468da177 | 342 | { |
<> | 161:2cc1468da177 | 343 | LL_RTC_TIME_Config(RTCx, RTC_TimeStruct->TimeFormat, __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->Hours), |
<> | 161:2cc1468da177 | 344 | __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->Minutes), |
<> | 161:2cc1468da177 | 345 | __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->Seconds)); |
<> | 161:2cc1468da177 | 346 | } |
<> | 161:2cc1468da177 | 347 | |
<> | 161:2cc1468da177 | 348 | /* Exit Initialization mode */ |
<> | 161:2cc1468da177 | 349 | LL_RTC_DisableInitMode(RTC); |
<> | 161:2cc1468da177 | 350 | |
<> | 161:2cc1468da177 | 351 | /* If RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */ |
<> | 161:2cc1468da177 | 352 | if (LL_RTC_IsShadowRegBypassEnabled(RTCx) == 0U) |
<> | 161:2cc1468da177 | 353 | { |
<> | 161:2cc1468da177 | 354 | status = LL_RTC_WaitForSynchro(RTCx); |
<> | 161:2cc1468da177 | 355 | } |
<> | 161:2cc1468da177 | 356 | else |
<> | 161:2cc1468da177 | 357 | { |
<> | 161:2cc1468da177 | 358 | status = SUCCESS; |
<> | 161:2cc1468da177 | 359 | } |
<> | 161:2cc1468da177 | 360 | } |
<> | 161:2cc1468da177 | 361 | /* Enable the write protection for RTC registers */ |
<> | 161:2cc1468da177 | 362 | LL_RTC_EnableWriteProtection(RTCx); |
<> | 161:2cc1468da177 | 363 | |
<> | 161:2cc1468da177 | 364 | return status; |
<> | 161:2cc1468da177 | 365 | } |
<> | 161:2cc1468da177 | 366 | |
<> | 161:2cc1468da177 | 367 | /** |
<> | 161:2cc1468da177 | 368 | * @brief Set each @ref LL_RTC_TimeTypeDef field to default value (Time = 00h:00min:00sec). |
<> | 161:2cc1468da177 | 369 | * @param RTC_TimeStruct pointer to a @ref LL_RTC_TimeTypeDef structure which will be initialized. |
<> | 161:2cc1468da177 | 370 | * @retval None |
<> | 161:2cc1468da177 | 371 | */ |
<> | 161:2cc1468da177 | 372 | void LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct) |
<> | 161:2cc1468da177 | 373 | { |
<> | 161:2cc1468da177 | 374 | /* Time = 00h:00min:00sec */ |
<> | 161:2cc1468da177 | 375 | RTC_TimeStruct->TimeFormat = LL_RTC_TIME_FORMAT_AM_OR_24; |
<> | 161:2cc1468da177 | 376 | RTC_TimeStruct->Hours = 0U; |
<> | 161:2cc1468da177 | 377 | RTC_TimeStruct->Minutes = 0U; |
<> | 161:2cc1468da177 | 378 | RTC_TimeStruct->Seconds = 0U; |
<> | 161:2cc1468da177 | 379 | } |
<> | 161:2cc1468da177 | 380 | |
<> | 161:2cc1468da177 | 381 | /** |
<> | 161:2cc1468da177 | 382 | * @brief Set the RTC current date. |
<> | 161:2cc1468da177 | 383 | * @param RTCx RTC Instance |
<> | 161:2cc1468da177 | 384 | * @param RTC_Format This parameter can be one of the following values: |
<> | 161:2cc1468da177 | 385 | * @arg @ref LL_RTC_FORMAT_BIN |
<> | 161:2cc1468da177 | 386 | * @arg @ref LL_RTC_FORMAT_BCD |
<> | 161:2cc1468da177 | 387 | * @param RTC_DateStruct: pointer to a RTC_DateTypeDef structure that contains |
<> | 161:2cc1468da177 | 388 | * the date configuration information for the RTC. |
<> | 161:2cc1468da177 | 389 | * @retval An ErrorStatus enumeration value: |
<> | 161:2cc1468da177 | 390 | * - SUCCESS: RTC Day register is configured |
<> | 161:2cc1468da177 | 391 | * - ERROR: RTC Day register is not configured |
<> | 161:2cc1468da177 | 392 | */ |
<> | 161:2cc1468da177 | 393 | ErrorStatus LL_RTC_DATE_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_DateTypeDef *RTC_DateStruct) |
<> | 161:2cc1468da177 | 394 | { |
<> | 161:2cc1468da177 | 395 | ErrorStatus status = ERROR; |
<> | 161:2cc1468da177 | 396 | |
<> | 161:2cc1468da177 | 397 | /* Check the parameters */ |
<> | 161:2cc1468da177 | 398 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
<> | 161:2cc1468da177 | 399 | assert_param(IS_LL_RTC_FORMAT(RTC_Format)); |
<> | 161:2cc1468da177 | 400 | |
<> | 161:2cc1468da177 | 401 | if ((RTC_Format == LL_RTC_FORMAT_BIN) && ((RTC_DateStruct->Month & 0x10U) == 0x10U)) |
<> | 161:2cc1468da177 | 402 | { |
<> | 161:2cc1468da177 | 403 | RTC_DateStruct->Month = (RTC_DateStruct->Month & (uint32_t)~(0x10U)) + 0x0AU; |
<> | 161:2cc1468da177 | 404 | } |
<> | 161:2cc1468da177 | 405 | if (RTC_Format == LL_RTC_FORMAT_BIN) |
<> | 161:2cc1468da177 | 406 | { |
<> | 161:2cc1468da177 | 407 | assert_param(IS_LL_RTC_YEAR(RTC_DateStruct->Year)); |
<> | 161:2cc1468da177 | 408 | assert_param(IS_LL_RTC_MONTH(RTC_DateStruct->Month)); |
<> | 161:2cc1468da177 | 409 | assert_param(IS_LL_RTC_DAY(RTC_DateStruct->Day)); |
<> | 161:2cc1468da177 | 410 | } |
<> | 161:2cc1468da177 | 411 | else |
<> | 161:2cc1468da177 | 412 | { |
<> | 161:2cc1468da177 | 413 | assert_param(IS_LL_RTC_YEAR(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->Year))); |
<> | 161:2cc1468da177 | 414 | assert_param(IS_LL_RTC_MONTH(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->Month))); |
<> | 161:2cc1468da177 | 415 | assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->Day))); |
<> | 161:2cc1468da177 | 416 | } |
<> | 161:2cc1468da177 | 417 | assert_param(IS_LL_RTC_WEEKDAY(RTC_DateStruct->WeekDay)); |
<> | 161:2cc1468da177 | 418 | |
<> | 161:2cc1468da177 | 419 | /* Disable the write protection for RTC registers */ |
<> | 161:2cc1468da177 | 420 | LL_RTC_DisableWriteProtection(RTCx); |
<> | 161:2cc1468da177 | 421 | |
<> | 161:2cc1468da177 | 422 | /* Set Initialization mode */ |
<> | 161:2cc1468da177 | 423 | if (LL_RTC_EnterInitMode(RTCx) != ERROR) |
<> | 161:2cc1468da177 | 424 | { |
<> | 161:2cc1468da177 | 425 | /* Check the input parameters format */ |
<> | 161:2cc1468da177 | 426 | if (RTC_Format != LL_RTC_FORMAT_BIN) |
<> | 161:2cc1468da177 | 427 | { |
<> | 161:2cc1468da177 | 428 | LL_RTC_DATE_Config(RTCx, RTC_DateStruct->WeekDay, RTC_DateStruct->Day, RTC_DateStruct->Month, RTC_DateStruct->Year); |
<> | 161:2cc1468da177 | 429 | } |
<> | 161:2cc1468da177 | 430 | else |
<> | 161:2cc1468da177 | 431 | { |
<> | 161:2cc1468da177 | 432 | LL_RTC_DATE_Config(RTCx, RTC_DateStruct->WeekDay, __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->Day), |
<> | 161:2cc1468da177 | 433 | __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->Month), __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->Year)); |
<> | 161:2cc1468da177 | 434 | } |
<> | 161:2cc1468da177 | 435 | |
<> | 161:2cc1468da177 | 436 | /* Exit Initialization mode */ |
<> | 161:2cc1468da177 | 437 | LL_RTC_DisableInitMode(RTC); |
<> | 161:2cc1468da177 | 438 | |
<> | 161:2cc1468da177 | 439 | /* If RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */ |
<> | 161:2cc1468da177 | 440 | if (LL_RTC_IsShadowRegBypassEnabled(RTCx) == 0U) |
<> | 161:2cc1468da177 | 441 | { |
<> | 161:2cc1468da177 | 442 | status = LL_RTC_WaitForSynchro(RTCx); |
<> | 161:2cc1468da177 | 443 | } |
<> | 161:2cc1468da177 | 444 | else |
<> | 161:2cc1468da177 | 445 | { |
<> | 161:2cc1468da177 | 446 | status = SUCCESS; |
<> | 161:2cc1468da177 | 447 | } |
<> | 161:2cc1468da177 | 448 | } |
<> | 161:2cc1468da177 | 449 | /* Enable the write protection for RTC registers */ |
<> | 161:2cc1468da177 | 450 | LL_RTC_EnableWriteProtection(RTCx); |
<> | 161:2cc1468da177 | 451 | |
<> | 161:2cc1468da177 | 452 | return status; |
<> | 161:2cc1468da177 | 453 | } |
<> | 161:2cc1468da177 | 454 | |
<> | 161:2cc1468da177 | 455 | /** |
<> | 161:2cc1468da177 | 456 | * @brief Set each @ref LL_RTC_DateTypeDef field to default value (date = Monday, January 01 xx00) |
<> | 161:2cc1468da177 | 457 | * @param RTC_DateStruct pointer to a @ref LL_RTC_DateTypeDef structure which will be initialized. |
<> | 161:2cc1468da177 | 458 | * @retval None |
<> | 161:2cc1468da177 | 459 | */ |
<> | 161:2cc1468da177 | 460 | void LL_RTC_DATE_StructInit(LL_RTC_DateTypeDef *RTC_DateStruct) |
<> | 161:2cc1468da177 | 461 | { |
<> | 161:2cc1468da177 | 462 | /* Monday, January 01 xx00 */ |
<> | 161:2cc1468da177 | 463 | RTC_DateStruct->WeekDay = LL_RTC_WEEKDAY_MONDAY; |
<> | 161:2cc1468da177 | 464 | RTC_DateStruct->Day = 1U; |
<> | 161:2cc1468da177 | 465 | RTC_DateStruct->Month = LL_RTC_MONTH_JANUARY; |
<> | 161:2cc1468da177 | 466 | RTC_DateStruct->Year = 0U; |
<> | 161:2cc1468da177 | 467 | } |
<> | 161:2cc1468da177 | 468 | |
<> | 161:2cc1468da177 | 469 | /** |
<> | 161:2cc1468da177 | 470 | * @brief Set the RTC Alarm A. |
<> | 161:2cc1468da177 | 471 | * @note The Alarm register can only be written when the corresponding Alarm |
<> | 161:2cc1468da177 | 472 | * is disabled (Use @ref LL_RTC_ALMA_Disable function). |
<> | 161:2cc1468da177 | 473 | * @param RTCx RTC Instance |
<> | 161:2cc1468da177 | 474 | * @param RTC_Format This parameter can be one of the following values: |
<> | 161:2cc1468da177 | 475 | * @arg @ref LL_RTC_FORMAT_BIN |
<> | 161:2cc1468da177 | 476 | * @arg @ref LL_RTC_FORMAT_BCD |
<> | 161:2cc1468da177 | 477 | * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure that |
<> | 161:2cc1468da177 | 478 | * contains the alarm configuration parameters. |
<> | 161:2cc1468da177 | 479 | * @retval An ErrorStatus enumeration value: |
<> | 161:2cc1468da177 | 480 | * - SUCCESS: ALARMA registers are configured |
<> | 161:2cc1468da177 | 481 | * - ERROR: ALARMA registers are not configured |
<> | 161:2cc1468da177 | 482 | */ |
<> | 161:2cc1468da177 | 483 | ErrorStatus LL_RTC_ALMA_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct) |
<> | 161:2cc1468da177 | 484 | { |
<> | 161:2cc1468da177 | 485 | /* Check the parameters */ |
<> | 161:2cc1468da177 | 486 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
<> | 161:2cc1468da177 | 487 | assert_param(IS_LL_RTC_FORMAT(RTC_Format)); |
<> | 161:2cc1468da177 | 488 | assert_param(IS_LL_RTC_ALMA_MASK(RTC_AlarmStruct->AlarmMask)); |
<> | 161:2cc1468da177 | 489 | assert_param(IS_LL_RTC_ALMA_DATE_WEEKDAY_SEL(RTC_AlarmStruct->AlarmDateWeekDaySel)); |
<> | 161:2cc1468da177 | 490 | |
<> | 161:2cc1468da177 | 491 | if (RTC_Format == LL_RTC_FORMAT_BIN) |
<> | 161:2cc1468da177 | 492 | { |
<> | 161:2cc1468da177 | 493 | if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) |
<> | 161:2cc1468da177 | 494 | { |
<> | 161:2cc1468da177 | 495 | assert_param(IS_LL_RTC_HOUR12(RTC_AlarmStruct->AlarmTime.Hours)); |
<> | 161:2cc1468da177 | 496 | assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat)); |
<> | 161:2cc1468da177 | 497 | } |
<> | 161:2cc1468da177 | 498 | else |
<> | 161:2cc1468da177 | 499 | { |
<> | 161:2cc1468da177 | 500 | RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U; |
<> | 161:2cc1468da177 | 501 | assert_param(IS_LL_RTC_HOUR24(RTC_AlarmStruct->AlarmTime.Hours)); |
<> | 161:2cc1468da177 | 502 | } |
<> | 161:2cc1468da177 | 503 | assert_param(IS_LL_RTC_MINUTES(RTC_AlarmStruct->AlarmTime.Minutes)); |
<> | 161:2cc1468da177 | 504 | assert_param(IS_LL_RTC_SECONDS(RTC_AlarmStruct->AlarmTime.Seconds)); |
<> | 161:2cc1468da177 | 505 | |
<> | 161:2cc1468da177 | 506 | if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE) |
<> | 161:2cc1468da177 | 507 | { |
<> | 161:2cc1468da177 | 508 | assert_param(IS_LL_RTC_DAY(RTC_AlarmStruct->AlarmDateWeekDay)); |
<> | 161:2cc1468da177 | 509 | } |
<> | 161:2cc1468da177 | 510 | else |
<> | 161:2cc1468da177 | 511 | { |
<> | 161:2cc1468da177 | 512 | assert_param(IS_LL_RTC_WEEKDAY(RTC_AlarmStruct->AlarmDateWeekDay)); |
<> | 161:2cc1468da177 | 513 | } |
<> | 161:2cc1468da177 | 514 | } |
<> | 161:2cc1468da177 | 515 | else |
<> | 161:2cc1468da177 | 516 | { |
<> | 161:2cc1468da177 | 517 | if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) |
<> | 161:2cc1468da177 | 518 | { |
<> | 161:2cc1468da177 | 519 | assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours))); |
<> | 161:2cc1468da177 | 520 | assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat)); |
<> | 161:2cc1468da177 | 521 | } |
<> | 161:2cc1468da177 | 522 | else |
<> | 161:2cc1468da177 | 523 | { |
<> | 161:2cc1468da177 | 524 | RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U; |
<> | 161:2cc1468da177 | 525 | assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours))); |
<> | 161:2cc1468da177 | 526 | } |
<> | 161:2cc1468da177 | 527 | |
<> | 161:2cc1468da177 | 528 | assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Minutes))); |
<> | 161:2cc1468da177 | 529 | assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Seconds))); |
<> | 161:2cc1468da177 | 530 | |
<> | 161:2cc1468da177 | 531 | if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE) |
<> | 161:2cc1468da177 | 532 | { |
<> | 161:2cc1468da177 | 533 | assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay))); |
<> | 161:2cc1468da177 | 534 | } |
<> | 161:2cc1468da177 | 535 | else |
<> | 161:2cc1468da177 | 536 | { |
<> | 161:2cc1468da177 | 537 | assert_param(IS_LL_RTC_WEEKDAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay))); |
<> | 161:2cc1468da177 | 538 | } |
<> | 161:2cc1468da177 | 539 | } |
<> | 161:2cc1468da177 | 540 | |
<> | 161:2cc1468da177 | 541 | /* Disable the write protection for RTC registers */ |
<> | 161:2cc1468da177 | 542 | LL_RTC_DisableWriteProtection(RTCx); |
<> | 161:2cc1468da177 | 543 | |
<> | 161:2cc1468da177 | 544 | /* Select weekday selection */ |
<> | 161:2cc1468da177 | 545 | if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE) |
<> | 161:2cc1468da177 | 546 | { |
<> | 161:2cc1468da177 | 547 | /* Set the date for ALARM */ |
<> | 161:2cc1468da177 | 548 | LL_RTC_ALMA_DisableWeekday(RTCx); |
<> | 161:2cc1468da177 | 549 | if (RTC_Format != LL_RTC_FORMAT_BIN) |
<> | 161:2cc1468da177 | 550 | { |
<> | 161:2cc1468da177 | 551 | LL_RTC_ALMA_SetDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay); |
<> | 161:2cc1468da177 | 552 | } |
<> | 161:2cc1468da177 | 553 | else |
<> | 161:2cc1468da177 | 554 | { |
<> | 161:2cc1468da177 | 555 | LL_RTC_ALMA_SetDay(RTCx, __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmDateWeekDay)); |
<> | 161:2cc1468da177 | 556 | } |
<> | 161:2cc1468da177 | 557 | } |
<> | 161:2cc1468da177 | 558 | else |
<> | 161:2cc1468da177 | 559 | { |
<> | 161:2cc1468da177 | 560 | /* Set the week day for ALARM */ |
<> | 161:2cc1468da177 | 561 | LL_RTC_ALMA_EnableWeekday(RTCx); |
<> | 161:2cc1468da177 | 562 | LL_RTC_ALMA_SetWeekDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay); |
<> | 161:2cc1468da177 | 563 | } |
<> | 161:2cc1468da177 | 564 | |
<> | 161:2cc1468da177 | 565 | /* Configure the Alarm register */ |
<> | 161:2cc1468da177 | 566 | if (RTC_Format != LL_RTC_FORMAT_BIN) |
<> | 161:2cc1468da177 | 567 | { |
<> | 161:2cc1468da177 | 568 | LL_RTC_ALMA_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, RTC_AlarmStruct->AlarmTime.Hours, |
<> | 161:2cc1468da177 | 569 | RTC_AlarmStruct->AlarmTime.Minutes, RTC_AlarmStruct->AlarmTime.Seconds); |
<> | 161:2cc1468da177 | 570 | } |
<> | 161:2cc1468da177 | 571 | else |
<> | 161:2cc1468da177 | 572 | { |
<> | 161:2cc1468da177 | 573 | LL_RTC_ALMA_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, |
<> | 161:2cc1468da177 | 574 | __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Hours), |
<> | 161:2cc1468da177 | 575 | __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Minutes), |
<> | 161:2cc1468da177 | 576 | __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Seconds)); |
<> | 161:2cc1468da177 | 577 | } |
<> | 161:2cc1468da177 | 578 | /* Set ALARM mask */ |
<> | 161:2cc1468da177 | 579 | LL_RTC_ALMA_SetMask(RTCx, RTC_AlarmStruct->AlarmMask); |
<> | 161:2cc1468da177 | 580 | |
<> | 161:2cc1468da177 | 581 | /* Enable the write protection for RTC registers */ |
<> | 161:2cc1468da177 | 582 | LL_RTC_EnableWriteProtection(RTCx); |
<> | 161:2cc1468da177 | 583 | |
<> | 161:2cc1468da177 | 584 | return SUCCESS; |
<> | 161:2cc1468da177 | 585 | } |
<> | 161:2cc1468da177 | 586 | |
<> | 161:2cc1468da177 | 587 | /** |
<> | 161:2cc1468da177 | 588 | * @brief Set the RTC Alarm B. |
<> | 161:2cc1468da177 | 589 | * @note The Alarm register can only be written when the corresponding Alarm |
<> | 161:2cc1468da177 | 590 | * is disabled (@ref LL_RTC_ALMB_Disable function). |
<> | 161:2cc1468da177 | 591 | * @param RTCx RTC Instance |
<> | 161:2cc1468da177 | 592 | * @param RTC_Format This parameter can be one of the following values: |
<> | 161:2cc1468da177 | 593 | * @arg @ref LL_RTC_FORMAT_BIN |
<> | 161:2cc1468da177 | 594 | * @arg @ref LL_RTC_FORMAT_BCD |
<> | 161:2cc1468da177 | 595 | * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure that |
<> | 161:2cc1468da177 | 596 | * contains the alarm configuration parameters. |
<> | 161:2cc1468da177 | 597 | * @retval An ErrorStatus enumeration value: |
<> | 161:2cc1468da177 | 598 | * - SUCCESS: ALARMB registers are configured |
<> | 161:2cc1468da177 | 599 | * - ERROR: ALARMB registers are not configured |
<> | 161:2cc1468da177 | 600 | */ |
<> | 161:2cc1468da177 | 601 | ErrorStatus LL_RTC_ALMB_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct) |
<> | 161:2cc1468da177 | 602 | { |
<> | 161:2cc1468da177 | 603 | /* Check the parameters */ |
<> | 161:2cc1468da177 | 604 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
<> | 161:2cc1468da177 | 605 | assert_param(IS_LL_RTC_FORMAT(RTC_Format)); |
<> | 161:2cc1468da177 | 606 | assert_param(IS_LL_RTC_ALMB_MASK(RTC_AlarmStruct->AlarmMask)); |
<> | 161:2cc1468da177 | 607 | assert_param(IS_LL_RTC_ALMB_DATE_WEEKDAY_SEL(RTC_AlarmStruct->AlarmDateWeekDaySel)); |
<> | 161:2cc1468da177 | 608 | |
<> | 161:2cc1468da177 | 609 | if (RTC_Format == LL_RTC_FORMAT_BIN) |
<> | 161:2cc1468da177 | 610 | { |
<> | 161:2cc1468da177 | 611 | if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) |
<> | 161:2cc1468da177 | 612 | { |
<> | 161:2cc1468da177 | 613 | assert_param(IS_LL_RTC_HOUR12(RTC_AlarmStruct->AlarmTime.Hours)); |
<> | 161:2cc1468da177 | 614 | assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat)); |
<> | 161:2cc1468da177 | 615 | } |
<> | 161:2cc1468da177 | 616 | else |
<> | 161:2cc1468da177 | 617 | { |
<> | 161:2cc1468da177 | 618 | RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U; |
<> | 161:2cc1468da177 | 619 | assert_param(IS_LL_RTC_HOUR24(RTC_AlarmStruct->AlarmTime.Hours)); |
<> | 161:2cc1468da177 | 620 | } |
<> | 161:2cc1468da177 | 621 | assert_param(IS_LL_RTC_MINUTES(RTC_AlarmStruct->AlarmTime.Minutes)); |
<> | 161:2cc1468da177 | 622 | assert_param(IS_LL_RTC_SECONDS(RTC_AlarmStruct->AlarmTime.Seconds)); |
<> | 161:2cc1468da177 | 623 | |
<> | 161:2cc1468da177 | 624 | if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE) |
<> | 161:2cc1468da177 | 625 | { |
<> | 161:2cc1468da177 | 626 | assert_param(IS_LL_RTC_DAY(RTC_AlarmStruct->AlarmDateWeekDay)); |
<> | 161:2cc1468da177 | 627 | } |
<> | 161:2cc1468da177 | 628 | else |
<> | 161:2cc1468da177 | 629 | { |
<> | 161:2cc1468da177 | 630 | assert_param(IS_LL_RTC_WEEKDAY(RTC_AlarmStruct->AlarmDateWeekDay)); |
<> | 161:2cc1468da177 | 631 | } |
<> | 161:2cc1468da177 | 632 | } |
<> | 161:2cc1468da177 | 633 | else |
<> | 161:2cc1468da177 | 634 | { |
<> | 161:2cc1468da177 | 635 | if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) |
<> | 161:2cc1468da177 | 636 | { |
<> | 161:2cc1468da177 | 637 | assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours))); |
<> | 161:2cc1468da177 | 638 | assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat)); |
<> | 161:2cc1468da177 | 639 | } |
<> | 161:2cc1468da177 | 640 | else |
<> | 161:2cc1468da177 | 641 | { |
<> | 161:2cc1468da177 | 642 | RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U; |
<> | 161:2cc1468da177 | 643 | assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours))); |
<> | 161:2cc1468da177 | 644 | } |
<> | 161:2cc1468da177 | 645 | |
<> | 161:2cc1468da177 | 646 | assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Minutes))); |
<> | 161:2cc1468da177 | 647 | assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Seconds))); |
<> | 161:2cc1468da177 | 648 | |
<> | 161:2cc1468da177 | 649 | if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE) |
<> | 161:2cc1468da177 | 650 | { |
<> | 161:2cc1468da177 | 651 | assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay))); |
<> | 161:2cc1468da177 | 652 | } |
<> | 161:2cc1468da177 | 653 | else |
<> | 161:2cc1468da177 | 654 | { |
<> | 161:2cc1468da177 | 655 | assert_param(IS_LL_RTC_WEEKDAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay))); |
<> | 161:2cc1468da177 | 656 | } |
<> | 161:2cc1468da177 | 657 | } |
<> | 161:2cc1468da177 | 658 | |
<> | 161:2cc1468da177 | 659 | /* Disable the write protection for RTC registers */ |
<> | 161:2cc1468da177 | 660 | LL_RTC_DisableWriteProtection(RTCx); |
<> | 161:2cc1468da177 | 661 | |
<> | 161:2cc1468da177 | 662 | /* Select weekday selection */ |
<> | 161:2cc1468da177 | 663 | if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE) |
<> | 161:2cc1468da177 | 664 | { |
<> | 161:2cc1468da177 | 665 | /* Set the date for ALARM */ |
<> | 161:2cc1468da177 | 666 | LL_RTC_ALMB_DisableWeekday(RTCx); |
<> | 161:2cc1468da177 | 667 | if (RTC_Format != LL_RTC_FORMAT_BIN) |
<> | 161:2cc1468da177 | 668 | { |
<> | 161:2cc1468da177 | 669 | LL_RTC_ALMB_SetDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay); |
<> | 161:2cc1468da177 | 670 | } |
<> | 161:2cc1468da177 | 671 | else |
<> | 161:2cc1468da177 | 672 | { |
<> | 161:2cc1468da177 | 673 | LL_RTC_ALMB_SetDay(RTCx, __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmDateWeekDay)); |
<> | 161:2cc1468da177 | 674 | } |
<> | 161:2cc1468da177 | 675 | } |
<> | 161:2cc1468da177 | 676 | else |
<> | 161:2cc1468da177 | 677 | { |
<> | 161:2cc1468da177 | 678 | /* Set the week day for ALARM */ |
<> | 161:2cc1468da177 | 679 | LL_RTC_ALMB_EnableWeekday(RTCx); |
<> | 161:2cc1468da177 | 680 | LL_RTC_ALMB_SetWeekDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay); |
<> | 161:2cc1468da177 | 681 | } |
<> | 161:2cc1468da177 | 682 | |
<> | 161:2cc1468da177 | 683 | /* Configure the Alarm register */ |
<> | 161:2cc1468da177 | 684 | if (RTC_Format != LL_RTC_FORMAT_BIN) |
<> | 161:2cc1468da177 | 685 | { |
<> | 161:2cc1468da177 | 686 | LL_RTC_ALMB_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, RTC_AlarmStruct->AlarmTime.Hours, |
<> | 161:2cc1468da177 | 687 | RTC_AlarmStruct->AlarmTime.Minutes, RTC_AlarmStruct->AlarmTime.Seconds); |
<> | 161:2cc1468da177 | 688 | } |
<> | 161:2cc1468da177 | 689 | else |
<> | 161:2cc1468da177 | 690 | { |
<> | 161:2cc1468da177 | 691 | LL_RTC_ALMB_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, |
<> | 161:2cc1468da177 | 692 | __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Hours), |
<> | 161:2cc1468da177 | 693 | __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Minutes), |
<> | 161:2cc1468da177 | 694 | __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Seconds)); |
<> | 161:2cc1468da177 | 695 | } |
<> | 161:2cc1468da177 | 696 | /* Set ALARM mask */ |
<> | 161:2cc1468da177 | 697 | LL_RTC_ALMB_SetMask(RTCx, RTC_AlarmStruct->AlarmMask); |
<> | 161:2cc1468da177 | 698 | |
<> | 161:2cc1468da177 | 699 | /* Enable the write protection for RTC registers */ |
<> | 161:2cc1468da177 | 700 | LL_RTC_EnableWriteProtection(RTCx); |
<> | 161:2cc1468da177 | 701 | |
<> | 161:2cc1468da177 | 702 | return SUCCESS; |
<> | 161:2cc1468da177 | 703 | } |
<> | 161:2cc1468da177 | 704 | |
<> | 161:2cc1468da177 | 705 | /** |
<> | 161:2cc1468da177 | 706 | * @brief Set each @ref LL_RTC_AlarmTypeDef of ALARMA field to default value (Time = 00h:00mn:00sec / |
<> | 161:2cc1468da177 | 707 | * Day = 1st day of the month/Mask = all fields are masked). |
<> | 161:2cc1468da177 | 708 | * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure which will be initialized. |
<> | 161:2cc1468da177 | 709 | * @retval None |
<> | 161:2cc1468da177 | 710 | */ |
<> | 161:2cc1468da177 | 711 | void LL_RTC_ALMA_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct) |
<> | 161:2cc1468da177 | 712 | { |
<> | 161:2cc1468da177 | 713 | /* Alarm Time Settings : Time = 00h:00mn:00sec */ |
<> | 161:2cc1468da177 | 714 | RTC_AlarmStruct->AlarmTime.TimeFormat = LL_RTC_ALMA_TIME_FORMAT_AM; |
<> | 161:2cc1468da177 | 715 | RTC_AlarmStruct->AlarmTime.Hours = 0U; |
<> | 161:2cc1468da177 | 716 | RTC_AlarmStruct->AlarmTime.Minutes = 0U; |
<> | 161:2cc1468da177 | 717 | RTC_AlarmStruct->AlarmTime.Seconds = 0U; |
<> | 161:2cc1468da177 | 718 | |
<> | 161:2cc1468da177 | 719 | /* Alarm Day Settings : Day = 1st day of the month */ |
<> | 161:2cc1468da177 | 720 | RTC_AlarmStruct->AlarmDateWeekDaySel = LL_RTC_ALMA_DATEWEEKDAYSEL_DATE; |
<> | 161:2cc1468da177 | 721 | RTC_AlarmStruct->AlarmDateWeekDay = 1U; |
<> | 161:2cc1468da177 | 722 | |
<> | 161:2cc1468da177 | 723 | /* Alarm Masks Settings : Mask = all fields are not masked */ |
<> | 161:2cc1468da177 | 724 | RTC_AlarmStruct->AlarmMask = LL_RTC_ALMA_MASK_NONE; |
<> | 161:2cc1468da177 | 725 | } |
<> | 161:2cc1468da177 | 726 | |
<> | 161:2cc1468da177 | 727 | /** |
<> | 161:2cc1468da177 | 728 | * @brief Set each @ref LL_RTC_AlarmTypeDef of ALARMA field to default value (Time = 00h:00mn:00sec / |
<> | 161:2cc1468da177 | 729 | * Day = 1st day of the month/Mask = all fields are masked). |
<> | 161:2cc1468da177 | 730 | * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure which will be initialized. |
<> | 161:2cc1468da177 | 731 | * @retval None |
<> | 161:2cc1468da177 | 732 | */ |
<> | 161:2cc1468da177 | 733 | void LL_RTC_ALMB_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct) |
<> | 161:2cc1468da177 | 734 | { |
<> | 161:2cc1468da177 | 735 | /* Alarm Time Settings : Time = 00h:00mn:00sec */ |
<> | 161:2cc1468da177 | 736 | RTC_AlarmStruct->AlarmTime.TimeFormat = LL_RTC_ALMB_TIME_FORMAT_AM; |
<> | 161:2cc1468da177 | 737 | RTC_AlarmStruct->AlarmTime.Hours = 0U; |
<> | 161:2cc1468da177 | 738 | RTC_AlarmStruct->AlarmTime.Minutes = 0U; |
<> | 161:2cc1468da177 | 739 | RTC_AlarmStruct->AlarmTime.Seconds = 0U; |
<> | 161:2cc1468da177 | 740 | |
<> | 161:2cc1468da177 | 741 | /* Alarm Day Settings : Day = 1st day of the month */ |
<> | 161:2cc1468da177 | 742 | RTC_AlarmStruct->AlarmDateWeekDaySel = LL_RTC_ALMB_DATEWEEKDAYSEL_DATE; |
<> | 161:2cc1468da177 | 743 | RTC_AlarmStruct->AlarmDateWeekDay = 1U; |
<> | 161:2cc1468da177 | 744 | |
<> | 161:2cc1468da177 | 745 | /* Alarm Masks Settings : Mask = all fields are not masked */ |
<> | 161:2cc1468da177 | 746 | RTC_AlarmStruct->AlarmMask = LL_RTC_ALMB_MASK_NONE; |
<> | 161:2cc1468da177 | 747 | } |
<> | 161:2cc1468da177 | 748 | |
<> | 161:2cc1468da177 | 749 | /** |
<> | 161:2cc1468da177 | 750 | * @brief Enters the RTC Initialization mode. |
<> | 161:2cc1468da177 | 751 | * @note The RTC Initialization mode is write protected, use the |
<> | 161:2cc1468da177 | 752 | * @ref LL_RTC_DisableWriteProtection before calling this function. |
<> | 161:2cc1468da177 | 753 | * @param RTCx RTC Instance |
<> | 161:2cc1468da177 | 754 | * @retval An ErrorStatus enumeration value: |
<> | 161:2cc1468da177 | 755 | * - SUCCESS: RTC is in Init mode |
<> | 161:2cc1468da177 | 756 | * - ERROR: RTC is not in Init mode |
<> | 161:2cc1468da177 | 757 | */ |
<> | 161:2cc1468da177 | 758 | ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx) |
<> | 161:2cc1468da177 | 759 | { |
<> | 161:2cc1468da177 | 760 | __IO uint32_t timeout = RTC_INITMODE_TIMEOUT; |
<> | 161:2cc1468da177 | 761 | ErrorStatus status = SUCCESS; |
<> | 161:2cc1468da177 | 762 | uint32_t tmp = 0U; |
<> | 161:2cc1468da177 | 763 | |
<> | 161:2cc1468da177 | 764 | /* Check the parameter */ |
<> | 161:2cc1468da177 | 765 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
<> | 161:2cc1468da177 | 766 | |
<> | 161:2cc1468da177 | 767 | /* Check if the Initialization mode is set */ |
<> | 161:2cc1468da177 | 768 | if (LL_RTC_IsActiveFlag_INIT(RTCx) == 0U) |
<> | 161:2cc1468da177 | 769 | { |
<> | 161:2cc1468da177 | 770 | /* Set the Initialization mode */ |
<> | 161:2cc1468da177 | 771 | LL_RTC_EnableInitMode(RTCx); |
<> | 161:2cc1468da177 | 772 | |
<> | 161:2cc1468da177 | 773 | /* Wait till RTC is in INIT state and if Time out is reached exit */ |
<> | 161:2cc1468da177 | 774 | tmp = LL_RTC_IsActiveFlag_INIT(RTCx); |
<> | 161:2cc1468da177 | 775 | while ((timeout != 0U) && (tmp != 1U)) |
<> | 161:2cc1468da177 | 776 | { |
<> | 161:2cc1468da177 | 777 | if (LL_SYSTICK_IsActiveCounterFlag() == 1U) |
<> | 161:2cc1468da177 | 778 | { |
<> | 161:2cc1468da177 | 779 | timeout --; |
<> | 161:2cc1468da177 | 780 | } |
<> | 161:2cc1468da177 | 781 | tmp = LL_RTC_IsActiveFlag_INIT(RTCx); |
<> | 161:2cc1468da177 | 782 | if (timeout == 0U) |
<> | 161:2cc1468da177 | 783 | { |
<> | 161:2cc1468da177 | 784 | status = ERROR; |
<> | 161:2cc1468da177 | 785 | } |
<> | 161:2cc1468da177 | 786 | } |
<> | 161:2cc1468da177 | 787 | } |
<> | 161:2cc1468da177 | 788 | return status; |
<> | 161:2cc1468da177 | 789 | } |
<> | 161:2cc1468da177 | 790 | |
<> | 161:2cc1468da177 | 791 | /** |
<> | 161:2cc1468da177 | 792 | * @brief Exit the RTC Initialization mode. |
<> | 161:2cc1468da177 | 793 | * @note When the initialization sequence is complete, the calendar restarts |
<> | 161:2cc1468da177 | 794 | * counting after 4 RTCCLK cycles. |
<> | 161:2cc1468da177 | 795 | * @note The RTC Initialization mode is write protected, use the |
<> | 161:2cc1468da177 | 796 | * @ref LL_RTC_DisableWriteProtection before calling this function. |
<> | 161:2cc1468da177 | 797 | * @param RTCx RTC Instance |
<> | 161:2cc1468da177 | 798 | * @retval An ErrorStatus enumeration value: |
<> | 161:2cc1468da177 | 799 | * - SUCCESS: RTC exited from in Init mode |
<> | 161:2cc1468da177 | 800 | * - ERROR: Not applicable |
<> | 161:2cc1468da177 | 801 | */ |
<> | 161:2cc1468da177 | 802 | ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx) |
<> | 161:2cc1468da177 | 803 | { |
<> | 161:2cc1468da177 | 804 | /* Check the parameter */ |
<> | 161:2cc1468da177 | 805 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
<> | 161:2cc1468da177 | 806 | |
<> | 161:2cc1468da177 | 807 | /* Disable initialization mode */ |
<> | 161:2cc1468da177 | 808 | LL_RTC_DisableInitMode(RTCx); |
<> | 161:2cc1468da177 | 809 | |
<> | 161:2cc1468da177 | 810 | return SUCCESS; |
<> | 161:2cc1468da177 | 811 | } |
<> | 161:2cc1468da177 | 812 | |
<> | 161:2cc1468da177 | 813 | /** |
<> | 161:2cc1468da177 | 814 | * @brief Waits until the RTC Time and Day registers (RTC_TR and RTC_DR) are |
<> | 161:2cc1468da177 | 815 | * synchronized with RTC APB clock. |
<> | 161:2cc1468da177 | 816 | * @note The RTC Resynchronization mode is write protected, use the |
<> | 161:2cc1468da177 | 817 | * @ref LL_RTC_DisableWriteProtection before calling this function. |
<> | 161:2cc1468da177 | 818 | * @note To read the calendar through the shadow registers after Calendar |
<> | 161:2cc1468da177 | 819 | * initialization, calendar update or after wakeup from low power modes |
<> | 161:2cc1468da177 | 820 | * the software must first clear the RSF flag. |
<> | 161:2cc1468da177 | 821 | * The software must then wait until it is set again before reading |
<> | 161:2cc1468da177 | 822 | * the calendar, which means that the calendar registers have been |
<> | 161:2cc1468da177 | 823 | * correctly copied into the RTC_TR and RTC_DR shadow registers. |
<> | 161:2cc1468da177 | 824 | * @param RTCx RTC Instance |
<> | 161:2cc1468da177 | 825 | * @retval An ErrorStatus enumeration value: |
<> | 161:2cc1468da177 | 826 | * - SUCCESS: RTC registers are synchronised |
<> | 161:2cc1468da177 | 827 | * - ERROR: RTC registers are not synchronised |
<> | 161:2cc1468da177 | 828 | */ |
<> | 161:2cc1468da177 | 829 | ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx) |
<> | 161:2cc1468da177 | 830 | { |
<> | 161:2cc1468da177 | 831 | __IO uint32_t timeout = RTC_SYNCHRO_TIMEOUT; |
<> | 161:2cc1468da177 | 832 | ErrorStatus status = SUCCESS; |
<> | 161:2cc1468da177 | 833 | uint32_t tmp = 0U; |
<> | 161:2cc1468da177 | 834 | |
<> | 161:2cc1468da177 | 835 | /* Check the parameter */ |
<> | 161:2cc1468da177 | 836 | assert_param(IS_RTC_ALL_INSTANCE(RTCx)); |
<> | 161:2cc1468da177 | 837 | |
<> | 161:2cc1468da177 | 838 | /* Clear RSF flag */ |
<> | 161:2cc1468da177 | 839 | LL_RTC_ClearFlag_RS(RTCx); |
<> | 161:2cc1468da177 | 840 | |
<> | 161:2cc1468da177 | 841 | /* Wait the registers to be synchronised */ |
<> | 161:2cc1468da177 | 842 | tmp = LL_RTC_IsActiveFlag_RS(RTCx); |
<> | 161:2cc1468da177 | 843 | while ((timeout != 0U) && (tmp != 0U)) |
<> | 161:2cc1468da177 | 844 | { |
<> | 161:2cc1468da177 | 845 | if (LL_SYSTICK_IsActiveCounterFlag() == 1U) |
<> | 161:2cc1468da177 | 846 | { |
<> | 161:2cc1468da177 | 847 | timeout--; |
<> | 161:2cc1468da177 | 848 | } |
<> | 161:2cc1468da177 | 849 | tmp = LL_RTC_IsActiveFlag_RS(RTCx); |
<> | 161:2cc1468da177 | 850 | if (timeout == 0U) |
<> | 161:2cc1468da177 | 851 | { |
<> | 161:2cc1468da177 | 852 | status = ERROR; |
<> | 161:2cc1468da177 | 853 | } |
<> | 161:2cc1468da177 | 854 | } |
<> | 161:2cc1468da177 | 855 | |
<> | 161:2cc1468da177 | 856 | if (status != ERROR) |
<> | 161:2cc1468da177 | 857 | { |
<> | 161:2cc1468da177 | 858 | timeout = RTC_SYNCHRO_TIMEOUT; |
<> | 161:2cc1468da177 | 859 | tmp = LL_RTC_IsActiveFlag_RS(RTCx); |
<> | 161:2cc1468da177 | 860 | while ((timeout != 0U) && (tmp != 1U)) |
<> | 161:2cc1468da177 | 861 | { |
<> | 161:2cc1468da177 | 862 | if (LL_SYSTICK_IsActiveCounterFlag() == 1U) |
<> | 161:2cc1468da177 | 863 | { |
<> | 161:2cc1468da177 | 864 | timeout--; |
<> | 161:2cc1468da177 | 865 | } |
<> | 161:2cc1468da177 | 866 | tmp = LL_RTC_IsActiveFlag_RS(RTCx); |
<> | 161:2cc1468da177 | 867 | if (timeout == 0U) |
<> | 161:2cc1468da177 | 868 | { |
<> | 161:2cc1468da177 | 869 | status = ERROR; |
<> | 161:2cc1468da177 | 870 | } |
<> | 161:2cc1468da177 | 871 | } |
<> | 161:2cc1468da177 | 872 | } |
<> | 161:2cc1468da177 | 873 | |
<> | 161:2cc1468da177 | 874 | return (status); |
<> | 161:2cc1468da177 | 875 | } |
<> | 161:2cc1468da177 | 876 | |
<> | 161:2cc1468da177 | 877 | /** |
<> | 161:2cc1468da177 | 878 | * @} |
<> | 161:2cc1468da177 | 879 | */ |
<> | 161:2cc1468da177 | 880 | |
<> | 161:2cc1468da177 | 881 | /** |
<> | 161:2cc1468da177 | 882 | * @} |
<> | 161:2cc1468da177 | 883 | */ |
<> | 161:2cc1468da177 | 884 | |
<> | 161:2cc1468da177 | 885 | /** |
<> | 161:2cc1468da177 | 886 | * @} |
<> | 161:2cc1468da177 | 887 | */ |
<> | 161:2cc1468da177 | 888 | |
<> | 161:2cc1468da177 | 889 | #endif /* defined(RTC) */ |
<> | 161:2cc1468da177 | 890 | |
<> | 161:2cc1468da177 | 891 | /** |
<> | 161:2cc1468da177 | 892 | * @} |
<> | 161:2cc1468da177 | 893 | */ |
<> | 161:2cc1468da177 | 894 | |
<> | 161:2cc1468da177 | 895 | #endif /* USE_FULL_LL_DRIVER */ |
<> | 161:2cc1468da177 | 896 | |
<> | 161:2cc1468da177 | 897 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |