mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
Parent:
180:96ed750bd169
mbed library release version 165

Who changed what in which revision?

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