mbed library sources. Supersedes mbed-src.

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

Committer:
<>
Date:
Fri Oct 28 11:17:30 2016 +0100
Revision:
149:156823d33999
Child:
184:08ed48f1de7f
This updates the lib to the mbed lib v128

NOTE: This release includes a restructuring of the file and directory locations and thus some
include paths in your code may need updating accordingly.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 149:156823d33999 1 /**
<> 149:156823d33999 2 ******************************************************************************
<> 149:156823d33999 3 * @file stm32l1xx_hal_rtc_ex.c
<> 149:156823d33999 4 * @author MCD Application Team
<> 149:156823d33999 5 * @version V1.2.0
<> 149:156823d33999 6 * @date 01-July-2016
<> 149:156823d33999 7 * @brief Extended RTC HAL module driver.
<> 149:156823d33999 8 * This file provides firmware functions to manage the following
<> 149:156823d33999 9 * functionalities of the Real Time Clock (RTC) Extension peripheral:
<> 149:156823d33999 10 * + RTC Time Stamp functions
<> 149:156823d33999 11 * + RTC Tamper functions
<> 149:156823d33999 12 * + RTC Wake-up functions
<> 149:156823d33999 13 * + Extension Control functions
<> 149:156823d33999 14 * + Extension RTC features functions
<> 149:156823d33999 15 *
<> 149:156823d33999 16 @verbatim
<> 149:156823d33999 17 ==============================================================================
<> 149:156823d33999 18 ##### How to use this driver #####
<> 149:156823d33999 19 ==============================================================================
<> 149:156823d33999 20 [..]
<> 149:156823d33999 21 (+) Enable the RTC domain access.
<> 149:156823d33999 22 (+) Configure the RTC Prescaler (Asynchronous and Synchronous) and RTC hour
<> 149:156823d33999 23 format using the HAL_RTC_Init() function.
<> 149:156823d33999 24
<> 149:156823d33999 25 *** RTC Wakeup configuration ***
<> 149:156823d33999 26 ================================
<> 149:156823d33999 27 [..]
<> 149:156823d33999 28 (+) To configure the RTC Wakeup Clock source and Counter use the HAL_RTCEx_SetWakeUpTimer()
<> 149:156823d33999 29 function. You can also configure the RTC Wakeup timer with interrupt mode
<> 149:156823d33999 30 using the HAL_RTCEx_SetWakeUpTimer_IT() function.
<> 149:156823d33999 31 (+) To read the RTC WakeUp Counter register, use the HAL_RTCEx_GetWakeUpTimer()
<> 149:156823d33999 32 function.
<> 149:156823d33999 33
<> 149:156823d33999 34 *** TimeStamp configuration ***
<> 149:156823d33999 35 ===============================
<> 149:156823d33999 36 [..]
<> 149:156823d33999 37 (+) Configure the RTC_AFx trigger and enable the RTC TimeStamp using the
<> 149:156823d33999 38 HAL_RTCEx_SetTimeStamp() function. You can also configure the RTC TimeStamp with
<> 149:156823d33999 39 interrupt mode using the HAL_RTCEx_SetTimeStamp_IT() function.
<> 149:156823d33999 40 (+) To read the RTC TimeStamp Time and Date register, use the HAL_RTCEx_GetTimeStamp()
<> 149:156823d33999 41 function.
<> 149:156823d33999 42 (+) The TIMESTAMP alternate function can be mapped to RTC_AF1 (PC13).
<> 149:156823d33999 43
<> 149:156823d33999 44 *** Tamper configuration ***
<> 149:156823d33999 45 ============================
<> 149:156823d33999 46 [..]
<> 149:156823d33999 47 (+) Enable the RTC Tamper and configure the Tamper filter count, trigger Edge
<> 149:156823d33999 48 or Level according to the Tamper filter (if equal to 0 Edge else Level)
<> 149:156823d33999 49 value, sampling frequency, precharge or discharge and Pull-UP using the
<> 149:156823d33999 50 HAL_RTCEx_SetTamper() function. You can configure RTC Tamper with interrupt
<> 149:156823d33999 51 mode using HAL_RTCEx_SetTamper_IT() function.
<> 149:156823d33999 52 (+) The TAMPER1 alternate function can be mapped to RTC_AF1 (PC13).
<> 149:156823d33999 53
<> 149:156823d33999 54 *** Backup Data Registers configuration ***
<> 149:156823d33999 55 ===========================================
<> 149:156823d33999 56 [..]
<> 149:156823d33999 57 (+) To write to the RTC Backup Data registers, use the HAL_RTCEx_BKUPWrite()
<> 149:156823d33999 58 function.
<> 149:156823d33999 59 (+) To read the RTC Backup Data registers, use the HAL_RTCEx_BKUPRead()
<> 149:156823d33999 60 function.
<> 149:156823d33999 61
<> 149:156823d33999 62 @endverbatim
<> 149:156823d33999 63 ******************************************************************************
<> 149:156823d33999 64 * @attention
<> 149:156823d33999 65 *
<> 149:156823d33999 66 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
<> 149:156823d33999 67 *
<> 149:156823d33999 68 * Redistribution and use in source and binary forms, with or without modification,
<> 149:156823d33999 69 * are permitted provided that the following conditions are met:
<> 149:156823d33999 70 * 1. Redistributions of source code must retain the above copyright notice,
<> 149:156823d33999 71 * this list of conditions and the following disclaimer.
<> 149:156823d33999 72 * 2. Redistributions in binary form must reproduce the above copyright notice,
<> 149:156823d33999 73 * this list of conditions and the following disclaimer in the documentation
<> 149:156823d33999 74 * and/or other materials provided with the distribution.
<> 149:156823d33999 75 * 3. Neither the name of STMicroelectronics nor the names of its contributors
<> 149:156823d33999 76 * may be used to endorse or promote products derived from this software
<> 149:156823d33999 77 * without specific prior written permission.
<> 149:156823d33999 78 *
<> 149:156823d33999 79 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
<> 149:156823d33999 80 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
<> 149:156823d33999 81 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
<> 149:156823d33999 82 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
<> 149:156823d33999 83 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
<> 149:156823d33999 84 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
<> 149:156823d33999 85 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
<> 149:156823d33999 86 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
<> 149:156823d33999 87 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
<> 149:156823d33999 88 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<> 149:156823d33999 89 *
<> 149:156823d33999 90 ******************************************************************************
<> 149:156823d33999 91 */
<> 149:156823d33999 92
<> 149:156823d33999 93 /* Includes ------------------------------------------------------------------*/
<> 149:156823d33999 94 #include "stm32l1xx_hal.h"
<> 149:156823d33999 95
<> 149:156823d33999 96 /** @addtogroup STM32L1xx_HAL_Driver
<> 149:156823d33999 97 * @{
<> 149:156823d33999 98 */
<> 149:156823d33999 99
<> 149:156823d33999 100 /** @addtogroup RTC
<> 149:156823d33999 101 * @{
<> 149:156823d33999 102 */
<> 149:156823d33999 103
<> 149:156823d33999 104 #ifdef HAL_RTC_MODULE_ENABLED
<> 149:156823d33999 105
<> 149:156823d33999 106 /* Private typedef -----------------------------------------------------------*/
<> 149:156823d33999 107 /* Private define ------------------------------------------------------------*/
<> 149:156823d33999 108 /* Private macro -------------------------------------------------------------*/
<> 149:156823d33999 109 /* Private variables ---------------------------------------------------------*/
<> 149:156823d33999 110 /* Private function prototypes -----------------------------------------------*/
<> 149:156823d33999 111 /* Private functions ---------------------------------------------------------*/
<> 149:156823d33999 112
<> 149:156823d33999 113 /** @addtogroup RTC_Exported_Functions
<> 149:156823d33999 114 * @{
<> 149:156823d33999 115 */
<> 149:156823d33999 116
<> 149:156823d33999 117
<> 149:156823d33999 118 /** @addtogroup RTC_Exported_Functions_Group1
<> 149:156823d33999 119 * @{
<> 149:156823d33999 120 */
<> 149:156823d33999 121
<> 149:156823d33999 122 /**
<> 149:156823d33999 123 * @brief DeInitializes the RTC peripheral
<> 149:156823d33999 124 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 125 * the configuration information for RTC.
<> 149:156823d33999 126 * @note This function does not reset the RTC Backup Data registers.
<> 149:156823d33999 127 * @retval HAL status
<> 149:156823d33999 128 */
<> 149:156823d33999 129 HAL_StatusTypeDef HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc)
<> 149:156823d33999 130 {
<> 149:156823d33999 131 uint32_t tickstart = 0;
<> 149:156823d33999 132
<> 149:156823d33999 133 /* Check the parameters */
<> 149:156823d33999 134 assert_param(IS_RTC_ALL_INSTANCE(hrtc->Instance));
<> 149:156823d33999 135
<> 149:156823d33999 136 /* Set RTC state */
<> 149:156823d33999 137 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 138
<> 149:156823d33999 139 /* Disable the write protection for RTC registers */
<> 149:156823d33999 140 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
<> 149:156823d33999 141
<> 149:156823d33999 142 /* Set Initialization mode */
<> 149:156823d33999 143 if(RTC_EnterInitMode(hrtc) != HAL_OK)
<> 149:156823d33999 144 {
<> 149:156823d33999 145 /* Enable the write protection for RTC registers */
<> 149:156823d33999 146 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 147
<> 149:156823d33999 148 /* Set RTC state */
<> 149:156823d33999 149 hrtc->State = HAL_RTC_STATE_ERROR;
<> 149:156823d33999 150
<> 149:156823d33999 151 return HAL_ERROR;
<> 149:156823d33999 152 }
<> 149:156823d33999 153 else
<> 149:156823d33999 154 {
<> 149:156823d33999 155 /* Reset TR, DR and CR registers */
<> 149:156823d33999 156 hrtc->Instance->TR = (uint32_t)0x00000000;
<> 149:156823d33999 157 hrtc->Instance->DR = (uint32_t)0x00002101;
<> 149:156823d33999 158 /* Reset All CR bits except CR[2:0] */
<> 149:156823d33999 159 hrtc->Instance->CR &= (uint32_t)0x00000007;
<> 149:156823d33999 160
<> 149:156823d33999 161 tickstart = HAL_GetTick();
<> 149:156823d33999 162
<> 149:156823d33999 163 /* Wait till WUTWF flag is set and if Time out is reached exit */
<> 149:156823d33999 164 while(((hrtc->Instance->ISR) & RTC_ISR_WUTWF) == (uint32_t)RESET)
<> 149:156823d33999 165 {
<> 149:156823d33999 166 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
<> 149:156823d33999 167 {
<> 149:156823d33999 168 /* Enable the write protection for RTC registers */
<> 149:156823d33999 169 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 170
<> 149:156823d33999 171 /* Set RTC state */
<> 149:156823d33999 172 hrtc->State = HAL_RTC_STATE_TIMEOUT;
<> 149:156823d33999 173
<> 149:156823d33999 174 return HAL_TIMEOUT;
<> 149:156823d33999 175 }
<> 149:156823d33999 176 }
<> 149:156823d33999 177
<> 149:156823d33999 178 /* Reset all RTC CR register bits */
<> 149:156823d33999 179 hrtc->Instance->CR &= (uint32_t)0x00000000;
<> 149:156823d33999 180 hrtc->Instance->WUTR = (uint32_t)0x0000FFFF;
<> 149:156823d33999 181 hrtc->Instance->PRER = (uint32_t)0x007F00FF;
<> 149:156823d33999 182 hrtc->Instance->CALIBR = (uint32_t)0x00000000;
<> 149:156823d33999 183 hrtc->Instance->ALRMAR = (uint32_t)0x00000000;
<> 149:156823d33999 184 hrtc->Instance->ALRMBR = (uint32_t)0x00000000;
<> 149:156823d33999 185 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 186 hrtc->Instance->SHIFTR = (uint32_t)0x00000000;
<> 149:156823d33999 187 hrtc->Instance->CALR = (uint32_t)0x00000000;
<> 149:156823d33999 188 hrtc->Instance->ALRMASSR = (uint32_t)0x00000000;
<> 149:156823d33999 189 hrtc->Instance->ALRMBSSR = (uint32_t)0x00000000;
<> 149:156823d33999 190 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 191 /* Reset ISR register and exit initialization mode */
<> 149:156823d33999 192 hrtc->Instance->ISR = (uint32_t)0x00000000;
<> 149:156823d33999 193
<> 149:156823d33999 194 /* Reset Tamper and alternate functions configuration register */
<> 149:156823d33999 195 hrtc->Instance->TAFCR = 0x00000000;
<> 149:156823d33999 196
<> 149:156823d33999 197 /* Wait for synchro */
<> 149:156823d33999 198 if(HAL_RTC_WaitForSynchro(hrtc) != HAL_OK)
<> 149:156823d33999 199 {
<> 149:156823d33999 200 /* Enable the write protection for RTC registers */
<> 149:156823d33999 201 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 202
<> 149:156823d33999 203 hrtc->State = HAL_RTC_STATE_ERROR;
<> 149:156823d33999 204
<> 149:156823d33999 205 return HAL_ERROR;
<> 149:156823d33999 206 }
<> 149:156823d33999 207 }
<> 149:156823d33999 208
<> 149:156823d33999 209 /* Enable the write protection for RTC registers */
<> 149:156823d33999 210 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 211
<> 149:156823d33999 212 /* De-Initialize RTC MSP */
<> 149:156823d33999 213 HAL_RTC_MspDeInit(hrtc);
<> 149:156823d33999 214
<> 149:156823d33999 215 hrtc->State = HAL_RTC_STATE_RESET;
<> 149:156823d33999 216
<> 149:156823d33999 217 /* Release Lock */
<> 149:156823d33999 218 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 219
<> 149:156823d33999 220 return HAL_OK;
<> 149:156823d33999 221 }
<> 149:156823d33999 222
<> 149:156823d33999 223 /**
<> 149:156823d33999 224 * @}
<> 149:156823d33999 225 */
<> 149:156823d33999 226
<> 149:156823d33999 227 /** @addtogroup RTC_Exported_Functions_Group2
<> 149:156823d33999 228 * @{
<> 149:156823d33999 229 */
<> 149:156823d33999 230
<> 149:156823d33999 231 /**
<> 149:156823d33999 232 * @brief Get RTC current time.
<> 149:156823d33999 233 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 234 * the configuration information for RTC.
<> 149:156823d33999 235 * @param sTime: Pointer to Time structure with Hours, Minutes and Seconds fields returned
<> 149:156823d33999 236 * with input format (BIN or BCD), also SubSeconds field (if availabale) returning the
<> 149:156823d33999 237 * RTC_SSR register content and SecondFraction field the Synchronous pre-scaler
<> 149:156823d33999 238 * factor to be used for second fraction ratio computation.
<> 149:156823d33999 239 * @param Format: Specifies the format of the entered parameters.
<> 149:156823d33999 240 * This parameter can be one of the following values:
<> 149:156823d33999 241 * @arg RTC_FORMAT_BIN: Binary data format
<> 149:156823d33999 242 * @arg RTC_FORMAT_BCD: BCD data format
<> 149:156823d33999 243 * @note If available, you can use SubSeconds and SecondFraction (sTime structure fields returned) to convert SubSeconds
<> 149:156823d33999 244 * value in second fraction ratio with time unit following generic formula:
<> 149:156823d33999 245 * Second fraction ratio * time_unit= [(SecondFraction-SubSeconds)/(SecondFraction+1)] * time_unit
<> 149:156823d33999 246 * This conversion can be performed only if no shift operation is pending (ie. SHFP=0) when PREDIV_S >= SS
<> 149:156823d33999 247 * @note You must call HAL_RTC_GetDate() after HAL_RTC_GetTime() to unlock the values
<> 149:156823d33999 248 * in the higher-order calendar shadow registers to ensure consistency between the time and date values.
<> 149:156823d33999 249 * Reading RTC current time locks the values in calendar shadow registers until Current date is read
<> 149:156823d33999 250 * to ensure consistency between the time and date values.
<> 149:156823d33999 251 * @retval HAL status
<> 149:156823d33999 252 */
<> 149:156823d33999 253 HAL_StatusTypeDef HAL_RTC_GetTime(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTime, uint32_t Format)
<> 149:156823d33999 254 {
<> 149:156823d33999 255 uint32_t tmpreg = 0;
<> 149:156823d33999 256
<> 149:156823d33999 257 /* Check the parameters */
<> 149:156823d33999 258 assert_param(IS_RTC_FORMAT(Format));
<> 149:156823d33999 259
<> 149:156823d33999 260 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 261 /* Get subseconds structure field from the corresponding register*/
<> 149:156823d33999 262 sTime->SubSeconds = (uint32_t)((hrtc->Instance->SSR) & RTC_SSR_SS);
<> 149:156823d33999 263
<> 149:156823d33999 264 /* Get SecondFraction structure field from the corresponding register field*/
<> 149:156823d33999 265 sTime->SecondFraction = (uint32_t)(hrtc->Instance->PRER & RTC_PRER_PREDIV_S);
<> 149:156823d33999 266 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 267
<> 149:156823d33999 268 /* Get the TR register */
<> 149:156823d33999 269 tmpreg = (uint32_t)(hrtc->Instance->TR & RTC_TR_RESERVED_MASK);
<> 149:156823d33999 270
<> 149:156823d33999 271 /* Fill the structure fields with the read parameters */
<> 149:156823d33999 272 sTime->Hours = (uint8_t)((tmpreg & (RTC_TR_HT | RTC_TR_HU)) >> 16);
<> 149:156823d33999 273 sTime->Minutes = (uint8_t)((tmpreg & (RTC_TR_MNT | RTC_TR_MNU)) >>8);
<> 149:156823d33999 274 sTime->Seconds = (uint8_t)(tmpreg & (RTC_TR_ST | RTC_TR_SU));
<> 149:156823d33999 275 sTime->TimeFormat = (uint8_t)((tmpreg & (RTC_TR_PM)) >> 16);
<> 149:156823d33999 276
<> 149:156823d33999 277 /* Check the input parameters format */
<> 149:156823d33999 278 if(Format == RTC_FORMAT_BIN)
<> 149:156823d33999 279 {
<> 149:156823d33999 280 /* Convert the time structure parameters to Binary format */
<> 149:156823d33999 281 sTime->Hours = (uint8_t)RTC_Bcd2ToByte(sTime->Hours);
<> 149:156823d33999 282 sTime->Minutes = (uint8_t)RTC_Bcd2ToByte(sTime->Minutes);
<> 149:156823d33999 283 sTime->Seconds = (uint8_t)RTC_Bcd2ToByte(sTime->Seconds);
<> 149:156823d33999 284 }
<> 149:156823d33999 285
<> 149:156823d33999 286 return HAL_OK;
<> 149:156823d33999 287 }
<> 149:156823d33999 288
<> 149:156823d33999 289 /**
<> 149:156823d33999 290 * @}
<> 149:156823d33999 291 */
<> 149:156823d33999 292
<> 149:156823d33999 293 /** @addtogroup RTC_Exported_Functions_Group3
<> 149:156823d33999 294 * @{
<> 149:156823d33999 295 */
<> 149:156823d33999 296
<> 149:156823d33999 297 /**
<> 149:156823d33999 298 * @brief Sets the specified RTC Alarm.
<> 149:156823d33999 299 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 300 * the configuration information for RTC.
<> 149:156823d33999 301 * @param sAlarm: Pointer to Alarm structure
<> 149:156823d33999 302 * @param Format: Specifies the format of the entered parameters.
<> 149:156823d33999 303 * This parameter can be one of the following values:
<> 149:156823d33999 304 * @arg RTC_FORMAT_BIN: Binary data format
<> 149:156823d33999 305 * @arg RTC_FORMAT_BCD: BCD data format
<> 149:156823d33999 306 * @retval HAL status
<> 149:156823d33999 307 */
<> 149:156823d33999 308 HAL_StatusTypeDef HAL_RTC_SetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format)
<> 149:156823d33999 309 {
<> 149:156823d33999 310 uint32_t tickstart = 0;
<> 149:156823d33999 311 uint32_t tmpreg = 0;
<> 149:156823d33999 312
<> 149:156823d33999 313 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 314 uint32_t subsecondtmpreg = 0;
<> 149:156823d33999 315 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 316
<> 149:156823d33999 317 /* Check the parameters */
<> 149:156823d33999 318 assert_param(IS_RTC_FORMAT(Format));
<> 149:156823d33999 319 assert_param(IS_RTC_ALARM(sAlarm->Alarm));
<> 149:156823d33999 320 assert_param(IS_RTC_ALARM_MASK(sAlarm->AlarmMask));
<> 149:156823d33999 321 assert_param(IS_RTC_ALARM_DATE_WEEKDAY_SEL(sAlarm->AlarmDateWeekDaySel));
<> 149:156823d33999 322 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 323 assert_param(IS_RTC_ALARM_SUB_SECOND_VALUE(sAlarm->AlarmTime.SubSeconds));
<> 149:156823d33999 324 assert_param(IS_RTC_ALARM_SUB_SECOND_MASK(sAlarm->AlarmSubSecondMask));
<> 149:156823d33999 325 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 326
<> 149:156823d33999 327 /* Process Locked */
<> 149:156823d33999 328 __HAL_LOCK(hrtc);
<> 149:156823d33999 329
<> 149:156823d33999 330 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 331
<> 149:156823d33999 332 if(Format == RTC_FORMAT_BIN)
<> 149:156823d33999 333 {
<> 149:156823d33999 334 if((hrtc->Instance->CR & RTC_CR_FMT) != (uint32_t)RESET)
<> 149:156823d33999 335 {
<> 149:156823d33999 336 assert_param(IS_RTC_HOUR12(sAlarm->AlarmTime.Hours));
<> 149:156823d33999 337 assert_param(IS_RTC_HOURFORMAT12(sAlarm->AlarmTime.TimeFormat));
<> 149:156823d33999 338 }
<> 149:156823d33999 339 else
<> 149:156823d33999 340 {
<> 149:156823d33999 341 sAlarm->AlarmTime.TimeFormat = 0x00;
<> 149:156823d33999 342 assert_param(IS_RTC_HOUR24(sAlarm->AlarmTime.Hours));
<> 149:156823d33999 343 }
<> 149:156823d33999 344 assert_param(IS_RTC_MINUTES(sAlarm->AlarmTime.Minutes));
<> 149:156823d33999 345 assert_param(IS_RTC_SECONDS(sAlarm->AlarmTime.Seconds));
<> 149:156823d33999 346
<> 149:156823d33999 347 if(sAlarm->AlarmDateWeekDaySel == RTC_ALARMDATEWEEKDAYSEL_DATE)
<> 149:156823d33999 348 {
<> 149:156823d33999 349 assert_param(IS_RTC_ALARM_DATE_WEEKDAY_DATE(sAlarm->AlarmDateWeekDay));
<> 149:156823d33999 350 }
<> 149:156823d33999 351 else
<> 149:156823d33999 352 {
<> 149:156823d33999 353 assert_param(IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(sAlarm->AlarmDateWeekDay));
<> 149:156823d33999 354 }
<> 149:156823d33999 355
<> 149:156823d33999 356 tmpreg = (((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Hours) << 16) | \
<> 149:156823d33999 357 ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Minutes) << 8) | \
<> 149:156823d33999 358 ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Seconds)) | \
<> 149:156823d33999 359 ((uint32_t)(sAlarm->AlarmTime.TimeFormat) << 16) | \
<> 149:156823d33999 360 ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmDateWeekDay) << 24) | \
<> 149:156823d33999 361 ((uint32_t)sAlarm->AlarmDateWeekDaySel) | \
<> 149:156823d33999 362 ((uint32_t)sAlarm->AlarmMask));
<> 149:156823d33999 363 }
<> 149:156823d33999 364 else
<> 149:156823d33999 365 {
<> 149:156823d33999 366 if((hrtc->Instance->CR & RTC_CR_FMT) != (uint32_t)RESET)
<> 149:156823d33999 367 {
<> 149:156823d33999 368 tmpreg = RTC_Bcd2ToByte(sAlarm->AlarmTime.Hours);
<> 149:156823d33999 369 assert_param(IS_RTC_HOUR12(tmpreg));
<> 149:156823d33999 370 assert_param(IS_RTC_HOURFORMAT12(sAlarm->AlarmTime.TimeFormat));
<> 149:156823d33999 371 }
<> 149:156823d33999 372 else
<> 149:156823d33999 373 {
<> 149:156823d33999 374 sAlarm->AlarmTime.TimeFormat = 0x00;
<> 149:156823d33999 375 assert_param(IS_RTC_HOUR24(RTC_Bcd2ToByte(sAlarm->AlarmTime.Hours)));
<> 149:156823d33999 376 }
<> 149:156823d33999 377
<> 149:156823d33999 378 assert_param(IS_RTC_MINUTES(RTC_Bcd2ToByte(sAlarm->AlarmTime.Minutes)));
<> 149:156823d33999 379 assert_param(IS_RTC_SECONDS(RTC_Bcd2ToByte(sAlarm->AlarmTime.Seconds)));
<> 149:156823d33999 380
<> 149:156823d33999 381 if(sAlarm->AlarmDateWeekDaySel == RTC_ALARMDATEWEEKDAYSEL_DATE)
<> 149:156823d33999 382 {
<> 149:156823d33999 383 tmpreg = RTC_Bcd2ToByte(sAlarm->AlarmDateWeekDay);
<> 149:156823d33999 384 assert_param(IS_RTC_ALARM_DATE_WEEKDAY_DATE(tmpreg));
<> 149:156823d33999 385 }
<> 149:156823d33999 386 else
<> 149:156823d33999 387 {
<> 149:156823d33999 388 tmpreg = RTC_Bcd2ToByte(sAlarm->AlarmDateWeekDay);
<> 149:156823d33999 389 assert_param(IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(tmpreg));
<> 149:156823d33999 390 }
<> 149:156823d33999 391
<> 149:156823d33999 392 tmpreg = (((uint32_t)(sAlarm->AlarmTime.Hours) << 16) | \
<> 149:156823d33999 393 ((uint32_t)(sAlarm->AlarmTime.Minutes) << 8) | \
<> 149:156823d33999 394 ((uint32_t) sAlarm->AlarmTime.Seconds) | \
<> 149:156823d33999 395 ((uint32_t)(sAlarm->AlarmTime.TimeFormat) << 16) | \
<> 149:156823d33999 396 ((uint32_t)(sAlarm->AlarmDateWeekDay) << 24) | \
<> 149:156823d33999 397 ((uint32_t)sAlarm->AlarmDateWeekDaySel) | \
<> 149:156823d33999 398 ((uint32_t)sAlarm->AlarmMask));
<> 149:156823d33999 399 }
<> 149:156823d33999 400
<> 149:156823d33999 401 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 402 /* Configure the Alarm A or Alarm B Sub Second registers */
<> 149:156823d33999 403 subsecondtmpreg = (uint32_t)((uint32_t)(sAlarm->AlarmTime.SubSeconds) | (uint32_t)(sAlarm->AlarmSubSecondMask));
<> 149:156823d33999 404 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 405
<> 149:156823d33999 406 /* Disable the write protection for RTC registers */
<> 149:156823d33999 407 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
<> 149:156823d33999 408
<> 149:156823d33999 409 /* Configure the Alarm register */
<> 149:156823d33999 410 if(sAlarm->Alarm == RTC_ALARM_A)
<> 149:156823d33999 411 {
<> 149:156823d33999 412 /* Disable the Alarm A interrupt */
<> 149:156823d33999 413 __HAL_RTC_ALARMA_DISABLE(hrtc);
<> 149:156823d33999 414
<> 149:156823d33999 415 /* In case of interrupt mode is used, the interrupt source must disabled */
<> 149:156823d33999 416 __HAL_RTC_ALARM_DISABLE_IT(hrtc, RTC_IT_ALRA);
<> 149:156823d33999 417
<> 149:156823d33999 418 tickstart = HAL_GetTick();
<> 149:156823d33999 419 /* Wait till RTC ALRAWF flag is set and if Time out is reached exit */
<> 149:156823d33999 420 while(__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRAWF) == RESET)
<> 149:156823d33999 421 {
<> 149:156823d33999 422 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
<> 149:156823d33999 423 {
<> 149:156823d33999 424 /* Enable the write protection for RTC registers */
<> 149:156823d33999 425 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 426
<> 149:156823d33999 427 hrtc->State = HAL_RTC_STATE_TIMEOUT;
<> 149:156823d33999 428
<> 149:156823d33999 429 /* Process Unlocked */
<> 149:156823d33999 430 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 431
<> 149:156823d33999 432 return HAL_TIMEOUT;
<> 149:156823d33999 433 }
<> 149:156823d33999 434 }
<> 149:156823d33999 435
<> 149:156823d33999 436 hrtc->Instance->ALRMAR = (uint32_t)tmpreg;
<> 149:156823d33999 437 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 438 /* Configure the Alarm A Sub Second register */
<> 149:156823d33999 439 hrtc->Instance->ALRMASSR = subsecondtmpreg;
<> 149:156823d33999 440 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 441 /* Configure the Alarm state: Enable Alarm */
<> 149:156823d33999 442 __HAL_RTC_ALARMA_ENABLE(hrtc);
<> 149:156823d33999 443 }
<> 149:156823d33999 444 else
<> 149:156823d33999 445 {
<> 149:156823d33999 446 /* Disable the Alarm B interrupt */
<> 149:156823d33999 447 __HAL_RTC_ALARMB_DISABLE(hrtc);
<> 149:156823d33999 448
<> 149:156823d33999 449 /* In case of interrupt mode is used, the interrupt source must disabled */
<> 149:156823d33999 450 __HAL_RTC_ALARM_DISABLE_IT(hrtc, RTC_IT_ALRB);
<> 149:156823d33999 451
<> 149:156823d33999 452 tickstart = HAL_GetTick();
<> 149:156823d33999 453 /* Wait till RTC ALRBWF flag is set and if Time out is reached exit */
<> 149:156823d33999 454 while(__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRBWF) == RESET)
<> 149:156823d33999 455 {
<> 149:156823d33999 456 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
<> 149:156823d33999 457 {
<> 149:156823d33999 458 /* Enable the write protection for RTC registers */
<> 149:156823d33999 459 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 460
<> 149:156823d33999 461 hrtc->State = HAL_RTC_STATE_TIMEOUT;
<> 149:156823d33999 462
<> 149:156823d33999 463 /* Process Unlocked */
<> 149:156823d33999 464 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 465
<> 149:156823d33999 466 return HAL_TIMEOUT;
<> 149:156823d33999 467 }
<> 149:156823d33999 468 }
<> 149:156823d33999 469
<> 149:156823d33999 470 hrtc->Instance->ALRMBR = (uint32_t)tmpreg;
<> 149:156823d33999 471 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 472 /* Configure the Alarm B Sub Second register */
<> 149:156823d33999 473 hrtc->Instance->ALRMBSSR = subsecondtmpreg;
<> 149:156823d33999 474 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 475 /* Configure the Alarm state: Enable Alarm */
<> 149:156823d33999 476 __HAL_RTC_ALARMB_ENABLE(hrtc);
<> 149:156823d33999 477 }
<> 149:156823d33999 478
<> 149:156823d33999 479 /* Enable the write protection for RTC registers */
<> 149:156823d33999 480 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 481
<> 149:156823d33999 482 /* Change RTC state */
<> 149:156823d33999 483 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 484
<> 149:156823d33999 485 /* Process Unlocked */
<> 149:156823d33999 486 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 487
<> 149:156823d33999 488 return HAL_OK;
<> 149:156823d33999 489 }
<> 149:156823d33999 490
<> 149:156823d33999 491 /**
<> 149:156823d33999 492 * @brief Sets the specified RTC Alarm with Interrupt
<> 149:156823d33999 493 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 494 * the configuration information for RTC.
<> 149:156823d33999 495 * @param sAlarm: Pointer to Alarm structure
<> 149:156823d33999 496 * @param Format: Specifies the format of the entered parameters.
<> 149:156823d33999 497 * This parameter can be one of the following values:
<> 149:156823d33999 498 * @arg RTC_FORMAT_BIN: Binary data format
<> 149:156823d33999 499 * @arg RTC_FORMAT_BCD: BCD data format
<> 149:156823d33999 500 * @note The Alarm register can only be written when the corresponding Alarm
<> 149:156823d33999 501 * is disabled (Use the HAL_RTC_DeactivateAlarm()).
<> 149:156823d33999 502 * @note The HAL_RTC_SetTime() must be called before enabling the Alarm feature.
<> 149:156823d33999 503 * @retval HAL status
<> 149:156823d33999 504 */
<> 149:156823d33999 505 HAL_StatusTypeDef HAL_RTC_SetAlarm_IT(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Format)
<> 149:156823d33999 506 {
<> 149:156823d33999 507 uint32_t tickstart = 0;
<> 149:156823d33999 508 uint32_t tmpreg = 0;
<> 149:156823d33999 509 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 510 uint32_t subsecondtmpreg = 0;
<> 149:156823d33999 511 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 512
<> 149:156823d33999 513 /* Check the parameters */
<> 149:156823d33999 514 assert_param(IS_RTC_FORMAT(Format));
<> 149:156823d33999 515 assert_param(IS_RTC_ALARM(sAlarm->Alarm));
<> 149:156823d33999 516 assert_param(IS_RTC_ALARM_MASK(sAlarm->AlarmMask));
<> 149:156823d33999 517 assert_param(IS_RTC_ALARM_DATE_WEEKDAY_SEL(sAlarm->AlarmDateWeekDaySel));
<> 149:156823d33999 518 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 519 assert_param(IS_RTC_ALARM_SUB_SECOND_VALUE(sAlarm->AlarmTime.SubSeconds));
<> 149:156823d33999 520 assert_param(IS_RTC_ALARM_SUB_SECOND_MASK(sAlarm->AlarmSubSecondMask));
<> 149:156823d33999 521 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 522
<> 149:156823d33999 523 /* Process Locked */
<> 149:156823d33999 524 __HAL_LOCK(hrtc);
<> 149:156823d33999 525
<> 149:156823d33999 526 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 527
<> 149:156823d33999 528 if(Format == RTC_FORMAT_BIN)
<> 149:156823d33999 529 {
<> 149:156823d33999 530 if((hrtc->Instance->CR & RTC_CR_FMT) != (uint32_t)RESET)
<> 149:156823d33999 531 {
<> 149:156823d33999 532 assert_param(IS_RTC_HOUR12(sAlarm->AlarmTime.Hours));
<> 149:156823d33999 533 assert_param(IS_RTC_HOURFORMAT12(sAlarm->AlarmTime.TimeFormat));
<> 149:156823d33999 534 }
<> 149:156823d33999 535 else
<> 149:156823d33999 536 {
<> 149:156823d33999 537 sAlarm->AlarmTime.TimeFormat = 0x00;
<> 149:156823d33999 538 assert_param(IS_RTC_HOUR24(sAlarm->AlarmTime.Hours));
<> 149:156823d33999 539 }
<> 149:156823d33999 540 assert_param(IS_RTC_MINUTES(sAlarm->AlarmTime.Minutes));
<> 149:156823d33999 541 assert_param(IS_RTC_SECONDS(sAlarm->AlarmTime.Seconds));
<> 149:156823d33999 542
<> 149:156823d33999 543 if(sAlarm->AlarmDateWeekDaySel == RTC_ALARMDATEWEEKDAYSEL_DATE)
<> 149:156823d33999 544 {
<> 149:156823d33999 545 assert_param(IS_RTC_ALARM_DATE_WEEKDAY_DATE(sAlarm->AlarmDateWeekDay));
<> 149:156823d33999 546 }
<> 149:156823d33999 547 else
<> 149:156823d33999 548 {
<> 149:156823d33999 549 assert_param(IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(sAlarm->AlarmDateWeekDay));
<> 149:156823d33999 550 }
<> 149:156823d33999 551 tmpreg = (((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Hours) << 16) | \
<> 149:156823d33999 552 ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Minutes) << 8) | \
<> 149:156823d33999 553 ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmTime.Seconds)) | \
<> 149:156823d33999 554 ((uint32_t)(sAlarm->AlarmTime.TimeFormat) << 16) | \
<> 149:156823d33999 555 ((uint32_t)RTC_ByteToBcd2(sAlarm->AlarmDateWeekDay) << 24) | \
<> 149:156823d33999 556 ((uint32_t)sAlarm->AlarmDateWeekDaySel) | \
<> 149:156823d33999 557 ((uint32_t)sAlarm->AlarmMask));
<> 149:156823d33999 558 }
<> 149:156823d33999 559 else
<> 149:156823d33999 560 {
<> 149:156823d33999 561 if((hrtc->Instance->CR & RTC_CR_FMT) != (uint32_t)RESET)
<> 149:156823d33999 562 {
<> 149:156823d33999 563 tmpreg = RTC_Bcd2ToByte(sAlarm->AlarmTime.Hours);
<> 149:156823d33999 564 assert_param(IS_RTC_HOUR12(tmpreg));
<> 149:156823d33999 565 assert_param(IS_RTC_HOURFORMAT12(sAlarm->AlarmTime.TimeFormat));
<> 149:156823d33999 566 }
<> 149:156823d33999 567 else
<> 149:156823d33999 568 {
<> 149:156823d33999 569 sAlarm->AlarmTime.TimeFormat = 0x00;
<> 149:156823d33999 570 assert_param(IS_RTC_HOUR24(RTC_Bcd2ToByte(sAlarm->AlarmTime.Hours)));
<> 149:156823d33999 571 }
<> 149:156823d33999 572
<> 149:156823d33999 573 assert_param(IS_RTC_MINUTES(RTC_Bcd2ToByte(sAlarm->AlarmTime.Minutes)));
<> 149:156823d33999 574 assert_param(IS_RTC_SECONDS(RTC_Bcd2ToByte(sAlarm->AlarmTime.Seconds)));
<> 149:156823d33999 575
<> 149:156823d33999 576 if(sAlarm->AlarmDateWeekDaySel == RTC_ALARMDATEWEEKDAYSEL_DATE)
<> 149:156823d33999 577 {
<> 149:156823d33999 578 tmpreg = RTC_Bcd2ToByte(sAlarm->AlarmDateWeekDay);
<> 149:156823d33999 579 assert_param(IS_RTC_ALARM_DATE_WEEKDAY_DATE(tmpreg));
<> 149:156823d33999 580 }
<> 149:156823d33999 581 else
<> 149:156823d33999 582 {
<> 149:156823d33999 583 tmpreg = RTC_Bcd2ToByte(sAlarm->AlarmDateWeekDay);
<> 149:156823d33999 584 assert_param(IS_RTC_ALARM_DATE_WEEKDAY_WEEKDAY(tmpreg));
<> 149:156823d33999 585 }
<> 149:156823d33999 586 tmpreg = (((uint32_t)(sAlarm->AlarmTime.Hours) << 16) | \
<> 149:156823d33999 587 ((uint32_t)(sAlarm->AlarmTime.Minutes) << 8) | \
<> 149:156823d33999 588 ((uint32_t) sAlarm->AlarmTime.Seconds) | \
<> 149:156823d33999 589 ((uint32_t)(sAlarm->AlarmTime.TimeFormat) << 16) | \
<> 149:156823d33999 590 ((uint32_t)(sAlarm->AlarmDateWeekDay) << 24) | \
<> 149:156823d33999 591 ((uint32_t)sAlarm->AlarmDateWeekDaySel) | \
<> 149:156823d33999 592 ((uint32_t)sAlarm->AlarmMask));
<> 149:156823d33999 593 }
<> 149:156823d33999 594 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 595 /* Configure the Alarm A or Alarm B Sub Second registers */
<> 149:156823d33999 596 subsecondtmpreg = (uint32_t)((uint32_t)(sAlarm->AlarmTime.SubSeconds) | (uint32_t)(sAlarm->AlarmSubSecondMask));
<> 149:156823d33999 597 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 598
<> 149:156823d33999 599 /* Disable the write protection for RTC registers */
<> 149:156823d33999 600 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
<> 149:156823d33999 601
<> 149:156823d33999 602 /* Configure the Alarm register */
<> 149:156823d33999 603 if(sAlarm->Alarm == RTC_ALARM_A)
<> 149:156823d33999 604 {
<> 149:156823d33999 605 /* Disable the Alarm A interrupt */
<> 149:156823d33999 606 __HAL_RTC_ALARMA_DISABLE(hrtc);
<> 149:156823d33999 607
<> 149:156823d33999 608 /* Clear flag alarm A */
<> 149:156823d33999 609 __HAL_RTC_ALARM_CLEAR_FLAG(hrtc, RTC_FLAG_ALRAF);
<> 149:156823d33999 610
<> 149:156823d33999 611 tickstart = HAL_GetTick();
<> 149:156823d33999 612 /* Wait till RTC ALRAWF flag is set and if Time out is reached exit */
<> 149:156823d33999 613 while(__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRAWF) == RESET)
<> 149:156823d33999 614 {
<> 149:156823d33999 615 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
<> 149:156823d33999 616 {
<> 149:156823d33999 617 /* Enable the write protection for RTC registers */
<> 149:156823d33999 618 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 619
<> 149:156823d33999 620 hrtc->State = HAL_RTC_STATE_TIMEOUT;
<> 149:156823d33999 621
<> 149:156823d33999 622 /* Process Unlocked */
<> 149:156823d33999 623 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 624
<> 149:156823d33999 625 return HAL_TIMEOUT;
<> 149:156823d33999 626 }
<> 149:156823d33999 627 }
<> 149:156823d33999 628
<> 149:156823d33999 629 hrtc->Instance->ALRMAR = (uint32_t)tmpreg;
<> 149:156823d33999 630 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 631 /* Configure the Alarm A Sub Second register */
<> 149:156823d33999 632 hrtc->Instance->ALRMASSR = subsecondtmpreg;
<> 149:156823d33999 633 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 634 /* Configure the Alarm state: Enable Alarm */
<> 149:156823d33999 635 __HAL_RTC_ALARMA_ENABLE(hrtc);
<> 149:156823d33999 636 /* Configure the Alarm interrupt */
<> 149:156823d33999 637 __HAL_RTC_ALARM_ENABLE_IT(hrtc,RTC_IT_ALRA);
<> 149:156823d33999 638 }
<> 149:156823d33999 639 else
<> 149:156823d33999 640 {
<> 149:156823d33999 641 /* Disable the Alarm B interrupt */
<> 149:156823d33999 642 __HAL_RTC_ALARMB_DISABLE(hrtc);
<> 149:156823d33999 643
<> 149:156823d33999 644 /* Clear flag alarm B */
<> 149:156823d33999 645 __HAL_RTC_ALARM_CLEAR_FLAG(hrtc, RTC_FLAG_ALRBF);
<> 149:156823d33999 646
<> 149:156823d33999 647 tickstart = HAL_GetTick();
<> 149:156823d33999 648 /* Wait till RTC ALRBWF flag is set and if Time out is reached exit */
<> 149:156823d33999 649 while(__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRBWF) == RESET)
<> 149:156823d33999 650 {
<> 149:156823d33999 651 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
<> 149:156823d33999 652 {
<> 149:156823d33999 653 /* Enable the write protection for RTC registers */
<> 149:156823d33999 654 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 655
<> 149:156823d33999 656 hrtc->State = HAL_RTC_STATE_TIMEOUT;
<> 149:156823d33999 657
<> 149:156823d33999 658 /* Process Unlocked */
<> 149:156823d33999 659 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 660
<> 149:156823d33999 661 return HAL_TIMEOUT;
<> 149:156823d33999 662 }
<> 149:156823d33999 663 }
<> 149:156823d33999 664
<> 149:156823d33999 665 hrtc->Instance->ALRMBR = (uint32_t)tmpreg;
<> 149:156823d33999 666 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 667 /* Configure the Alarm B Sub Second register */
<> 149:156823d33999 668 hrtc->Instance->ALRMBSSR = subsecondtmpreg;
<> 149:156823d33999 669 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 670 /* Configure the Alarm state: Enable Alarm */
<> 149:156823d33999 671 __HAL_RTC_ALARMB_ENABLE(hrtc);
<> 149:156823d33999 672 /* Configure the Alarm interrupt */
<> 149:156823d33999 673 __HAL_RTC_ALARM_ENABLE_IT(hrtc, RTC_IT_ALRB);
<> 149:156823d33999 674 }
<> 149:156823d33999 675
<> 149:156823d33999 676 /* RTC Alarm Interrupt Configuration: EXTI configuration */
<> 149:156823d33999 677 __HAL_RTC_ALARM_EXTI_ENABLE_IT();
<> 149:156823d33999 678
<> 149:156823d33999 679 __HAL_RTC_ALARM_EXTI_ENABLE_RISING_EDGE();
<> 149:156823d33999 680
<> 149:156823d33999 681 /* Enable the write protection for RTC registers */
<> 149:156823d33999 682 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 683
<> 149:156823d33999 684 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 685
<> 149:156823d33999 686 /* Process Unlocked */
<> 149:156823d33999 687 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 688
<> 149:156823d33999 689 return HAL_OK;
<> 149:156823d33999 690 }
<> 149:156823d33999 691
<> 149:156823d33999 692 /**
<> 149:156823d33999 693 * @brief Gets the RTC Alarm value and masks.
<> 149:156823d33999 694 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 695 * the configuration information for RTC.
<> 149:156823d33999 696 * @param sAlarm: Pointer to Date structure
<> 149:156823d33999 697 * @param Alarm: Specifies the Alarm.
<> 149:156823d33999 698 * This parameter can be one of the following values:
<> 149:156823d33999 699 * @arg RTC_ALARM_A: AlarmA
<> 149:156823d33999 700 * @arg RTC_ALARM_B: AlarmB
<> 149:156823d33999 701 * @param Format: Specifies the format of the entered parameters.
<> 149:156823d33999 702 * This parameter can be one of the following values:
<> 149:156823d33999 703 * @arg RTC_FORMAT_BIN: Binary data format
<> 149:156823d33999 704 * @arg RTC_FORMAT_BCD: BCD data format
<> 149:156823d33999 705 * @retval HAL status
<> 149:156823d33999 706 */
<> 149:156823d33999 707 HAL_StatusTypeDef HAL_RTC_GetAlarm(RTC_HandleTypeDef *hrtc, RTC_AlarmTypeDef *sAlarm, uint32_t Alarm, uint32_t Format)
<> 149:156823d33999 708 {
<> 149:156823d33999 709 uint32_t tmpreg = 0;
<> 149:156823d33999 710 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 711 uint32_t subsecondtmpreg = 0;
<> 149:156823d33999 712 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 713
<> 149:156823d33999 714 /* Check the parameters */
<> 149:156823d33999 715 assert_param(IS_RTC_FORMAT(Format));
<> 149:156823d33999 716 assert_param(IS_RTC_ALARM(Alarm));
<> 149:156823d33999 717
<> 149:156823d33999 718 if(Alarm == RTC_ALARM_A)
<> 149:156823d33999 719 {
<> 149:156823d33999 720 /* AlarmA */
<> 149:156823d33999 721 sAlarm->Alarm = RTC_ALARM_A;
<> 149:156823d33999 722
<> 149:156823d33999 723 tmpreg = (uint32_t)(hrtc->Instance->ALRMAR);
<> 149:156823d33999 724 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 725 subsecondtmpreg = (uint32_t)((hrtc->Instance->ALRMASSR) & RTC_ALRMASSR_SS);
<> 149:156823d33999 726 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 727 }
<> 149:156823d33999 728 else
<> 149:156823d33999 729 {
<> 149:156823d33999 730 sAlarm->Alarm = RTC_ALARM_B;
<> 149:156823d33999 731
<> 149:156823d33999 732 tmpreg = (uint32_t)(hrtc->Instance->ALRMBR);
<> 149:156823d33999 733 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 734 subsecondtmpreg = (uint32_t)((hrtc->Instance->ALRMBSSR) & RTC_ALRMBSSR_SS);
<> 149:156823d33999 735 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 736 }
<> 149:156823d33999 737
<> 149:156823d33999 738 /* Fill the structure with the read parameters */
<> 149:156823d33999 739 sAlarm->AlarmTime.Hours = (uint32_t)((tmpreg & (RTC_ALRMAR_HT | RTC_ALRMAR_HU)) >> 16);
<> 149:156823d33999 740 sAlarm->AlarmTime.Minutes = (uint32_t)((tmpreg & (RTC_ALRMAR_MNT | RTC_ALRMAR_MNU)) >> 8);
<> 149:156823d33999 741 sAlarm->AlarmTime.Seconds = (uint32_t)(tmpreg & (RTC_ALRMAR_ST | RTC_ALRMAR_SU));
<> 149:156823d33999 742 sAlarm->AlarmTime.TimeFormat = (uint32_t)((tmpreg & RTC_ALRMAR_PM) >> 16);
<> 149:156823d33999 743 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 744 sAlarm->AlarmTime.SubSeconds = (uint32_t) subsecondtmpreg;
<> 149:156823d33999 745 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 746 sAlarm->AlarmDateWeekDay = (uint32_t)((tmpreg & (RTC_ALRMAR_DT | RTC_ALRMAR_DU)) >> 24);
<> 149:156823d33999 747 sAlarm->AlarmDateWeekDaySel = (uint32_t)(tmpreg & RTC_ALRMAR_WDSEL);
<> 149:156823d33999 748 sAlarm->AlarmMask = (uint32_t)(tmpreg & RTC_ALARMMASK_ALL);
<> 149:156823d33999 749
<> 149:156823d33999 750 if(Format == RTC_FORMAT_BIN)
<> 149:156823d33999 751 {
<> 149:156823d33999 752 sAlarm->AlarmTime.Hours = RTC_Bcd2ToByte(sAlarm->AlarmTime.Hours);
<> 149:156823d33999 753 sAlarm->AlarmTime.Minutes = RTC_Bcd2ToByte(sAlarm->AlarmTime.Minutes);
<> 149:156823d33999 754 sAlarm->AlarmTime.Seconds = RTC_Bcd2ToByte(sAlarm->AlarmTime.Seconds);
<> 149:156823d33999 755 sAlarm->AlarmDateWeekDay = RTC_Bcd2ToByte(sAlarm->AlarmDateWeekDay);
<> 149:156823d33999 756 }
<> 149:156823d33999 757
<> 149:156823d33999 758 return HAL_OK;
<> 149:156823d33999 759 }
<> 149:156823d33999 760
<> 149:156823d33999 761 /**
<> 149:156823d33999 762 * @}
<> 149:156823d33999 763 */
<> 149:156823d33999 764
<> 149:156823d33999 765
<> 149:156823d33999 766 /** @defgroup RTC_Exported_Functions_Group6 Peripheral Control functions
<> 149:156823d33999 767 * @brief Peripheral Control functions
<> 149:156823d33999 768 *
<> 149:156823d33999 769 @verbatim
<> 149:156823d33999 770 ===============================================================================
<> 149:156823d33999 771 ##### Peripheral Control functions #####
<> 149:156823d33999 772 ===============================================================================
<> 149:156823d33999 773 [..]
<> 149:156823d33999 774 This subsection provides functions allowing to
<> 149:156823d33999 775 (+) Wait for RTC Time and Date Synchronization
<> 149:156823d33999 776
<> 149:156823d33999 777 @endverbatim
<> 149:156823d33999 778 * @{
<> 149:156823d33999 779 */
<> 149:156823d33999 780
<> 149:156823d33999 781 /**
<> 149:156823d33999 782 * @brief Waits until the RTC Time and Date registers (RTC_TR and RTC_DR) are
<> 149:156823d33999 783 * synchronized with RTC APB clock.
<> 149:156823d33999 784 * @note The RTC Resynchronization mode is write protected, use the
<> 149:156823d33999 785 * __HAL_RTC_WRITEPROTECTION_DISABLE() before calling this function.
<> 149:156823d33999 786 * @note To read the calendar through the shadow registers after Calendar
<> 149:156823d33999 787 * initialization, calendar update or after wakeup from low power modes
<> 149:156823d33999 788 * the software must first clear the RSF flag.
<> 149:156823d33999 789 * The software must then wait until it is set again before reading
<> 149:156823d33999 790 * the calendar, which means that the calendar registers have been
<> 149:156823d33999 791 * correctly copied into the RTC_TR and RTC_DR shadow registers.
<> 149:156823d33999 792 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 793 * the configuration information for RTC.
<> 149:156823d33999 794 * @retval HAL status
<> 149:156823d33999 795 */
<> 149:156823d33999 796 HAL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef* hrtc)
<> 149:156823d33999 797 {
<> 149:156823d33999 798 uint32_t tickstart = 0;
<> 149:156823d33999 799
<> 149:156823d33999 800 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 801 /* If RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */
<> 149:156823d33999 802 if((hrtc->Instance->CR & RTC_CR_BYPSHAD) == RESET)
<> 149:156823d33999 803 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 804 {
<> 149:156823d33999 805 /* Clear RSF flag */
<> 149:156823d33999 806 hrtc->Instance->ISR &= (uint32_t)RTC_RSF_MASK;
<> 149:156823d33999 807
<> 149:156823d33999 808 tickstart = HAL_GetTick();
<> 149:156823d33999 809
<> 149:156823d33999 810 /* Wait the registers to be synchronised */
<> 149:156823d33999 811 while((hrtc->Instance->ISR & RTC_ISR_RSF) == (uint32_t)RESET)
<> 149:156823d33999 812 {
<> 149:156823d33999 813 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
<> 149:156823d33999 814 {
<> 149:156823d33999 815 return HAL_TIMEOUT;
<> 149:156823d33999 816 }
<> 149:156823d33999 817 }
<> 149:156823d33999 818 }
<> 149:156823d33999 819
<> 149:156823d33999 820 return HAL_OK;
<> 149:156823d33999 821 }
<> 149:156823d33999 822
<> 149:156823d33999 823 /**
<> 149:156823d33999 824 * @}
<> 149:156823d33999 825 */
<> 149:156823d33999 826
<> 149:156823d33999 827 /**
<> 149:156823d33999 828 * @}
<> 149:156823d33999 829 */
<> 149:156823d33999 830
<> 149:156823d33999 831 /**
<> 149:156823d33999 832 * @}
<> 149:156823d33999 833 */
<> 149:156823d33999 834
<> 149:156823d33999 835 /** @defgroup RTCEx RTCEx
<> 149:156823d33999 836 * @brief RTC Extended HAL module driver
<> 149:156823d33999 837 * @{
<> 149:156823d33999 838 */
<> 149:156823d33999 839
<> 149:156823d33999 840 /** @defgroup RTCEx_Exported_Functions RTCEx Exported Functions
<> 149:156823d33999 841 * @{
<> 149:156823d33999 842 */
<> 149:156823d33999 843
<> 149:156823d33999 844 /** @defgroup RTCEx_Exported_Functions_Group4 RTC TimeStamp and Tamper functions
<> 149:156823d33999 845 * @brief RTC TimeStamp and Tamper functions
<> 149:156823d33999 846 *
<> 149:156823d33999 847 @verbatim
<> 149:156823d33999 848 ===============================================================================
<> 149:156823d33999 849 ##### RTC TimeStamp and Tamper functions #####
<> 149:156823d33999 850 ===============================================================================
<> 149:156823d33999 851
<> 149:156823d33999 852 [..] This section provides functions allowing to configure TimeStamp feature
<> 149:156823d33999 853
<> 149:156823d33999 854 @endverbatim
<> 149:156823d33999 855 * @{
<> 149:156823d33999 856 */
<> 149:156823d33999 857
<> 149:156823d33999 858 /**
<> 149:156823d33999 859 * @brief Sets TimeStamp.
<> 149:156823d33999 860 * @note This API must be called before enabling the TimeStamp feature.
<> 149:156823d33999 861 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 862 * the configuration information for RTC.
<> 149:156823d33999 863 * @param TimeStampEdge: Specifies the pin edge on which the TimeStamp is
<> 149:156823d33999 864 * activated.
<> 149:156823d33999 865 * This parameter can be one of the following values:
<> 149:156823d33999 866 * @arg RTC_TIMESTAMPEDGE_RISING: the Time stamp event occurs on the
<> 149:156823d33999 867 * rising edge of the related pin.
<> 149:156823d33999 868 * @arg RTC_TIMESTAMPEDGE_FALLING: the Time stamp event occurs on the
<> 149:156823d33999 869 * falling edge of the related pin.
<> 149:156823d33999 870 * @retval HAL status
<> 149:156823d33999 871 */
<> 149:156823d33999 872 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge)
<> 149:156823d33999 873 {
<> 149:156823d33999 874 uint32_t tmpreg = 0;
<> 149:156823d33999 875
<> 149:156823d33999 876 /* Check the parameters */
<> 149:156823d33999 877 assert_param(IS_TIMESTAMP_EDGE(TimeStampEdge));
<> 149:156823d33999 878
<> 149:156823d33999 879 /* Process Locked */
<> 149:156823d33999 880 __HAL_LOCK(hrtc);
<> 149:156823d33999 881
<> 149:156823d33999 882 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 883
<> 149:156823d33999 884 /* Get the RTC_CR register and clear the bits to be configured */
<> 149:156823d33999 885 tmpreg = (uint32_t)(hrtc->Instance->CR & (uint32_t)~(RTC_CR_TSEDGE | RTC_CR_TSE));
<> 149:156823d33999 886
<> 149:156823d33999 887 tmpreg|= TimeStampEdge;
<> 149:156823d33999 888
<> 149:156823d33999 889 /* Disable the write protection for RTC registers */
<> 149:156823d33999 890 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
<> 149:156823d33999 891
<> 149:156823d33999 892 /* Configure the Time Stamp TSEDGE and Enable bits */
<> 149:156823d33999 893 hrtc->Instance->CR = (uint32_t)tmpreg;
<> 149:156823d33999 894
<> 149:156823d33999 895 __HAL_RTC_TIMESTAMP_ENABLE(hrtc);
<> 149:156823d33999 896
<> 149:156823d33999 897 /* Enable the write protection for RTC registers */
<> 149:156823d33999 898 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 899
<> 149:156823d33999 900 /* Change RTC state */
<> 149:156823d33999 901 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 902
<> 149:156823d33999 903 /* Process Unlocked */
<> 149:156823d33999 904 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 905
<> 149:156823d33999 906 return HAL_OK;
<> 149:156823d33999 907 }
<> 149:156823d33999 908
<> 149:156823d33999 909 /**
<> 149:156823d33999 910 * @brief Sets TimeStamp with Interrupt.
<> 149:156823d33999 911 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 912 * the configuration information for RTC.
<> 149:156823d33999 913 * @note This API must be called before enabling the TimeStamp feature.
<> 149:156823d33999 914 * @param TimeStampEdge: Specifies the pin edge on which the TimeStamp is
<> 149:156823d33999 915 * activated.
<> 149:156823d33999 916 * This parameter can be one of the following values:
<> 149:156823d33999 917 * @arg RTC_TIMESTAMPEDGE_RISING: the Time stamp event occurs on the
<> 149:156823d33999 918 * rising edge of the related pin.
<> 149:156823d33999 919 * @arg RTC_TIMESTAMPEDGE_FALLING: the Time stamp event occurs on the
<> 149:156823d33999 920 * falling edge of the related pin.
<> 149:156823d33999 921 * @retval HAL status
<> 149:156823d33999 922 */
<> 149:156823d33999 923 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge)
<> 149:156823d33999 924 {
<> 149:156823d33999 925 uint32_t tmpreg = 0;
<> 149:156823d33999 926
<> 149:156823d33999 927 /* Check the parameters */
<> 149:156823d33999 928 assert_param(IS_TIMESTAMP_EDGE(TimeStampEdge));
<> 149:156823d33999 929
<> 149:156823d33999 930 /* Process Locked */
<> 149:156823d33999 931 __HAL_LOCK(hrtc);
<> 149:156823d33999 932
<> 149:156823d33999 933 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 934
<> 149:156823d33999 935 /* Get the RTC_CR register and clear the bits to be configured */
<> 149:156823d33999 936 tmpreg = (uint32_t)(hrtc->Instance->CR & (uint32_t)~(RTC_CR_TSEDGE | RTC_CR_TSE));
<> 149:156823d33999 937
<> 149:156823d33999 938 tmpreg |= TimeStampEdge;
<> 149:156823d33999 939
<> 149:156823d33999 940 /* Disable the write protection for RTC registers */
<> 149:156823d33999 941 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
<> 149:156823d33999 942
<> 149:156823d33999 943 /* Configure the Time Stamp TSEDGE and Enable bits */
<> 149:156823d33999 944 hrtc->Instance->CR = (uint32_t)tmpreg;
<> 149:156823d33999 945
<> 149:156823d33999 946 __HAL_RTC_TIMESTAMP_ENABLE(hrtc);
<> 149:156823d33999 947
<> 149:156823d33999 948 /* Enable IT timestamp */
<> 149:156823d33999 949 __HAL_RTC_TIMESTAMP_ENABLE_IT(hrtc,RTC_IT_TS);
<> 149:156823d33999 950
<> 149:156823d33999 951 /* RTC timestamp Interrupt Configuration: EXTI configuration */
<> 149:156823d33999 952 __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT();
<> 149:156823d33999 953
<> 149:156823d33999 954 __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE();
<> 149:156823d33999 955
<> 149:156823d33999 956 /* Enable the write protection for RTC registers */
<> 149:156823d33999 957 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 958
<> 149:156823d33999 959 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 960
<> 149:156823d33999 961 /* Process Unlocked */
<> 149:156823d33999 962 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 963
<> 149:156823d33999 964 return HAL_OK;
<> 149:156823d33999 965 }
<> 149:156823d33999 966
<> 149:156823d33999 967 /**
<> 149:156823d33999 968 * @brief Deactivates TimeStamp.
<> 149:156823d33999 969 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 970 * the configuration information for RTC.
<> 149:156823d33999 971 * @retval HAL status
<> 149:156823d33999 972 */
<> 149:156823d33999 973 HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc)
<> 149:156823d33999 974 {
<> 149:156823d33999 975 uint32_t tmpreg = 0;
<> 149:156823d33999 976
<> 149:156823d33999 977 /* Process Locked */
<> 149:156823d33999 978 __HAL_LOCK(hrtc);
<> 149:156823d33999 979
<> 149:156823d33999 980 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 981
<> 149:156823d33999 982 /* Disable the write protection for RTC registers */
<> 149:156823d33999 983 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
<> 149:156823d33999 984
<> 149:156823d33999 985 /* In case of interrupt mode is used, the interrupt source must disabled */
<> 149:156823d33999 986 __HAL_RTC_TIMESTAMP_DISABLE_IT(hrtc, RTC_IT_TS);
<> 149:156823d33999 987
<> 149:156823d33999 988 /* Get the RTC_CR register and clear the bits to be configured */
<> 149:156823d33999 989 tmpreg = (uint32_t)(hrtc->Instance->CR & (uint32_t)~(RTC_CR_TSEDGE | RTC_CR_TSE));
<> 149:156823d33999 990
<> 149:156823d33999 991 /* Configure the Time Stamp TSEDGE and Enable bits */
<> 149:156823d33999 992 hrtc->Instance->CR = (uint32_t)tmpreg;
<> 149:156823d33999 993
<> 149:156823d33999 994 /* Enable the write protection for RTC registers */
<> 149:156823d33999 995 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 996
<> 149:156823d33999 997 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 998
<> 149:156823d33999 999 /* Process Unlocked */
<> 149:156823d33999 1000 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 1001
<> 149:156823d33999 1002 return HAL_OK;
<> 149:156823d33999 1003 }
<> 149:156823d33999 1004
<> 149:156823d33999 1005 /**
<> 149:156823d33999 1006 * @brief Gets the RTC TimeStamp value.
<> 149:156823d33999 1007 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1008 * the configuration information for RTC.
<> 149:156823d33999 1009 * @param sTimeStamp: Pointer to Time structure
<> 149:156823d33999 1010 * @param sTimeStampDate: Pointer to Date structure
<> 149:156823d33999 1011 * @param Format: specifies the format of the entered parameters.
<> 149:156823d33999 1012 * This parameter can be one of the following values:
<> 149:156823d33999 1013 * RTC_FORMAT_BIN: Binary data format
<> 149:156823d33999 1014 * RTC_FORMAT_BCD: BCD data format
<> 149:156823d33999 1015 * @retval HAL status
<> 149:156823d33999 1016 */
<> 149:156823d33999 1017 HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef* sTimeStamp, RTC_DateTypeDef* sTimeStampDate, uint32_t Format)
<> 149:156823d33999 1018 {
<> 149:156823d33999 1019 uint32_t tmptime = 0, tmpdate = 0;
<> 149:156823d33999 1020
<> 149:156823d33999 1021 /* Check the parameters */
<> 149:156823d33999 1022 assert_param(IS_RTC_FORMAT(Format));
<> 149:156823d33999 1023
<> 149:156823d33999 1024 /* Get the TimeStamp time and date registers values */
<> 149:156823d33999 1025 tmptime = (uint32_t)(hrtc->Instance->TSTR & RTC_TR_RESERVED_MASK);
<> 149:156823d33999 1026 tmpdate = (uint32_t)(hrtc->Instance->TSDR & RTC_DR_RESERVED_MASK);
<> 149:156823d33999 1027
<> 149:156823d33999 1028 /* Fill the Time structure fields with the read parameters */
<> 149:156823d33999 1029 sTimeStamp->Hours = (uint8_t)((tmptime & (RTC_TR_HT | RTC_TR_HU)) >> 16);
<> 149:156823d33999 1030 sTimeStamp->Minutes = (uint8_t)((tmptime & (RTC_TR_MNT | RTC_TR_MNU)) >> 8);
<> 149:156823d33999 1031 sTimeStamp->Seconds = (uint8_t)(tmptime & (RTC_TR_ST | RTC_TR_SU));
<> 149:156823d33999 1032 sTimeStamp->TimeFormat = (uint8_t)((tmptime & (RTC_TR_PM)) >> 16);
<> 149:156823d33999 1033 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 1034 sTimeStamp->SubSeconds = (uint32_t)((hrtc->Instance->TSSSR) & RTC_TSSSR_SS);
<> 149:156823d33999 1035 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 1036
<> 149:156823d33999 1037 /* Fill the Date structure fields with the read parameters */
<> 149:156823d33999 1038 sTimeStampDate->Year = 0;
<> 149:156823d33999 1039 sTimeStampDate->Month = (uint8_t)((tmpdate & (RTC_DR_MT | RTC_DR_MU)) >> 8);
<> 149:156823d33999 1040 sTimeStampDate->Date = (uint8_t)(tmpdate & (RTC_DR_DT | RTC_DR_DU));
<> 149:156823d33999 1041 sTimeStampDate->WeekDay = (uint8_t)((tmpdate & (RTC_DR_WDU)) >> 13);
<> 149:156823d33999 1042
<> 149:156823d33999 1043 /* Check the input parameters format */
<> 149:156823d33999 1044 if(Format == RTC_FORMAT_BIN)
<> 149:156823d33999 1045 {
<> 149:156823d33999 1046 /* Convert the TimeStamp structure parameters to Binary format */
<> 149:156823d33999 1047 sTimeStamp->Hours = (uint8_t)RTC_Bcd2ToByte(sTimeStamp->Hours);
<> 149:156823d33999 1048 sTimeStamp->Minutes = (uint8_t)RTC_Bcd2ToByte(sTimeStamp->Minutes);
<> 149:156823d33999 1049 sTimeStamp->Seconds = (uint8_t)RTC_Bcd2ToByte(sTimeStamp->Seconds);
<> 149:156823d33999 1050
<> 149:156823d33999 1051 /* Convert the DateTimeStamp structure parameters to Binary format */
<> 149:156823d33999 1052 sTimeStampDate->Month = (uint8_t)RTC_Bcd2ToByte(sTimeStampDate->Month);
<> 149:156823d33999 1053 sTimeStampDate->Date = (uint8_t)RTC_Bcd2ToByte(sTimeStampDate->Date);
<> 149:156823d33999 1054 sTimeStampDate->WeekDay = (uint8_t)RTC_Bcd2ToByte(sTimeStampDate->WeekDay);
<> 149:156823d33999 1055 }
<> 149:156823d33999 1056
<> 149:156823d33999 1057 /* Clear the TIMESTAMP Flag */
<> 149:156823d33999 1058 __HAL_RTC_TIMESTAMP_CLEAR_FLAG(hrtc, RTC_FLAG_TSF);
<> 149:156823d33999 1059
<> 149:156823d33999 1060 return HAL_OK;
<> 149:156823d33999 1061 }
<> 149:156823d33999 1062
<> 149:156823d33999 1063 /**
<> 149:156823d33999 1064 * @brief Sets Tamper
<> 149:156823d33999 1065 * @note By calling this API we disable the tamper interrupt for all tampers.
<> 149:156823d33999 1066 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1067 * the configuration information for RTC.
<> 149:156823d33999 1068 * @param sTamper: Pointer to Tamper Structure.
<> 149:156823d33999 1069 * @retval HAL status
<> 149:156823d33999 1070 */
<> 149:156823d33999 1071 HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper)
<> 149:156823d33999 1072 {
<> 149:156823d33999 1073 uint32_t tmpreg = 0;
<> 149:156823d33999 1074
<> 149:156823d33999 1075 /* Check the parameters */
<> 149:156823d33999 1076 assert_param(IS_RTC_TAMPER(sTamper->Tamper));
<> 149:156823d33999 1077 assert_param(IS_RTC_TAMPER_TRIGGER(sTamper->Trigger));
<> 149:156823d33999 1078 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 1079 assert_param(IS_RTC_TAMPER_FILTER(sTamper->Filter));
<> 149:156823d33999 1080 assert_param(IS_RTC_TAMPER_SAMPLING_FREQ(sTamper->SamplingFrequency));
<> 149:156823d33999 1081 assert_param(IS_RTC_TAMPER_PRECHARGE_DURATION(sTamper->PrechargeDuration));
<> 149:156823d33999 1082 assert_param(IS_RTC_TAMPER_PULLUP_STATE(sTamper->TamperPullUp));
<> 149:156823d33999 1083 assert_param(IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(sTamper->TimeStampOnTamperDetection));
<> 149:156823d33999 1084 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 1085
<> 149:156823d33999 1086 /* Process Locked */
<> 149:156823d33999 1087 __HAL_LOCK(hrtc);
<> 149:156823d33999 1088
<> 149:156823d33999 1089 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 1090
<> 149:156823d33999 1091 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 1092 if((sTamper->Trigger == RTC_TAMPERTRIGGER_RISINGEDGE))
<> 149:156823d33999 1093 {
<> 149:156823d33999 1094 /* Configure the RTC_TAFCR register */
<> 149:156823d33999 1095 sTamper->Trigger = RTC_TAMPERTRIGGER_RISINGEDGE;
<> 149:156823d33999 1096 }
<> 149:156823d33999 1097 else
<> 149:156823d33999 1098 {
<> 149:156823d33999 1099 sTamper->Trigger = (uint32_t)(sTamper->Tamper << 1);
<> 149:156823d33999 1100 }
<> 149:156823d33999 1101
<> 149:156823d33999 1102 tmpreg = ((uint32_t)sTamper->Tamper | (uint32_t)sTamper->Trigger | (uint32_t)sTamper->Filter |\
<> 149:156823d33999 1103 (uint32_t)sTamper->SamplingFrequency | (uint32_t)sTamper->PrechargeDuration |\
<> 149:156823d33999 1104 (uint32_t)sTamper->TamperPullUp | sTamper->TimeStampOnTamperDetection);
<> 149:156823d33999 1105
<> 149:156823d33999 1106 hrtc->Instance->TAFCR &= (uint32_t)~((uint32_t)sTamper->Tamper | (uint32_t)(sTamper->Tamper << 1) | (uint32_t)RTC_TAFCR_TAMPTS |\
<> 149:156823d33999 1107 (uint32_t)RTC_TAFCR_TAMPFREQ | (uint32_t)RTC_TAFCR_TAMPFLT | (uint32_t)RTC_TAFCR_TAMPPRCH |\
<> 149:156823d33999 1108 (uint32_t)RTC_TAFCR_TAMPPUDIS | (uint32_t)RTC_TAFCR_TAMPIE);
<> 149:156823d33999 1109 #else
<> 149:156823d33999 1110 tmpreg = ((uint32_t)sTamper->Tamper | (uint32_t)(sTamper->Trigger));
<> 149:156823d33999 1111
<> 149:156823d33999 1112 hrtc->Instance->TAFCR &= (uint32_t)~((uint32_t)RTC_TAFCR_TAMP1E | (uint32_t)RTC_TAFCR_TAMP1TRG);
<> 149:156823d33999 1113
<> 149:156823d33999 1114 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 1115 hrtc->Instance->TAFCR |= tmpreg;
<> 149:156823d33999 1116
<> 149:156823d33999 1117 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 1118
<> 149:156823d33999 1119 /* Process Unlocked */
<> 149:156823d33999 1120 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 1121
<> 149:156823d33999 1122 return HAL_OK;
<> 149:156823d33999 1123 }
<> 149:156823d33999 1124
<> 149:156823d33999 1125 /**
<> 149:156823d33999 1126 * @brief Sets Tamper with interrupt.
<> 149:156823d33999 1127 * @note By calling this API we force the tamper interrupt for all tampers.
<> 149:156823d33999 1128 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1129 * the configuration information for RTC.
<> 149:156823d33999 1130 * @param sTamper: Pointer to RTC Tamper.
<> 149:156823d33999 1131 * @retval HAL status
<> 149:156823d33999 1132 */
<> 149:156823d33999 1133 HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper)
<> 149:156823d33999 1134 {
<> 149:156823d33999 1135 uint32_t tmpreg = 0;
<> 149:156823d33999 1136
<> 149:156823d33999 1137 /* Check the parameters */
<> 149:156823d33999 1138 assert_param(IS_RTC_TAMPER(sTamper->Tamper));
<> 149:156823d33999 1139 assert_param(IS_RTC_TAMPER_TRIGGER(sTamper->Trigger));
<> 149:156823d33999 1140 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 1141 assert_param(IS_RTC_TAMPER_FILTER(sTamper->Filter));
<> 149:156823d33999 1142 assert_param(IS_RTC_TAMPER_SAMPLING_FREQ(sTamper->SamplingFrequency));
<> 149:156823d33999 1143 assert_param(IS_RTC_TAMPER_PRECHARGE_DURATION(sTamper->PrechargeDuration));
<> 149:156823d33999 1144 assert_param(IS_RTC_TAMPER_PULLUP_STATE(sTamper->TamperPullUp));
<> 149:156823d33999 1145 assert_param(IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(sTamper->TimeStampOnTamperDetection));
<> 149:156823d33999 1146 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 1147
<> 149:156823d33999 1148 /* Process Locked */
<> 149:156823d33999 1149 __HAL_LOCK(hrtc);
<> 149:156823d33999 1150
<> 149:156823d33999 1151 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 1152
<> 149:156823d33999 1153 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 1154 /* Configure the tamper trigger */
<> 149:156823d33999 1155 if((sTamper->Trigger == RTC_TAMPERTRIGGER_RISINGEDGE))
<> 149:156823d33999 1156 {
<> 149:156823d33999 1157 sTamper->Trigger = RTC_TAMPERTRIGGER_RISINGEDGE;
<> 149:156823d33999 1158 }
<> 149:156823d33999 1159 else
<> 149:156823d33999 1160 {
<> 149:156823d33999 1161 sTamper->Trigger = (uint32_t) (sTamper->Tamper<<1);
<> 149:156823d33999 1162 }
<> 149:156823d33999 1163
<> 149:156823d33999 1164 tmpreg = ((uint32_t)sTamper->Tamper | (uint32_t)sTamper->Trigger | (uint32_t)sTamper->Filter |\
<> 149:156823d33999 1165 (uint32_t)sTamper->SamplingFrequency | (uint32_t)sTamper->PrechargeDuration |\
<> 149:156823d33999 1166 (uint32_t)sTamper->TamperPullUp | sTamper->TimeStampOnTamperDetection);
<> 149:156823d33999 1167
<> 149:156823d33999 1168 hrtc->Instance->TAFCR &= (uint32_t)~((uint32_t)sTamper->Tamper | (uint32_t)(sTamper->Tamper << 1) | (uint32_t)RTC_TAFCR_TAMPTS |\
<> 149:156823d33999 1169 (uint32_t)RTC_TAFCR_TAMPFREQ | (uint32_t)RTC_TAFCR_TAMPFLT | (uint32_t)RTC_TAFCR_TAMPPRCH |\
<> 149:156823d33999 1170 (uint32_t)RTC_TAFCR_TAMPPUDIS);
<> 149:156823d33999 1171 #else
<> 149:156823d33999 1172 tmpreg = ((uint32_t)sTamper->Tamper | (uint32_t)sTamper->Trigger);
<> 149:156823d33999 1173
<> 149:156823d33999 1174 hrtc->Instance->TAFCR &= (uint32_t)~((uint32_t)RTC_TAFCR_TAMP1E | (uint32_t)RTC_TAFCR_TAMP1TRG | (uint32_t)RTC_TAFCR_TAMPIE);
<> 149:156823d33999 1175 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 1176 hrtc->Instance->TAFCR |= tmpreg;
<> 149:156823d33999 1177
<> 149:156823d33999 1178 /* Configure the Tamper Interrupt in the RTC_TAFCR */
<> 149:156823d33999 1179 hrtc->Instance->TAFCR |= (uint32_t)RTC_TAFCR_TAMPIE;
<> 149:156823d33999 1180
<> 149:156823d33999 1181 /* RTC Tamper Interrupt Configuration: EXTI configuration */
<> 149:156823d33999 1182 __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT();
<> 149:156823d33999 1183
<> 149:156823d33999 1184 __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE();
<> 149:156823d33999 1185
<> 149:156823d33999 1186 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 1187
<> 149:156823d33999 1188 /* Process Unlocked */
<> 149:156823d33999 1189 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 1190
<> 149:156823d33999 1191 return HAL_OK;
<> 149:156823d33999 1192 }
<> 149:156823d33999 1193
<> 149:156823d33999 1194 /**
<> 149:156823d33999 1195 * @brief Deactivates Tamper.
<> 149:156823d33999 1196 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1197 * the configuration information for RTC.
<> 149:156823d33999 1198 * @param Tamper: Selected tamper pin.
<> 149:156823d33999 1199 * This parameter can be a value of @ref RTCEx_Tamper_Pins_Definitions
<> 149:156823d33999 1200 * @retval HAL status
<> 149:156823d33999 1201 */
<> 149:156823d33999 1202 HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper)
<> 149:156823d33999 1203 {
<> 149:156823d33999 1204 assert_param(IS_RTC_TAMPER(Tamper));
<> 149:156823d33999 1205
<> 149:156823d33999 1206 /* Process Locked */
<> 149:156823d33999 1207 __HAL_LOCK(hrtc);
<> 149:156823d33999 1208
<> 149:156823d33999 1209 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 1210
<> 149:156823d33999 1211 /* Disable the selected Tamper pin */
<> 149:156823d33999 1212 hrtc->Instance->TAFCR &= (uint32_t)~Tamper;
<> 149:156823d33999 1213
<> 149:156823d33999 1214 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 1215
<> 149:156823d33999 1216 /* Process Unlocked */
<> 149:156823d33999 1217 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 1218
<> 149:156823d33999 1219 return HAL_OK;
<> 149:156823d33999 1220 }
<> 149:156823d33999 1221
<> 149:156823d33999 1222 /**
<> 149:156823d33999 1223 * @brief This function handles TimeStamp interrupt request.
<> 149:156823d33999 1224 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1225 * the configuration information for RTC.
<> 149:156823d33999 1226 * @retval None
<> 149:156823d33999 1227 */
<> 149:156823d33999 1228 void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc)
<> 149:156823d33999 1229 {
<> 149:156823d33999 1230 /* Get the TimeStamp interrupt source enable status */
<> 149:156823d33999 1231 if(__HAL_RTC_TIMESTAMP_GET_IT_SOURCE(hrtc, RTC_IT_TS) != RESET)
<> 149:156823d33999 1232 {
<> 149:156823d33999 1233 /* Get the pending status of the TIMESTAMP Interrupt */
<> 149:156823d33999 1234 if(__HAL_RTC_TIMESTAMP_GET_FLAG(hrtc, RTC_FLAG_TSF) != RESET)
<> 149:156823d33999 1235 {
<> 149:156823d33999 1236 /* TIMESTAMP callback */
<> 149:156823d33999 1237 HAL_RTCEx_TimeStampEventCallback(hrtc);
<> 149:156823d33999 1238
<> 149:156823d33999 1239 /* Clear the TIMESTAMP interrupt pending bit */
<> 149:156823d33999 1240 __HAL_RTC_TIMESTAMP_CLEAR_FLAG(hrtc, RTC_FLAG_TSF);
<> 149:156823d33999 1241 }
<> 149:156823d33999 1242 }
<> 149:156823d33999 1243
<> 149:156823d33999 1244 /* Get the Tamper1 interrupts source enable status */
<> 149:156823d33999 1245 if(__HAL_RTC_TAMPER_GET_IT_SOURCE(hrtc, RTC_IT_TAMP | RTC_IT_TAMP1) != RESET)
<> 149:156823d33999 1246 {
<> 149:156823d33999 1247 /* Get the pending status of the Tamper1 Interrupt */
<> 149:156823d33999 1248 if(__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP1F) != RESET)
<> 149:156823d33999 1249 {
<> 149:156823d33999 1250 /* Tamper1 callback */
<> 149:156823d33999 1251 HAL_RTCEx_Tamper1EventCallback(hrtc);
<> 149:156823d33999 1252
<> 149:156823d33999 1253 /* Clear the Tamper1 interrupt pending bit */
<> 149:156823d33999 1254 __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP1F);
<> 149:156823d33999 1255 }
<> 149:156823d33999 1256 }
<> 149:156823d33999 1257
<> 149:156823d33999 1258 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 1259 /* Get the Tamper2 interrupts source enable status */
<> 149:156823d33999 1260 if(__HAL_RTC_TAMPER_GET_IT_SOURCE(hrtc, RTC_IT_TAMP | RTC_IT_TAMP2) != RESET)
<> 149:156823d33999 1261 {
<> 149:156823d33999 1262 /* Get the pending status of the Tamper2 Interrupt */
<> 149:156823d33999 1263 if(__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP2F) != RESET)
<> 149:156823d33999 1264 {
<> 149:156823d33999 1265 /* Tamper2 callback */
<> 149:156823d33999 1266 HAL_RTCEx_Tamper2EventCallback(hrtc);
<> 149:156823d33999 1267
<> 149:156823d33999 1268 /* Clear the Tamper2 interrupt pending bit */
<> 149:156823d33999 1269 __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP2F);
<> 149:156823d33999 1270 }
<> 149:156823d33999 1271 }
<> 149:156823d33999 1272
<> 149:156823d33999 1273 /* Get the Tamper3 interrupts source enable status */
<> 149:156823d33999 1274 if(__HAL_RTC_TAMPER_GET_IT_SOURCE(hrtc, RTC_IT_TAMP | RTC_IT_TAMP3) != RESET)
<> 149:156823d33999 1275 {
<> 149:156823d33999 1276 /* Get the pending status of the Tamper3 Interrupt */
<> 149:156823d33999 1277 if(__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP3F) != RESET)
<> 149:156823d33999 1278 {
<> 149:156823d33999 1279 /* Tamper3 callback */
<> 149:156823d33999 1280 HAL_RTCEx_Tamper3EventCallback(hrtc);
<> 149:156823d33999 1281
<> 149:156823d33999 1282 /* Clear the Tamper3 interrupt pending bit */
<> 149:156823d33999 1283 __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP3F);
<> 149:156823d33999 1284 }
<> 149:156823d33999 1285 }
<> 149:156823d33999 1286 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 1287
<> 149:156823d33999 1288 /* Clear the EXTI's Flag for RTC TimeStamp and Tamper */
<> 149:156823d33999 1289 __HAL_RTC_TAMPER_TIMESTAMP_EXTI_CLEAR_FLAG();
<> 149:156823d33999 1290
<> 149:156823d33999 1291 /* Change RTC state */
<> 149:156823d33999 1292 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 1293 }
<> 149:156823d33999 1294
<> 149:156823d33999 1295 /**
<> 149:156823d33999 1296 * @brief TimeStamp callback.
<> 149:156823d33999 1297 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1298 * the configuration information for RTC.
<> 149:156823d33999 1299 * @retval None
<> 149:156823d33999 1300 */
<> 149:156823d33999 1301 __weak void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc)
<> 149:156823d33999 1302 {
<> 149:156823d33999 1303 /* Prevent unused argument(s) compilation warning */
<> 149:156823d33999 1304 UNUSED(hrtc);
<> 149:156823d33999 1305
<> 149:156823d33999 1306 /* NOTE : This function Should not be modified, when the callback is needed,
<> 149:156823d33999 1307 the HAL_RTCEx_TimeStampEventCallback could be implemented in the user file
<> 149:156823d33999 1308 */
<> 149:156823d33999 1309 }
<> 149:156823d33999 1310
<> 149:156823d33999 1311 /**
<> 149:156823d33999 1312 * @brief Tamper 1 callback.
<> 149:156823d33999 1313 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1314 * the configuration information for RTC.
<> 149:156823d33999 1315 * @retval None
<> 149:156823d33999 1316 */
<> 149:156823d33999 1317 __weak void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc)
<> 149:156823d33999 1318 {
<> 149:156823d33999 1319 /* Prevent unused argument(s) compilation warning */
<> 149:156823d33999 1320 UNUSED(hrtc);
<> 149:156823d33999 1321
<> 149:156823d33999 1322 /* NOTE : This function Should not be modified, when the callback is needed,
<> 149:156823d33999 1323 the HAL_RTCEx_Tamper1EventCallback could be implemented in the user file
<> 149:156823d33999 1324 */
<> 149:156823d33999 1325 }
<> 149:156823d33999 1326
<> 149:156823d33999 1327 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 1328 /**
<> 149:156823d33999 1329 * @brief Tamper 2 callback.
<> 149:156823d33999 1330 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1331 * the configuration information for RTC.
<> 149:156823d33999 1332 * @retval None
<> 149:156823d33999 1333 */
<> 149:156823d33999 1334 __weak void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc)
<> 149:156823d33999 1335 {
<> 149:156823d33999 1336 /* Prevent unused argument(s) compilation warning */
<> 149:156823d33999 1337 UNUSED(hrtc);
<> 149:156823d33999 1338
<> 149:156823d33999 1339 /* NOTE : This function should not be modified, when the callback is needed,
<> 149:156823d33999 1340 the HAL_RTCEx_Tamper2EventCallback could be implemented in the user file
<> 149:156823d33999 1341 */
<> 149:156823d33999 1342 }
<> 149:156823d33999 1343
<> 149:156823d33999 1344 /**
<> 149:156823d33999 1345 * @brief Tamper 3 callback.
<> 149:156823d33999 1346 * @param hrtc: RTC handle
<> 149:156823d33999 1347 * @retval None
<> 149:156823d33999 1348 */
<> 149:156823d33999 1349 __weak void HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef *hrtc)
<> 149:156823d33999 1350 {
<> 149:156823d33999 1351 /* Prevent unused argument(s) compilation warning */
<> 149:156823d33999 1352 UNUSED(hrtc);
<> 149:156823d33999 1353
<> 149:156823d33999 1354 /* NOTE : This function Should not be modified, when the callback is needed,
<> 149:156823d33999 1355 the HAL_RTCEx_Tamper3EventCallback could be implemented in the user file
<> 149:156823d33999 1356 */
<> 149:156823d33999 1357 }
<> 149:156823d33999 1358 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 1359
<> 149:156823d33999 1360 /**
<> 149:156823d33999 1361 * @brief This function handles TimeStamp polling request.
<> 149:156823d33999 1362 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1363 * the configuration information for RTC.
<> 149:156823d33999 1364 * @param Timeout: Timeout duration
<> 149:156823d33999 1365 * @retval HAL status
<> 149:156823d33999 1366 */
<> 149:156823d33999 1367 HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
<> 149:156823d33999 1368 {
<> 149:156823d33999 1369 uint32_t tickstart = HAL_GetTick();
<> 149:156823d33999 1370
<> 149:156823d33999 1371 while(__HAL_RTC_TIMESTAMP_GET_FLAG(hrtc, RTC_FLAG_TSF) == RESET)
<> 149:156823d33999 1372 {
<> 149:156823d33999 1373 if(__HAL_RTC_TIMESTAMP_GET_FLAG(hrtc, RTC_FLAG_TSOVF) != RESET)
<> 149:156823d33999 1374 {
<> 149:156823d33999 1375 /* Clear the TIMESTAMP OverRun Flag */
<> 149:156823d33999 1376 __HAL_RTC_TIMESTAMP_CLEAR_FLAG(hrtc, RTC_FLAG_TSOVF);
<> 149:156823d33999 1377
<> 149:156823d33999 1378 /* Change TIMESTAMP state */
<> 149:156823d33999 1379 hrtc->State = HAL_RTC_STATE_ERROR;
<> 149:156823d33999 1380
<> 149:156823d33999 1381 return HAL_ERROR;
<> 149:156823d33999 1382 }
<> 149:156823d33999 1383
<> 149:156823d33999 1384 if(Timeout != HAL_MAX_DELAY)
<> 149:156823d33999 1385 {
<> 149:156823d33999 1386 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
<> 149:156823d33999 1387 {
<> 149:156823d33999 1388 hrtc->State = HAL_RTC_STATE_TIMEOUT;
<> 149:156823d33999 1389 return HAL_TIMEOUT;
<> 149:156823d33999 1390 }
<> 149:156823d33999 1391 }
<> 149:156823d33999 1392 }
<> 149:156823d33999 1393
<> 149:156823d33999 1394 /* Change RTC state */
<> 149:156823d33999 1395 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 1396
<> 149:156823d33999 1397 return HAL_OK;
<> 149:156823d33999 1398 }
<> 149:156823d33999 1399
<> 149:156823d33999 1400 /**
<> 149:156823d33999 1401 * @brief This function handles Tamper1 Polling.
<> 149:156823d33999 1402 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1403 * the configuration information for RTC.
<> 149:156823d33999 1404 * @param Timeout: Timeout duration
<> 149:156823d33999 1405 * @retval HAL status
<> 149:156823d33999 1406 */
<> 149:156823d33999 1407 HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
<> 149:156823d33999 1408 {
<> 149:156823d33999 1409 uint32_t tickstart = HAL_GetTick();
<> 149:156823d33999 1410
<> 149:156823d33999 1411 /* Get the status of the Interrupt */
<> 149:156823d33999 1412 while(__HAL_RTC_TAMPER_GET_FLAG(hrtc,RTC_FLAG_TAMP1F)== RESET)
<> 149:156823d33999 1413 {
<> 149:156823d33999 1414 if(Timeout != HAL_MAX_DELAY)
<> 149:156823d33999 1415 {
<> 149:156823d33999 1416 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
<> 149:156823d33999 1417 {
<> 149:156823d33999 1418 hrtc->State = HAL_RTC_STATE_TIMEOUT;
<> 149:156823d33999 1419 return HAL_TIMEOUT;
<> 149:156823d33999 1420 }
<> 149:156823d33999 1421 }
<> 149:156823d33999 1422 }
<> 149:156823d33999 1423
<> 149:156823d33999 1424 /* Clear the Tamper Flag */
<> 149:156823d33999 1425 __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc,RTC_FLAG_TAMP1F);
<> 149:156823d33999 1426
<> 149:156823d33999 1427 /* Change RTC state */
<> 149:156823d33999 1428 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 1429
<> 149:156823d33999 1430 return HAL_OK;
<> 149:156823d33999 1431 }
<> 149:156823d33999 1432
<> 149:156823d33999 1433 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 1434 /**
<> 149:156823d33999 1435 * @brief This function handles Tamper2 Polling.
<> 149:156823d33999 1436 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1437 * the configuration information for RTC.
<> 149:156823d33999 1438 * @param Timeout: Timeout duration
<> 149:156823d33999 1439 * @retval HAL status
<> 149:156823d33999 1440 */
<> 149:156823d33999 1441 HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
<> 149:156823d33999 1442 {
<> 149:156823d33999 1443 uint32_t tickstart = HAL_GetTick();
<> 149:156823d33999 1444
<> 149:156823d33999 1445 /* Get the status of the Interrupt */
<> 149:156823d33999 1446 while(__HAL_RTC_TAMPER_GET_FLAG(hrtc,RTC_FLAG_TAMP2F) == RESET)
<> 149:156823d33999 1447 {
<> 149:156823d33999 1448 if(Timeout != HAL_MAX_DELAY)
<> 149:156823d33999 1449 {
<> 149:156823d33999 1450 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
<> 149:156823d33999 1451 {
<> 149:156823d33999 1452 hrtc->State = HAL_RTC_STATE_TIMEOUT;
<> 149:156823d33999 1453 return HAL_TIMEOUT;
<> 149:156823d33999 1454 }
<> 149:156823d33999 1455 }
<> 149:156823d33999 1456 }
<> 149:156823d33999 1457
<> 149:156823d33999 1458 /* Clear the Tamper Flag */
<> 149:156823d33999 1459 __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc,RTC_FLAG_TAMP2F);
<> 149:156823d33999 1460
<> 149:156823d33999 1461 /* Change RTC state */
<> 149:156823d33999 1462 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 1463
<> 149:156823d33999 1464 return HAL_OK;
<> 149:156823d33999 1465 }
<> 149:156823d33999 1466
<> 149:156823d33999 1467 /**
<> 149:156823d33999 1468 * @brief This function handles Tamper3 Polling.
<> 149:156823d33999 1469 * @param hrtc: RTC handle
<> 149:156823d33999 1470 * @param Timeout: Timeout duration
<> 149:156823d33999 1471 * @retval HAL status
<> 149:156823d33999 1472 */
<> 149:156823d33999 1473 HAL_StatusTypeDef HAL_RTCEx_PollForTamper3Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
<> 149:156823d33999 1474 {
<> 149:156823d33999 1475 uint32_t tickstart = HAL_GetTick();
<> 149:156823d33999 1476
<> 149:156823d33999 1477 /* Get the status of the Interrupt */
<> 149:156823d33999 1478 while(__HAL_RTC_TAMPER_GET_FLAG(hrtc,RTC_FLAG_TAMP3F) == RESET)
<> 149:156823d33999 1479 {
<> 149:156823d33999 1480 if(Timeout != HAL_MAX_DELAY)
<> 149:156823d33999 1481 {
<> 149:156823d33999 1482 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
<> 149:156823d33999 1483 {
<> 149:156823d33999 1484 hrtc->State = HAL_RTC_STATE_TIMEOUT;
<> 149:156823d33999 1485 return HAL_TIMEOUT;
<> 149:156823d33999 1486 }
<> 149:156823d33999 1487 }
<> 149:156823d33999 1488 }
<> 149:156823d33999 1489
<> 149:156823d33999 1490 /* Clear the Tamper Flag */
<> 149:156823d33999 1491 __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc,RTC_FLAG_TAMP3F);
<> 149:156823d33999 1492
<> 149:156823d33999 1493 /* Change RTC state */
<> 149:156823d33999 1494 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 1495
<> 149:156823d33999 1496 return HAL_OK;
<> 149:156823d33999 1497 }
<> 149:156823d33999 1498 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 1499
<> 149:156823d33999 1500 /**
<> 149:156823d33999 1501 * @}
<> 149:156823d33999 1502 */
<> 149:156823d33999 1503
<> 149:156823d33999 1504 /** @defgroup RTCEx_Exported_Functions_Group5 RTC Wake-up functions
<> 149:156823d33999 1505 * @brief RTC Wake-up functions
<> 149:156823d33999 1506 *
<> 149:156823d33999 1507 @verbatim
<> 149:156823d33999 1508 ===============================================================================
<> 149:156823d33999 1509 ##### RTC Wake-up functions #####
<> 149:156823d33999 1510 ===============================================================================
<> 149:156823d33999 1511
<> 149:156823d33999 1512 [..] This section provides functions allowing to configure Wake-up feature
<> 149:156823d33999 1513
<> 149:156823d33999 1514 @endverbatim
<> 149:156823d33999 1515 * @{
<> 149:156823d33999 1516 */
<> 149:156823d33999 1517
<> 149:156823d33999 1518 /**
<> 149:156823d33999 1519 * @brief Set wake up timer.
<> 149:156823d33999 1520 * @param hrtc: RTC handle
<> 149:156823d33999 1521 * @param WakeUpCounter: Wake up counter
<> 149:156823d33999 1522 * @param WakeUpClock: Wake up clock
<> 149:156823d33999 1523 * @retval HAL status
<> 149:156823d33999 1524 */
<> 149:156823d33999 1525 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock)
<> 149:156823d33999 1526 {
<> 149:156823d33999 1527 uint32_t tickstart = 0;
<> 149:156823d33999 1528
<> 149:156823d33999 1529 /* Check the parameters */
<> 149:156823d33999 1530 assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock));
<> 149:156823d33999 1531 assert_param(IS_RTC_WAKEUP_COUNTER(WakeUpCounter));
<> 149:156823d33999 1532
<> 149:156823d33999 1533 /* Process Locked */
<> 149:156823d33999 1534 __HAL_LOCK(hrtc);
<> 149:156823d33999 1535
<> 149:156823d33999 1536 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 1537
<> 149:156823d33999 1538 /* Disable the write protection for RTC registers */
<> 149:156823d33999 1539 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
<> 149:156823d33999 1540
<> 149:156823d33999 1541 /*Check RTC WUTWF flag is reset only when wake up timer enabled*/
<> 149:156823d33999 1542 if((hrtc->Instance->CR & RTC_CR_WUTE) != RESET){
<> 149:156823d33999 1543 tickstart = HAL_GetTick();
<> 149:156823d33999 1544
<> 149:156823d33999 1545 /* Wait till RTC WUTWF flag is reset and if Time out is reached exit */
<> 149:156823d33999 1546 while(__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTWF) == SET)
<> 149:156823d33999 1547 {
<> 149:156823d33999 1548 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
<> 149:156823d33999 1549 {
<> 149:156823d33999 1550 /* Enable the write protection for RTC registers */
<> 149:156823d33999 1551 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 1552
<> 149:156823d33999 1553 hrtc->State = HAL_RTC_STATE_TIMEOUT;
<> 149:156823d33999 1554
<> 149:156823d33999 1555 /* Process Unlocked */
<> 149:156823d33999 1556 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 1557
<> 149:156823d33999 1558 return HAL_TIMEOUT;
<> 149:156823d33999 1559 }
<> 149:156823d33999 1560 }
<> 149:156823d33999 1561 }
<> 149:156823d33999 1562
<> 149:156823d33999 1563 __HAL_RTC_WAKEUPTIMER_DISABLE(hrtc);
<> 149:156823d33999 1564
<> 149:156823d33999 1565 tickstart = HAL_GetTick();
<> 149:156823d33999 1566
<> 149:156823d33999 1567 /* Wait till RTC WUTWF flag is set and if Time out is reached exit */
<> 149:156823d33999 1568 while(__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTWF) == RESET)
<> 149:156823d33999 1569 {
<> 149:156823d33999 1570 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
<> 149:156823d33999 1571 {
<> 149:156823d33999 1572 /* Enable the write protection for RTC registers */
<> 149:156823d33999 1573 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 1574
<> 149:156823d33999 1575 hrtc->State = HAL_RTC_STATE_TIMEOUT;
<> 149:156823d33999 1576
<> 149:156823d33999 1577 /* Process Unlocked */
<> 149:156823d33999 1578 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 1579
<> 149:156823d33999 1580 return HAL_TIMEOUT;
<> 149:156823d33999 1581 }
<> 149:156823d33999 1582 }
<> 149:156823d33999 1583
<> 149:156823d33999 1584 /* Clear the Wakeup Timer clock source bits in CR register */
<> 149:156823d33999 1585 hrtc->Instance->CR &= (uint32_t)~RTC_CR_WUCKSEL;
<> 149:156823d33999 1586
<> 149:156823d33999 1587 /* Configure the clock source */
<> 149:156823d33999 1588 hrtc->Instance->CR |= (uint32_t)WakeUpClock;
<> 149:156823d33999 1589
<> 149:156823d33999 1590 /* Configure the Wakeup Timer counter */
<> 149:156823d33999 1591 hrtc->Instance->WUTR = (uint32_t)WakeUpCounter;
<> 149:156823d33999 1592
<> 149:156823d33999 1593 /* Enable the Wakeup Timer */
<> 149:156823d33999 1594 __HAL_RTC_WAKEUPTIMER_ENABLE(hrtc);
<> 149:156823d33999 1595
<> 149:156823d33999 1596 /* Enable the write protection for RTC registers */
<> 149:156823d33999 1597 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 1598
<> 149:156823d33999 1599 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 1600
<> 149:156823d33999 1601 /* Process Unlocked */
<> 149:156823d33999 1602 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 1603
<> 149:156823d33999 1604 return HAL_OK;
<> 149:156823d33999 1605 }
<> 149:156823d33999 1606
<> 149:156823d33999 1607 /**
<> 149:156823d33999 1608 * @brief Set wake up timer with interrupt.
<> 149:156823d33999 1609 * @param hrtc: RTC handle
<> 149:156823d33999 1610 * @param WakeUpCounter: Wake up counter
<> 149:156823d33999 1611 * @param WakeUpClock: Wake up clock
<> 149:156823d33999 1612 * @retval HAL status
<> 149:156823d33999 1613 */
<> 149:156823d33999 1614 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock)
<> 149:156823d33999 1615 {
<> 149:156823d33999 1616 uint32_t tickstart = 0;
<> 149:156823d33999 1617
<> 149:156823d33999 1618 /* Check the parameters */
<> 149:156823d33999 1619 assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock));
<> 149:156823d33999 1620 assert_param(IS_RTC_WAKEUP_COUNTER(WakeUpCounter));
<> 149:156823d33999 1621
<> 149:156823d33999 1622 /* Process Locked */
<> 149:156823d33999 1623 __HAL_LOCK(hrtc);
<> 149:156823d33999 1624
<> 149:156823d33999 1625 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 1626
<> 149:156823d33999 1627 /* Disable the write protection for RTC registers */
<> 149:156823d33999 1628 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
<> 149:156823d33999 1629
<> 149:156823d33999 1630 /*Check RTC WUTWF flag is reset only when wake up timer enabled*/
<> 149:156823d33999 1631 if((hrtc->Instance->CR & RTC_CR_WUTE) != RESET){
<> 149:156823d33999 1632 tickstart = HAL_GetTick();
<> 149:156823d33999 1633
<> 149:156823d33999 1634 /* Wait till RTC WUTWF flag is reset and if Time out is reached exit */
<> 149:156823d33999 1635 while(__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTWF) == SET)
<> 149:156823d33999 1636 {
<> 149:156823d33999 1637 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
<> 149:156823d33999 1638 {
<> 149:156823d33999 1639 /* Enable the write protection for RTC registers */
<> 149:156823d33999 1640 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 1641
<> 149:156823d33999 1642 hrtc->State = HAL_RTC_STATE_TIMEOUT;
<> 149:156823d33999 1643
<> 149:156823d33999 1644 /* Process Unlocked */
<> 149:156823d33999 1645 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 1646
<> 149:156823d33999 1647 return HAL_TIMEOUT;
<> 149:156823d33999 1648 }
<> 149:156823d33999 1649 }
<> 149:156823d33999 1650 }
<> 149:156823d33999 1651
<> 149:156823d33999 1652 /* Disable the Wake-Up timer */
<> 149:156823d33999 1653 __HAL_RTC_WAKEUPTIMER_DISABLE(hrtc);
<> 149:156823d33999 1654
<> 149:156823d33999 1655 /* Clear flag Wake-Up */
<> 149:156823d33999 1656 __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(hrtc, RTC_FLAG_WUTF);
<> 149:156823d33999 1657
<> 149:156823d33999 1658 tickstart = HAL_GetTick();
<> 149:156823d33999 1659
<> 149:156823d33999 1660 /* Wait till RTC WUTWF flag is set and if Time out is reached exit */
<> 149:156823d33999 1661 while(__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTWF) == RESET)
<> 149:156823d33999 1662 {
<> 149:156823d33999 1663 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
<> 149:156823d33999 1664 {
<> 149:156823d33999 1665 /* Enable the write protection for RTC registers */
<> 149:156823d33999 1666 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 1667
<> 149:156823d33999 1668 hrtc->State = HAL_RTC_STATE_TIMEOUT;
<> 149:156823d33999 1669
<> 149:156823d33999 1670 /* Process Unlocked */
<> 149:156823d33999 1671 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 1672
<> 149:156823d33999 1673 return HAL_TIMEOUT;
<> 149:156823d33999 1674 }
<> 149:156823d33999 1675 }
<> 149:156823d33999 1676
<> 149:156823d33999 1677 /* Configure the Wakeup Timer counter */
<> 149:156823d33999 1678 hrtc->Instance->WUTR = (uint32_t)WakeUpCounter;
<> 149:156823d33999 1679
<> 149:156823d33999 1680 /* Clear the Wakeup Timer clock source bits in CR register */
<> 149:156823d33999 1681 hrtc->Instance->CR &= (uint32_t)~RTC_CR_WUCKSEL;
<> 149:156823d33999 1682
<> 149:156823d33999 1683 /* Configure the clock source */
<> 149:156823d33999 1684 hrtc->Instance->CR |= (uint32_t)WakeUpClock;
<> 149:156823d33999 1685
<> 149:156823d33999 1686 /* RTC WakeUpTimer Interrupt Configuration: EXTI configuration */
<> 149:156823d33999 1687 __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT();
<> 149:156823d33999 1688
<> 149:156823d33999 1689 __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE();
<> 149:156823d33999 1690
<> 149:156823d33999 1691 /* Configure the Interrupt in the RTC_CR register */
<> 149:156823d33999 1692 __HAL_RTC_WAKEUPTIMER_ENABLE_IT(hrtc,RTC_IT_WUT);
<> 149:156823d33999 1693
<> 149:156823d33999 1694 /* Enable the Wakeup Timer */
<> 149:156823d33999 1695 __HAL_RTC_WAKEUPTIMER_ENABLE(hrtc);
<> 149:156823d33999 1696
<> 149:156823d33999 1697 /* Enable the write protection for RTC registers */
<> 149:156823d33999 1698 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 1699
<> 149:156823d33999 1700 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 1701
<> 149:156823d33999 1702 /* Process Unlocked */
<> 149:156823d33999 1703 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 1704
<> 149:156823d33999 1705 return HAL_OK;
<> 149:156823d33999 1706 }
<> 149:156823d33999 1707
<> 149:156823d33999 1708 /**
<> 149:156823d33999 1709 * @brief Deactivates wake up timer counter.
<> 149:156823d33999 1710 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1711 * the configuration information for RTC.
<> 149:156823d33999 1712 * @retval HAL status
<> 149:156823d33999 1713 */
<> 149:156823d33999 1714 uint32_t HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc)
<> 149:156823d33999 1715 {
<> 149:156823d33999 1716 uint32_t tickstart = 0;
<> 149:156823d33999 1717
<> 149:156823d33999 1718 /* Process Locked */
<> 149:156823d33999 1719 __HAL_LOCK(hrtc);
<> 149:156823d33999 1720
<> 149:156823d33999 1721 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 1722
<> 149:156823d33999 1723 /* Disable the write protection for RTC registers */
<> 149:156823d33999 1724 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
<> 149:156823d33999 1725
<> 149:156823d33999 1726 /* Disable the Wakeup Timer */
<> 149:156823d33999 1727 __HAL_RTC_WAKEUPTIMER_DISABLE(hrtc);
<> 149:156823d33999 1728
<> 149:156823d33999 1729 /* In case of interrupt mode is used, the interrupt source must disabled */
<> 149:156823d33999 1730 __HAL_RTC_WAKEUPTIMER_DISABLE_IT(hrtc,RTC_IT_WUT);
<> 149:156823d33999 1731
<> 149:156823d33999 1732 tickstart = HAL_GetTick();
<> 149:156823d33999 1733 /* Wait till RTC WUTWF flag is set and if Time out is reached exit */
<> 149:156823d33999 1734 while(__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTWF) == RESET)
<> 149:156823d33999 1735 {
<> 149:156823d33999 1736 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
<> 149:156823d33999 1737 {
<> 149:156823d33999 1738 /* Enable the write protection for RTC registers */
<> 149:156823d33999 1739 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 1740
<> 149:156823d33999 1741 hrtc->State = HAL_RTC_STATE_TIMEOUT;
<> 149:156823d33999 1742
<> 149:156823d33999 1743 /* Process Unlocked */
<> 149:156823d33999 1744 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 1745
<> 149:156823d33999 1746 return HAL_TIMEOUT;
<> 149:156823d33999 1747 }
<> 149:156823d33999 1748 }
<> 149:156823d33999 1749
<> 149:156823d33999 1750 /* Enable the write protection for RTC registers */
<> 149:156823d33999 1751 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 1752
<> 149:156823d33999 1753 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 1754
<> 149:156823d33999 1755 /* Process Unlocked */
<> 149:156823d33999 1756 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 1757
<> 149:156823d33999 1758 return HAL_OK;
<> 149:156823d33999 1759 }
<> 149:156823d33999 1760
<> 149:156823d33999 1761 /**
<> 149:156823d33999 1762 * @brief Gets wake up timer counter.
<> 149:156823d33999 1763 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1764 * the configuration information for RTC.
<> 149:156823d33999 1765 * @retval Counter value
<> 149:156823d33999 1766 */
<> 149:156823d33999 1767 uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc)
<> 149:156823d33999 1768 {
<> 149:156823d33999 1769 /* Get the counter value */
<> 149:156823d33999 1770 return ((uint32_t)(hrtc->Instance->WUTR & RTC_WUTR_WUT));
<> 149:156823d33999 1771 }
<> 149:156823d33999 1772
<> 149:156823d33999 1773 /**
<> 149:156823d33999 1774 * @brief This function handles Wake Up Timer interrupt request.
<> 149:156823d33999 1775 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1776 * the configuration information for RTC.
<> 149:156823d33999 1777 * @retval None
<> 149:156823d33999 1778 */
<> 149:156823d33999 1779 void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc)
<> 149:156823d33999 1780 {
<> 149:156823d33999 1781 /* Get the pending status of the WAKEUPTIMER Interrupt */
<> 149:156823d33999 1782 if(__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTF) != RESET)
<> 149:156823d33999 1783 {
<> 149:156823d33999 1784 /* WAKEUPTIMER callback */
<> 149:156823d33999 1785 HAL_RTCEx_WakeUpTimerEventCallback(hrtc);
<> 149:156823d33999 1786
<> 149:156823d33999 1787 /* Clear the WAKEUPTIMER interrupt pending bit */
<> 149:156823d33999 1788 __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(hrtc, RTC_FLAG_WUTF);
<> 149:156823d33999 1789 }
<> 149:156823d33999 1790
<> 149:156823d33999 1791
<> 149:156823d33999 1792 /* Clear the EXTI's line Flag for RTC WakeUpTimer */
<> 149:156823d33999 1793 __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG();
<> 149:156823d33999 1794
<> 149:156823d33999 1795 /* Change RTC state */
<> 149:156823d33999 1796 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 1797 }
<> 149:156823d33999 1798
<> 149:156823d33999 1799 /**
<> 149:156823d33999 1800 * @brief Wake Up Timer callback.
<> 149:156823d33999 1801 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1802 * the configuration information for RTC.
<> 149:156823d33999 1803 * @retval None
<> 149:156823d33999 1804 */
<> 149:156823d33999 1805 __weak void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc)
<> 149:156823d33999 1806 {
<> 149:156823d33999 1807 /* Prevent unused argument(s) compilation warning */
<> 149:156823d33999 1808 UNUSED(hrtc);
<> 149:156823d33999 1809
<> 149:156823d33999 1810 /* NOTE : This function Should not be modified, when the callback is needed,
<> 149:156823d33999 1811 the HAL_RTCEx_WakeUpTimerEventCallback could be implemented in the user file
<> 149:156823d33999 1812 */
<> 149:156823d33999 1813 }
<> 149:156823d33999 1814
<> 149:156823d33999 1815 /**
<> 149:156823d33999 1816 * @brief This function handles Wake Up Timer Polling.
<> 149:156823d33999 1817 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1818 * the configuration information for RTC.
<> 149:156823d33999 1819 * @param Timeout: Timeout duration
<> 149:156823d33999 1820 * @retval HAL status
<> 149:156823d33999 1821 */
<> 149:156823d33999 1822 HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
<> 149:156823d33999 1823 {
<> 149:156823d33999 1824 uint32_t tickstart = HAL_GetTick();
<> 149:156823d33999 1825
<> 149:156823d33999 1826 while(__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTF) == RESET)
<> 149:156823d33999 1827 {
<> 149:156823d33999 1828 if(Timeout != HAL_MAX_DELAY)
<> 149:156823d33999 1829 {
<> 149:156823d33999 1830 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
<> 149:156823d33999 1831 {
<> 149:156823d33999 1832 hrtc->State = HAL_RTC_STATE_TIMEOUT;
<> 149:156823d33999 1833
<> 149:156823d33999 1834 return HAL_TIMEOUT;
<> 149:156823d33999 1835 }
<> 149:156823d33999 1836 }
<> 149:156823d33999 1837 }
<> 149:156823d33999 1838
<> 149:156823d33999 1839 /* Clear the WAKEUPTIMER Flag */
<> 149:156823d33999 1840 __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(hrtc, RTC_FLAG_WUTF);
<> 149:156823d33999 1841
<> 149:156823d33999 1842 /* Change RTC state */
<> 149:156823d33999 1843 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 1844
<> 149:156823d33999 1845 return HAL_OK;
<> 149:156823d33999 1846 }
<> 149:156823d33999 1847
<> 149:156823d33999 1848 /**
<> 149:156823d33999 1849 * @}
<> 149:156823d33999 1850 */
<> 149:156823d33999 1851
<> 149:156823d33999 1852 /** @defgroup RTCEx_Exported_Functions_Group7 Extended Peripheral Control functions
<> 149:156823d33999 1853 * @brief Extended Peripheral Control functions
<> 149:156823d33999 1854 *
<> 149:156823d33999 1855 @verbatim
<> 149:156823d33999 1856 ===============================================================================
<> 149:156823d33999 1857 ##### Extension Peripheral Control functions #####
<> 149:156823d33999 1858 ===============================================================================
<> 149:156823d33999 1859 [..]
<> 149:156823d33999 1860 This subsection provides functions allowing to
<> 149:156823d33999 1861 (+) Writes a data in a specified RTC Backup data register
<> 149:156823d33999 1862 (+) Read a data in a specified RTC Backup data register
<> 149:156823d33999 1863 (+) Sets the Coarse calibration parameters.
<> 149:156823d33999 1864 (+) Deactivates the Coarse calibration parameters
<> 149:156823d33999 1865 (+) Sets the Smooth calibration parameters.
<> 149:156823d33999 1866 (+) Configures the Synchronization Shift Control Settings.
<> 149:156823d33999 1867 (+) Configures the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz).
<> 149:156823d33999 1868 (+) Deactivates the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz).
<> 149:156823d33999 1869 (+) Enables the RTC reference clock detection.
<> 149:156823d33999 1870 (+) Disable the RTC reference clock detection.
<> 149:156823d33999 1871 (+) Enables the Bypass Shadow feature.
<> 149:156823d33999 1872 (+) Disables the Bypass Shadow feature.
<> 149:156823d33999 1873
<> 149:156823d33999 1874 @endverbatim
<> 149:156823d33999 1875 * @{
<> 149:156823d33999 1876 */
<> 149:156823d33999 1877
<> 149:156823d33999 1878 /**
<> 149:156823d33999 1879 * @brief Writes a data in a specified RTC Backup data register.
<> 149:156823d33999 1880 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1881 * the configuration information for RTC.
<> 149:156823d33999 1882 * @param BackupRegister: RTC Backup data Register number.
<> 149:156823d33999 1883 * This parameter can be: RTC_BKP_DRx where x can be from 0 to 19 to
<> 149:156823d33999 1884 * specify the register.
<> 149:156823d33999 1885 * @param Data: Data to be written in the specified RTC Backup data register.
<> 149:156823d33999 1886 * @retval None
<> 149:156823d33999 1887 */
<> 149:156823d33999 1888 void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data)
<> 149:156823d33999 1889 {
<> 149:156823d33999 1890 uint32_t tmp = 0;
<> 149:156823d33999 1891
<> 149:156823d33999 1892 /* Check the parameters */
<> 149:156823d33999 1893 assert_param(IS_RTC_BKP(BackupRegister));
<> 149:156823d33999 1894
<> 149:156823d33999 1895 tmp = (uint32_t)&(hrtc->Instance->BKP0R);
<> 149:156823d33999 1896 tmp += (BackupRegister * 4);
<> 149:156823d33999 1897
<> 149:156823d33999 1898 /* Write the specified register */
<> 149:156823d33999 1899 *(__IO uint32_t *)tmp = (uint32_t)Data;
<> 149:156823d33999 1900 }
<> 149:156823d33999 1901
<> 149:156823d33999 1902 /**
<> 149:156823d33999 1903 * @brief Reads data from the specified RTC Backup data Register.
<> 149:156823d33999 1904 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1905 * the configuration information for RTC.
<> 149:156823d33999 1906 * @param BackupRegister: RTC Backup data Register number.
<> 149:156823d33999 1907 * This parameter can be: RTC_BKP_DRx where x can be from 0 to 19 to
<> 149:156823d33999 1908 * specify the register.
<> 149:156823d33999 1909 * @retval Read value
<> 149:156823d33999 1910 */
<> 149:156823d33999 1911 uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister)
<> 149:156823d33999 1912 {
<> 149:156823d33999 1913 uint32_t tmp = 0;
<> 149:156823d33999 1914
<> 149:156823d33999 1915 /* Check the parameters */
<> 149:156823d33999 1916 assert_param(IS_RTC_BKP(BackupRegister));
<> 149:156823d33999 1917
<> 149:156823d33999 1918 tmp = (uint32_t)&(hrtc->Instance->BKP0R);
<> 149:156823d33999 1919 tmp += (BackupRegister * 4);
<> 149:156823d33999 1920
<> 149:156823d33999 1921 /* Read the specified register */
<> 149:156823d33999 1922 return (*(__IO uint32_t *)tmp);
<> 149:156823d33999 1923 }
<> 149:156823d33999 1924
<> 149:156823d33999 1925 /**
<> 149:156823d33999 1926 * @brief Sets the Coarse calibration parameters.
<> 149:156823d33999 1927 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1928 * the configuration information for RTC.
<> 149:156823d33999 1929 * @param CalibSign: Specifies the sign of the coarse calibration value.
<> 149:156823d33999 1930 * This parameter can be one of the following values :
<> 149:156823d33999 1931 * @arg RTC_CALIBSIGN_POSITIVE: The value sign is positive
<> 149:156823d33999 1932 * @arg RTC_CALIBSIGN_NEGATIVE: The value sign is negative
<> 149:156823d33999 1933 * @param Value: value of coarse calibration expressed in ppm (coded on 5 bits).
<> 149:156823d33999 1934 *
<> 149:156823d33999 1935 * @note This Calibration value should be between 0 and 63 when using negative
<> 149:156823d33999 1936 * sign with a 2-ppm step.
<> 149:156823d33999 1937 *
<> 149:156823d33999 1938 * @note This Calibration value should be between 0 and 126 when using positive
<> 149:156823d33999 1939 * sign with a 4-ppm step.
<> 149:156823d33999 1940 * @retval HAL status
<> 149:156823d33999 1941 */
<> 149:156823d33999 1942 HAL_StatusTypeDef HAL_RTCEx_SetCoarseCalib(RTC_HandleTypeDef* hrtc, uint32_t CalibSign, uint32_t Value)
<> 149:156823d33999 1943 {
<> 149:156823d33999 1944 /* Check the parameters */
<> 149:156823d33999 1945 assert_param(IS_RTC_CALIB_SIGN(CalibSign));
<> 149:156823d33999 1946 assert_param(IS_RTC_CALIB_VALUE(Value));
<> 149:156823d33999 1947
<> 149:156823d33999 1948 /* Process Locked */
<> 149:156823d33999 1949 __HAL_LOCK(hrtc);
<> 149:156823d33999 1950
<> 149:156823d33999 1951 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 1952
<> 149:156823d33999 1953 /* Disable the write protection for RTC registers */
<> 149:156823d33999 1954 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
<> 149:156823d33999 1955
<> 149:156823d33999 1956 /* Set Initialization mode */
<> 149:156823d33999 1957 if(RTC_EnterInitMode(hrtc) != HAL_OK)
<> 149:156823d33999 1958 {
<> 149:156823d33999 1959 /* Enable the write protection for RTC registers */
<> 149:156823d33999 1960 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 1961
<> 149:156823d33999 1962 /* Set RTC state*/
<> 149:156823d33999 1963 hrtc->State = HAL_RTC_STATE_ERROR;
<> 149:156823d33999 1964
<> 149:156823d33999 1965 /* Process Unlocked */
<> 149:156823d33999 1966 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 1967
<> 149:156823d33999 1968 return HAL_ERROR;
<> 149:156823d33999 1969 }
<> 149:156823d33999 1970 else
<> 149:156823d33999 1971 {
<> 149:156823d33999 1972 /* Enable the Coarse Calibration */
<> 149:156823d33999 1973 __HAL_RTC_COARSE_CALIB_ENABLE(hrtc);
<> 149:156823d33999 1974
<> 149:156823d33999 1975 /* Set the coarse calibration value */
<> 149:156823d33999 1976 hrtc->Instance->CALIBR = (uint32_t)(CalibSign|Value);
<> 149:156823d33999 1977
<> 149:156823d33999 1978 /* Exit Initialization mode */
<> 149:156823d33999 1979 hrtc->Instance->ISR &= (uint32_t)~RTC_ISR_INIT;
<> 149:156823d33999 1980 }
<> 149:156823d33999 1981
<> 149:156823d33999 1982 /* Enable the write protection for RTC registers */
<> 149:156823d33999 1983 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 1984
<> 149:156823d33999 1985 /* Change state */
<> 149:156823d33999 1986 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 1987
<> 149:156823d33999 1988 /* Process Unlocked */
<> 149:156823d33999 1989 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 1990
<> 149:156823d33999 1991 return HAL_OK;
<> 149:156823d33999 1992 }
<> 149:156823d33999 1993
<> 149:156823d33999 1994 /**
<> 149:156823d33999 1995 * @brief Deactivates the Coarse calibration parameters.
<> 149:156823d33999 1996 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 1997 * the configuration information for RTC.
<> 149:156823d33999 1998 * @retval HAL status
<> 149:156823d33999 1999 */
<> 149:156823d33999 2000 HAL_StatusTypeDef HAL_RTCEx_DeactivateCoarseCalib(RTC_HandleTypeDef* hrtc)
<> 149:156823d33999 2001 {
<> 149:156823d33999 2002 /* Process Locked */
<> 149:156823d33999 2003 __HAL_LOCK(hrtc);
<> 149:156823d33999 2004
<> 149:156823d33999 2005 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 2006
<> 149:156823d33999 2007 /* Disable the write protection for RTC registers */
<> 149:156823d33999 2008 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
<> 149:156823d33999 2009
<> 149:156823d33999 2010 /* Set Initialization mode */
<> 149:156823d33999 2011 if(RTC_EnterInitMode(hrtc) != HAL_OK)
<> 149:156823d33999 2012 {
<> 149:156823d33999 2013 /* Enable the write protection for RTC registers */
<> 149:156823d33999 2014 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 2015
<> 149:156823d33999 2016 /* Set RTC state*/
<> 149:156823d33999 2017 hrtc->State = HAL_RTC_STATE_ERROR;
<> 149:156823d33999 2018
<> 149:156823d33999 2019 /* Process Unlocked */
<> 149:156823d33999 2020 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 2021
<> 149:156823d33999 2022 return HAL_ERROR;
<> 149:156823d33999 2023 }
<> 149:156823d33999 2024 else
<> 149:156823d33999 2025 {
<> 149:156823d33999 2026 /* Enable the Coarse Calibration */
<> 149:156823d33999 2027 __HAL_RTC_COARSE_CALIB_DISABLE(hrtc);
<> 149:156823d33999 2028
<> 149:156823d33999 2029 /* Exit Initialization mode */
<> 149:156823d33999 2030 hrtc->Instance->ISR &= (uint32_t)~RTC_ISR_INIT;
<> 149:156823d33999 2031 }
<> 149:156823d33999 2032
<> 149:156823d33999 2033 /* Enable the write protection for RTC registers */
<> 149:156823d33999 2034 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 2035
<> 149:156823d33999 2036 /* Change state */
<> 149:156823d33999 2037 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 2038
<> 149:156823d33999 2039 /* Process Unlocked */
<> 149:156823d33999 2040 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 2041
<> 149:156823d33999 2042 return HAL_OK;
<> 149:156823d33999 2043 }
<> 149:156823d33999 2044
<> 149:156823d33999 2045 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 2046 /**
<> 149:156823d33999 2047 * @brief Sets the Smooth calibration parameters.
<> 149:156823d33999 2048 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 2049 * the configuration information for RTC.
<> 149:156823d33999 2050 * @param SmoothCalibPeriod: Select the Smooth Calibration Period.
<> 149:156823d33999 2051 * This parameter can be can be one of the following values :
<> 149:156823d33999 2052 * @arg RTC_SMOOTHCALIB_PERIOD_32SEC: The smooth calibration periode is 32s.
<> 149:156823d33999 2053 * @arg RTC_SMOOTHCALIB_PERIOD_16SEC: The smooth calibration periode is 16s.
<> 149:156823d33999 2054 * @arg RTC_SMOOTHCALIB_PERIOD_8SEC: The smooth calibartion periode is 8s.
<> 149:156823d33999 2055 * @param SmoothCalibPlusPulses: Select to Set or reset the CALP bit.
<> 149:156823d33999 2056 * This parameter can be one of the following values:
<> 149:156823d33999 2057 * @arg RTC_SMOOTHCALIB_PLUSPULSES_SET: Add one RTCCLK puls every 2*11 pulses.
<> 149:156823d33999 2058 * @arg RTC_SMOOTHCALIB_PLUSPULSES_RESET: No RTCCLK pulses are added.
<> 149:156823d33999 2059 * @param SmoothCalibMinusPulsesValue: Select the value of CALM[8:0] bits.
<> 149:156823d33999 2060 * This parameter can be one any value from 0 to 0x000001FF.
<> 149:156823d33999 2061 * @note To deactivate the smooth calibration, the field SmoothCalibPlusPulses
<> 149:156823d33999 2062 * must be equal to SMOOTHCALIB_PLUSPULSES_RESET and the field
<> 149:156823d33999 2063 * SmoothCalibMinusPulsesValue mut be equal to 0.
<> 149:156823d33999 2064 * @retval HAL status
<> 149:156823d33999 2065 */
<> 149:156823d33999 2066 HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef* hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue)
<> 149:156823d33999 2067 {
<> 149:156823d33999 2068 uint32_t tickstart = 0;
<> 149:156823d33999 2069
<> 149:156823d33999 2070 /* Check the parameters */
<> 149:156823d33999 2071 assert_param(IS_RTC_SMOOTH_CALIB_PERIOD(SmoothCalibPeriod));
<> 149:156823d33999 2072 assert_param(IS_RTC_SMOOTH_CALIB_PLUS(SmoothCalibPlusPulses));
<> 149:156823d33999 2073 assert_param(IS_RTC_SMOOTH_CALIB_MINUS(SmoothCalibMinusPulsesValue));
<> 149:156823d33999 2074
<> 149:156823d33999 2075 /* Process Locked */
<> 149:156823d33999 2076 __HAL_LOCK(hrtc);
<> 149:156823d33999 2077
<> 149:156823d33999 2078 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 2079
<> 149:156823d33999 2080 /* Disable the write protection for RTC registers */
<> 149:156823d33999 2081 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
<> 149:156823d33999 2082
<> 149:156823d33999 2083 /* check if a calibration is pending*/
<> 149:156823d33999 2084 if((hrtc->Instance->ISR & RTC_ISR_RECALPF) != RESET)
<> 149:156823d33999 2085 {
<> 149:156823d33999 2086 tickstart = HAL_GetTick();
<> 149:156823d33999 2087
<> 149:156823d33999 2088 /* check if a calibration is pending*/
<> 149:156823d33999 2089 while((hrtc->Instance->ISR & RTC_ISR_RECALPF) != RESET)
<> 149:156823d33999 2090 {
<> 149:156823d33999 2091 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
<> 149:156823d33999 2092 {
<> 149:156823d33999 2093 /* Enable the write protection for RTC registers */
<> 149:156823d33999 2094 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 2095
<> 149:156823d33999 2096 /* Change RTC state */
<> 149:156823d33999 2097 hrtc->State = HAL_RTC_STATE_TIMEOUT;
<> 149:156823d33999 2098
<> 149:156823d33999 2099 /* Process Unlocked */
<> 149:156823d33999 2100 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 2101
<> 149:156823d33999 2102 return HAL_TIMEOUT;
<> 149:156823d33999 2103 }
<> 149:156823d33999 2104 }
<> 149:156823d33999 2105 }
<> 149:156823d33999 2106
<> 149:156823d33999 2107 /* Configure the Smooth calibration settings */
<> 149:156823d33999 2108 hrtc->Instance->CALR = (uint32_t)((uint32_t)SmoothCalibPeriod | (uint32_t)SmoothCalibPlusPulses | (uint32_t)SmoothCalibMinusPulsesValue);
<> 149:156823d33999 2109
<> 149:156823d33999 2110 /* Enable the write protection for RTC registers */
<> 149:156823d33999 2111 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 2112
<> 149:156823d33999 2113 /* Change RTC state */
<> 149:156823d33999 2114 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 2115
<> 149:156823d33999 2116 /* Process Unlocked */
<> 149:156823d33999 2117 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 2118
<> 149:156823d33999 2119 return HAL_OK;
<> 149:156823d33999 2120 }
<> 149:156823d33999 2121
<> 149:156823d33999 2122 /**
<> 149:156823d33999 2123 * @brief Configures the Synchronization Shift Control Settings.
<> 149:156823d33999 2124 * @note When REFCKON is set, firmware must not write to Shift control register.
<> 149:156823d33999 2125 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 2126 * the configuration information for RTC.
<> 149:156823d33999 2127 * @param ShiftAdd1S: Select to add or not 1 second to the time calendar.
<> 149:156823d33999 2128 * This parameter can be one of the following values :
<> 149:156823d33999 2129 * @arg RTC_SHIFTADD1S_SET: Add one second to the clock calendar.
<> 149:156823d33999 2130 * @arg RTC_SHIFTADD1S_RESET: No effect.
<> 149:156823d33999 2131 * @param ShiftSubFS: Select the number of Second Fractions to substitute.
<> 149:156823d33999 2132 * This parameter can be one any value from 0 to 0x7FFF.
<> 149:156823d33999 2133 * @retval HAL status
<> 149:156823d33999 2134 */
<> 149:156823d33999 2135 HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef* hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS)
<> 149:156823d33999 2136 {
<> 149:156823d33999 2137 uint32_t tickstart = 0;
<> 149:156823d33999 2138
<> 149:156823d33999 2139 /* Check the parameters */
<> 149:156823d33999 2140 assert_param(IS_RTC_SHIFT_ADD1S(ShiftAdd1S));
<> 149:156823d33999 2141 assert_param(IS_RTC_SHIFT_SUBFS(ShiftSubFS));
<> 149:156823d33999 2142
<> 149:156823d33999 2143 /* Process Locked */
<> 149:156823d33999 2144 __HAL_LOCK(hrtc);
<> 149:156823d33999 2145
<> 149:156823d33999 2146 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 2147
<> 149:156823d33999 2148 /* Disable the write protection for RTC registers */
<> 149:156823d33999 2149 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
<> 149:156823d33999 2150
<> 149:156823d33999 2151 tickstart = HAL_GetTick();
<> 149:156823d33999 2152
<> 149:156823d33999 2153 /* Wait until the shift is completed*/
<> 149:156823d33999 2154 while((hrtc->Instance->ISR & RTC_ISR_SHPF) != RESET)
<> 149:156823d33999 2155 {
<> 149:156823d33999 2156 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
<> 149:156823d33999 2157 {
<> 149:156823d33999 2158 /* Enable the write protection for RTC registers */
<> 149:156823d33999 2159 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 2160
<> 149:156823d33999 2161 hrtc->State = HAL_RTC_STATE_TIMEOUT;
<> 149:156823d33999 2162
<> 149:156823d33999 2163 /* Process Unlocked */
<> 149:156823d33999 2164 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 2165
<> 149:156823d33999 2166 return HAL_TIMEOUT;
<> 149:156823d33999 2167 }
<> 149:156823d33999 2168 }
<> 149:156823d33999 2169
<> 149:156823d33999 2170 /* Check if the reference clock detection is disabled */
<> 149:156823d33999 2171 if((hrtc->Instance->CR & RTC_CR_REFCKON) == RESET)
<> 149:156823d33999 2172 {
<> 149:156823d33999 2173 /* Configure the Shift settings */
<> 149:156823d33999 2174 hrtc->Instance->SHIFTR = (uint32_t)(uint32_t)(ShiftSubFS) | (uint32_t)(ShiftAdd1S);
<> 149:156823d33999 2175
<> 149:156823d33999 2176 /* Wait for synchro */
<> 149:156823d33999 2177 if(HAL_RTC_WaitForSynchro(hrtc) != HAL_OK)
<> 149:156823d33999 2178 {
<> 149:156823d33999 2179 /* Enable the write protection for RTC registers */
<> 149:156823d33999 2180 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 2181
<> 149:156823d33999 2182 hrtc->State = HAL_RTC_STATE_ERROR;
<> 149:156823d33999 2183
<> 149:156823d33999 2184 /* Process Unlocked */
<> 149:156823d33999 2185 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 2186
<> 149:156823d33999 2187 return HAL_ERROR;
<> 149:156823d33999 2188 }
<> 149:156823d33999 2189 }
<> 149:156823d33999 2190 else
<> 149:156823d33999 2191 {
<> 149:156823d33999 2192 /* Enable the write protection for RTC registers */
<> 149:156823d33999 2193 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 2194
<> 149:156823d33999 2195 /* Change RTC state */
<> 149:156823d33999 2196 hrtc->State = HAL_RTC_STATE_ERROR;
<> 149:156823d33999 2197
<> 149:156823d33999 2198 /* Process Unlocked */
<> 149:156823d33999 2199 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 2200
<> 149:156823d33999 2201 return HAL_ERROR;
<> 149:156823d33999 2202 }
<> 149:156823d33999 2203
<> 149:156823d33999 2204 /* Enable the write protection for RTC registers */
<> 149:156823d33999 2205 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 2206
<> 149:156823d33999 2207 /* Change RTC state */
<> 149:156823d33999 2208 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 2209
<> 149:156823d33999 2210 /* Process Unlocked */
<> 149:156823d33999 2211 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 2212
<> 149:156823d33999 2213 return HAL_OK;
<> 149:156823d33999 2214 }
<> 149:156823d33999 2215 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 2216
<> 149:156823d33999 2217
<> 149:156823d33999 2218 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 2219 /**
<> 149:156823d33999 2220 * @brief Configures the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz).
<> 149:156823d33999 2221 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 2222 * the configuration information for RTC.
<> 149:156823d33999 2223 * @param CalibOutput : Select the Calibration output Selection .
<> 149:156823d33999 2224 * This parameter can be one of the following values:
<> 149:156823d33999 2225 * @arg RTC_CALIBOUTPUT_512HZ: A signal has a regular waveform at 512Hz.
<> 149:156823d33999 2226 * @arg RTC_CALIBOUTPUT_1HZ: A signal has a regular waveform at 1Hz.
<> 149:156823d33999 2227 * @retval HAL status
<> 149:156823d33999 2228 */
<> 149:156823d33999 2229 HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef* hrtc, uint32_t CalibOutput)
<> 149:156823d33999 2230 #else
<> 149:156823d33999 2231 /**
<> 149:156823d33999 2232 * @brief Configure the Calibration Pinout (RTC_CALIB).
<> 149:156823d33999 2233 * @param hrtc : RTC handle
<> 149:156823d33999 2234 * @retval HAL status
<> 149:156823d33999 2235 */
<> 149:156823d33999 2236 HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef* hrtc)
<> 149:156823d33999 2237 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 2238 {
<> 149:156823d33999 2239 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 2240 /* Check the parameters */
<> 149:156823d33999 2241 assert_param(IS_RTC_CALIB_OUTPUT(CalibOutput));
<> 149:156823d33999 2242 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 2243
<> 149:156823d33999 2244 /* Process Locked */
<> 149:156823d33999 2245 __HAL_LOCK(hrtc);
<> 149:156823d33999 2246
<> 149:156823d33999 2247 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 2248
<> 149:156823d33999 2249 /* Disable the write protection for RTC registers */
<> 149:156823d33999 2250 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
<> 149:156823d33999 2251
<> 149:156823d33999 2252 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 2253 /* Clear flags before config */
<> 149:156823d33999 2254 hrtc->Instance->CR &= (uint32_t)~RTC_CR_COSEL;
<> 149:156823d33999 2255
<> 149:156823d33999 2256 /* Configure the RTC_CR register */
<> 149:156823d33999 2257 hrtc->Instance->CR |= (uint32_t)CalibOutput;
<> 149:156823d33999 2258 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 2259
<> 149:156823d33999 2260 __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(hrtc);
<> 149:156823d33999 2261
<> 149:156823d33999 2262 /* Enable the write protection for RTC registers */
<> 149:156823d33999 2263 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 2264
<> 149:156823d33999 2265 /* Change RTC state */
<> 149:156823d33999 2266 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 2267
<> 149:156823d33999 2268 /* Process Unlocked */
<> 149:156823d33999 2269 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 2270
<> 149:156823d33999 2271 return HAL_OK;
<> 149:156823d33999 2272 }
<> 149:156823d33999 2273
<> 149:156823d33999 2274 /**
<> 149:156823d33999 2275 * @brief Deactivates the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz).
<> 149:156823d33999 2276 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 2277 * the configuration information for RTC.
<> 149:156823d33999 2278 * @retval HAL status
<> 149:156823d33999 2279 */
<> 149:156823d33999 2280 HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef* hrtc)
<> 149:156823d33999 2281 {
<> 149:156823d33999 2282 /* Process Locked */
<> 149:156823d33999 2283 __HAL_LOCK(hrtc);
<> 149:156823d33999 2284
<> 149:156823d33999 2285 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 2286
<> 149:156823d33999 2287 /* Disable the write protection for RTC registers */
<> 149:156823d33999 2288 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
<> 149:156823d33999 2289
<> 149:156823d33999 2290 __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(hrtc);
<> 149:156823d33999 2291
<> 149:156823d33999 2292 /* Enable the write protection for RTC registers */
<> 149:156823d33999 2293 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 2294
<> 149:156823d33999 2295 /* Change RTC state */
<> 149:156823d33999 2296 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 2297
<> 149:156823d33999 2298 /* Process Unlocked */
<> 149:156823d33999 2299 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 2300
<> 149:156823d33999 2301 return HAL_OK;
<> 149:156823d33999 2302 }
<> 149:156823d33999 2303
<> 149:156823d33999 2304 /**
<> 149:156823d33999 2305 * @brief Enables the RTC reference clock detection.
<> 149:156823d33999 2306 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 2307 * the configuration information for RTC.
<> 149:156823d33999 2308 * @retval HAL status
<> 149:156823d33999 2309 */
<> 149:156823d33999 2310 HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef* hrtc)
<> 149:156823d33999 2311 {
<> 149:156823d33999 2312 /* Process Locked */
<> 149:156823d33999 2313 __HAL_LOCK(hrtc);
<> 149:156823d33999 2314
<> 149:156823d33999 2315 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 2316
<> 149:156823d33999 2317 /* Disable the write protection for RTC registers */
<> 149:156823d33999 2318 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
<> 149:156823d33999 2319
<> 149:156823d33999 2320 /* Set Initialization mode */
<> 149:156823d33999 2321 if(RTC_EnterInitMode(hrtc) != HAL_OK)
<> 149:156823d33999 2322 {
<> 149:156823d33999 2323 /* Enable the write protection for RTC registers */
<> 149:156823d33999 2324 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 2325
<> 149:156823d33999 2326 /* Set RTC state*/
<> 149:156823d33999 2327 hrtc->State = HAL_RTC_STATE_ERROR;
<> 149:156823d33999 2328
<> 149:156823d33999 2329 /* Process Unlocked */
<> 149:156823d33999 2330 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 2331
<> 149:156823d33999 2332 return HAL_ERROR;
<> 149:156823d33999 2333 }
<> 149:156823d33999 2334 else
<> 149:156823d33999 2335 {
<> 149:156823d33999 2336 __HAL_RTC_CLOCKREF_DETECTION_ENABLE(hrtc);
<> 149:156823d33999 2337
<> 149:156823d33999 2338 /* Exit Initialization mode */
<> 149:156823d33999 2339 hrtc->Instance->ISR &= (uint32_t)~RTC_ISR_INIT;
<> 149:156823d33999 2340 }
<> 149:156823d33999 2341
<> 149:156823d33999 2342 /* Enable the write protection for RTC registers */
<> 149:156823d33999 2343 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 2344
<> 149:156823d33999 2345 /* Change RTC state */
<> 149:156823d33999 2346 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 2347
<> 149:156823d33999 2348 /* Process Unlocked */
<> 149:156823d33999 2349 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 2350
<> 149:156823d33999 2351 return HAL_OK;
<> 149:156823d33999 2352 }
<> 149:156823d33999 2353
<> 149:156823d33999 2354 /**
<> 149:156823d33999 2355 * @brief Disable the RTC reference clock detection.
<> 149:156823d33999 2356 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 2357 * the configuration information for RTC.
<> 149:156823d33999 2358 * @retval HAL status
<> 149:156823d33999 2359 */
<> 149:156823d33999 2360 HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef* hrtc)
<> 149:156823d33999 2361 {
<> 149:156823d33999 2362 /* Process Locked */
<> 149:156823d33999 2363 __HAL_LOCK(hrtc);
<> 149:156823d33999 2364
<> 149:156823d33999 2365 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 2366
<> 149:156823d33999 2367 /* Disable the write protection for RTC registers */
<> 149:156823d33999 2368 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
<> 149:156823d33999 2369
<> 149:156823d33999 2370 /* Set Initialization mode */
<> 149:156823d33999 2371 if(RTC_EnterInitMode(hrtc) != HAL_OK)
<> 149:156823d33999 2372 {
<> 149:156823d33999 2373 /* Enable the write protection for RTC registers */
<> 149:156823d33999 2374 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 2375
<> 149:156823d33999 2376 /* Set RTC state*/
<> 149:156823d33999 2377 hrtc->State = HAL_RTC_STATE_ERROR;
<> 149:156823d33999 2378
<> 149:156823d33999 2379 /* Process Unlocked */
<> 149:156823d33999 2380 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 2381
<> 149:156823d33999 2382 return HAL_ERROR;
<> 149:156823d33999 2383 }
<> 149:156823d33999 2384 else
<> 149:156823d33999 2385 {
<> 149:156823d33999 2386 __HAL_RTC_CLOCKREF_DETECTION_DISABLE(hrtc);
<> 149:156823d33999 2387
<> 149:156823d33999 2388 /* Exit Initialization mode */
<> 149:156823d33999 2389 hrtc->Instance->ISR &= (uint32_t)~RTC_ISR_INIT;
<> 149:156823d33999 2390 }
<> 149:156823d33999 2391
<> 149:156823d33999 2392 /* Enable the write protection for RTC registers */
<> 149:156823d33999 2393 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 2394
<> 149:156823d33999 2395 /* Change RTC state */
<> 149:156823d33999 2396 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 2397
<> 149:156823d33999 2398 /* Process Unlocked */
<> 149:156823d33999 2399 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 2400
<> 149:156823d33999 2401 return HAL_OK;
<> 149:156823d33999 2402 }
<> 149:156823d33999 2403
<> 149:156823d33999 2404 #if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
<> 149:156823d33999 2405 /**
<> 149:156823d33999 2406 * @brief Enables the Bypass Shadow feature.
<> 149:156823d33999 2407 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 2408 * the configuration information for RTC.
<> 149:156823d33999 2409 * @note When the Bypass Shadow is enabled the calendar value are taken
<> 149:156823d33999 2410 * directly from the Calendar counter.
<> 149:156823d33999 2411 * @retval HAL status
<> 149:156823d33999 2412 */
<> 149:156823d33999 2413 HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef* hrtc)
<> 149:156823d33999 2414 {
<> 149:156823d33999 2415 /* Process Locked */
<> 149:156823d33999 2416 __HAL_LOCK(hrtc);
<> 149:156823d33999 2417
<> 149:156823d33999 2418 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 2419
<> 149:156823d33999 2420 /* Disable the write protection for RTC registers */
<> 149:156823d33999 2421 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
<> 149:156823d33999 2422
<> 149:156823d33999 2423 /* Set the BYPSHAD bit */
<> 149:156823d33999 2424 hrtc->Instance->CR |= (uint8_t)RTC_CR_BYPSHAD;
<> 149:156823d33999 2425
<> 149:156823d33999 2426 /* Enable the write protection for RTC registers */
<> 149:156823d33999 2427 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 2428
<> 149:156823d33999 2429 /* Change RTC state */
<> 149:156823d33999 2430 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 2431
<> 149:156823d33999 2432 /* Process Unlocked */
<> 149:156823d33999 2433 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 2434
<> 149:156823d33999 2435 return HAL_OK;
<> 149:156823d33999 2436 }
<> 149:156823d33999 2437
<> 149:156823d33999 2438 /**
<> 149:156823d33999 2439 * @brief Disables the Bypass Shadow feature.
<> 149:156823d33999 2440 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 2441 * the configuration information for RTC.
<> 149:156823d33999 2442 * @note When the Bypass Shadow is enabled the calendar value are taken
<> 149:156823d33999 2443 * directly from the Calendar counter.
<> 149:156823d33999 2444 * @retval HAL status
<> 149:156823d33999 2445 */
<> 149:156823d33999 2446 HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef* hrtc)
<> 149:156823d33999 2447 {
<> 149:156823d33999 2448 /* Process Locked */
<> 149:156823d33999 2449 __HAL_LOCK(hrtc);
<> 149:156823d33999 2450
<> 149:156823d33999 2451 hrtc->State = HAL_RTC_STATE_BUSY;
<> 149:156823d33999 2452
<> 149:156823d33999 2453 /* Disable the write protection for RTC registers */
<> 149:156823d33999 2454 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
<> 149:156823d33999 2455
<> 149:156823d33999 2456 /* Reset the BYPSHAD bit */
<> 149:156823d33999 2457 hrtc->Instance->CR &= (uint8_t)~RTC_CR_BYPSHAD;
<> 149:156823d33999 2458
<> 149:156823d33999 2459 /* Enable the write protection for RTC registers */
<> 149:156823d33999 2460 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
<> 149:156823d33999 2461
<> 149:156823d33999 2462 /* Change RTC state */
<> 149:156823d33999 2463 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 2464
<> 149:156823d33999 2465 /* Process Unlocked */
<> 149:156823d33999 2466 __HAL_UNLOCK(hrtc);
<> 149:156823d33999 2467
<> 149:156823d33999 2468 return HAL_OK;
<> 149:156823d33999 2469 }
<> 149:156823d33999 2470 #endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
<> 149:156823d33999 2471
<> 149:156823d33999 2472 /**
<> 149:156823d33999 2473 * @}
<> 149:156823d33999 2474 */
<> 149:156823d33999 2475
<> 149:156823d33999 2476 /** @defgroup RTCEx_Exported_Functions_Group8 Extended features functions
<> 149:156823d33999 2477 * @brief Extended features functions
<> 149:156823d33999 2478 *
<> 149:156823d33999 2479 @verbatim
<> 149:156823d33999 2480 ===============================================================================
<> 149:156823d33999 2481 ##### Extended features functions #####
<> 149:156823d33999 2482 ===============================================================================
<> 149:156823d33999 2483 [..] This section provides functions allowing to:
<> 149:156823d33999 2484 (+) RTC Alram B callback
<> 149:156823d33999 2485 (+) RTC Poll for Alarm B request
<> 149:156823d33999 2486
<> 149:156823d33999 2487 @endverbatim
<> 149:156823d33999 2488 * @{
<> 149:156823d33999 2489 */
<> 149:156823d33999 2490
<> 149:156823d33999 2491 /**
<> 149:156823d33999 2492 * @brief Alarm B callback.
<> 149:156823d33999 2493 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 2494 * the configuration information for RTC.
<> 149:156823d33999 2495 * @retval None
<> 149:156823d33999 2496 */
<> 149:156823d33999 2497 __weak void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc)
<> 149:156823d33999 2498 {
<> 149:156823d33999 2499 /* Prevent unused argument(s) compilation warning */
<> 149:156823d33999 2500 UNUSED(hrtc);
<> 149:156823d33999 2501
<> 149:156823d33999 2502 /* NOTE : This function Should not be modified, when the callback is needed,
<> 149:156823d33999 2503 the HAL_RTCEx_AlarmBEventCallback could be implemented in the user file
<> 149:156823d33999 2504 */
<> 149:156823d33999 2505 }
<> 149:156823d33999 2506
<> 149:156823d33999 2507 /**
<> 149:156823d33999 2508 * @brief This function handles AlarmB Polling request.
<> 149:156823d33999 2509 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
<> 149:156823d33999 2510 * the configuration information for RTC.
<> 149:156823d33999 2511 * @param Timeout: Timeout duration
<> 149:156823d33999 2512 * @retval HAL status
<> 149:156823d33999 2513 */
<> 149:156823d33999 2514 HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
<> 149:156823d33999 2515 {
<> 149:156823d33999 2516 uint32_t tickstart = HAL_GetTick();
<> 149:156823d33999 2517
<> 149:156823d33999 2518 while(__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRBF) == RESET)
<> 149:156823d33999 2519 {
<> 149:156823d33999 2520 if(Timeout != HAL_MAX_DELAY)
<> 149:156823d33999 2521 {
<> 149:156823d33999 2522 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
<> 149:156823d33999 2523 {
<> 149:156823d33999 2524 hrtc->State = HAL_RTC_STATE_TIMEOUT;
<> 149:156823d33999 2525 return HAL_TIMEOUT;
<> 149:156823d33999 2526 }
<> 149:156823d33999 2527 }
<> 149:156823d33999 2528 }
<> 149:156823d33999 2529
<> 149:156823d33999 2530 /* Clear the Alarm Flag */
<> 149:156823d33999 2531 __HAL_RTC_ALARM_CLEAR_FLAG(hrtc, RTC_FLAG_ALRBF);
<> 149:156823d33999 2532
<> 149:156823d33999 2533 /* Change RTC state */
<> 149:156823d33999 2534 hrtc->State = HAL_RTC_STATE_READY;
<> 149:156823d33999 2535
<> 149:156823d33999 2536 return HAL_OK;
<> 149:156823d33999 2537 }
<> 149:156823d33999 2538
<> 149:156823d33999 2539 /**
<> 149:156823d33999 2540 * @}
<> 149:156823d33999 2541 */
<> 149:156823d33999 2542
<> 149:156823d33999 2543 /**
<> 149:156823d33999 2544 * @}
<> 149:156823d33999 2545 */
<> 149:156823d33999 2546
<> 149:156823d33999 2547 /**
<> 149:156823d33999 2548 * @}
<> 149:156823d33999 2549 */
<> 149:156823d33999 2550
<> 149:156823d33999 2551 #endif /* HAL_RTC_MODULE_ENABLED */
<> 149:156823d33999 2552
<> 149:156823d33999 2553 /**
<> 149:156823d33999 2554 * @}
<> 149:156823d33999 2555 */
<> 149:156823d33999 2556
<> 149:156823d33999 2557 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/