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