Lancaster University's (short term!) clone of mbed-src for micro:bit. This is a copy of the github branch https://github.com/lancaster-university/mbed-classic

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Fri Aug 14 13:15:17 2015 +0100
Revision:
610:813dcc80987e
Synchronized with git revision 6d84db41c6833e0b9b024741eb0616a5f62d5599

Full URL: https://github.com/mbedmicro/mbed/commit/6d84db41c6833e0b9b024741eb0616a5f62d5599/

DISCO_F746NG - Improvements

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 610:813dcc80987e 1 /**
mbed_official 610:813dcc80987e 2 ******************************************************************************
mbed_official 610:813dcc80987e 3 * @file stm32l4xx_hal_rtc_ex.c
mbed_official 610:813dcc80987e 4 * @author MCD Application Team
mbed_official 610:813dcc80987e 5 * @version V1.0.0
mbed_official 610:813dcc80987e 6 * @date 26-June-2015
mbed_official 610:813dcc80987e 7 * @brief Extended RTC HAL module driver.
mbed_official 610:813dcc80987e 8 * This file provides firmware functions to manage the following
mbed_official 610:813dcc80987e 9 * functionalities of the Real Time Clock (RTC) Extended peripheral:
mbed_official 610:813dcc80987e 10 * + RTC Time Stamp functions
mbed_official 610:813dcc80987e 11 * + RTC Tamper functions
mbed_official 610:813dcc80987e 12 * + RTC Wake-up functions
mbed_official 610:813dcc80987e 13 * + Extended Control functions
mbed_official 610:813dcc80987e 14 * + Extended RTC features functions
mbed_official 610:813dcc80987e 15 *
mbed_official 610:813dcc80987e 16 @verbatim
mbed_official 610:813dcc80987e 17 ==============================================================================
mbed_official 610:813dcc80987e 18 ##### How to use this driver #####
mbed_official 610:813dcc80987e 19 ==============================================================================
mbed_official 610:813dcc80987e 20 [..]
mbed_official 610:813dcc80987e 21 (+) Enable the RTC domain access.
mbed_official 610:813dcc80987e 22 (+) Configure the RTC Prescaler (Asynchronous and Synchronous) and RTC hour
mbed_official 610:813dcc80987e 23 format using the HAL_RTC_Init() function.
mbed_official 610:813dcc80987e 24
mbed_official 610:813dcc80987e 25 *** RTC Wakeup configuration ***
mbed_official 610:813dcc80987e 26 ================================
mbed_official 610:813dcc80987e 27 [..]
mbed_official 610:813dcc80987e 28 (+) To configure the RTC Wakeup Clock source and Counter use the HAL_RTCEx_SetWakeUpTimer()
mbed_official 610:813dcc80987e 29 function. You can also configure the RTC Wakeup timer with interrupt mode
mbed_official 610:813dcc80987e 30 using the HAL_RTCEx_SetWakeUpTimer_IT() function.
mbed_official 610:813dcc80987e 31 (+) To read the RTC WakeUp Counter register, use the HAL_RTCEx_GetWakeUpTimer()
mbed_official 610:813dcc80987e 32 function.
mbed_official 610:813dcc80987e 33
mbed_official 610:813dcc80987e 34 *** Outputs configuration ***
mbed_official 610:813dcc80987e 35 =============================
mbed_official 610:813dcc80987e 36 [..] The RTC has 2 different outputs:
mbed_official 610:813dcc80987e 37 (+) RTC_ALARM: this output is used to manage the RTC Alarm A, Alarm B
mbed_official 610:813dcc80987e 38 and WaKeUp signals.
mbed_official 610:813dcc80987e 39 To output the selected RTC signal, use the HAL_RTC_Init() function.
mbed_official 610:813dcc80987e 40 (+) RTC_CALIB: this output is 512Hz signal or 1Hz.
mbed_official 610:813dcc80987e 41 To enable the RTC_CALIB, use the HAL_RTCEx_SetCalibrationOutPut() function.
mbed_official 610:813dcc80987e 42 (+) Two pins can be used as RTC_ALARM or RTC_CALIB (PC13, PB2) managed on
mbed_official 610:813dcc80987e 43 the RTC_OR register.
mbed_official 610:813dcc80987e 44 (+) When the RTC_CALIB or RTC_ALARM output is selected, the RTC_OUT pin is
mbed_official 610:813dcc80987e 45 automatically configured in output alternate function.
mbed_official 610:813dcc80987e 46
mbed_official 610:813dcc80987e 47 *** Smooth digital Calibration configuration ***
mbed_official 610:813dcc80987e 48 ================================================
mbed_official 610:813dcc80987e 49 [..]
mbed_official 610:813dcc80987e 50 (+) Configure the RTC Original Digital Calibration Value and the corresponding
mbed_official 610:813dcc80987e 51 calibration cycle period (32s,16s and 8s) using the HAL_RTCEx_SetSmoothCalib()
mbed_official 610:813dcc80987e 52 function.
mbed_official 610:813dcc80987e 53
mbed_official 610:813dcc80987e 54 *** TimeStamp configuration ***
mbed_official 610:813dcc80987e 55 ===============================
mbed_official 610:813dcc80987e 56 [..]
mbed_official 610:813dcc80987e 57 (+) Enable the RTC TimeStamp using the HAL_RTCEx_SetTimeStamp() function.
mbed_official 610:813dcc80987e 58 You can also configure the RTC TimeStamp with interrupt mode using the
mbed_official 610:813dcc80987e 59 HAL_RTCEx_SetTimeStamp_IT() function.
mbed_official 610:813dcc80987e 60 (+) To read the RTC TimeStamp Time and Date register, use the HAL_RTCEx_GetTimeStamp()
mbed_official 610:813dcc80987e 61 function.
mbed_official 610:813dcc80987e 62
mbed_official 610:813dcc80987e 63 *** Internal TimeStamp configuration ***
mbed_official 610:813dcc80987e 64 ===============================
mbed_official 610:813dcc80987e 65 [..]
mbed_official 610:813dcc80987e 66 (+) Enable the RTC internal TimeStamp using the HAL_RTCEx_SetInternalTimeStamp() function.
mbed_official 610:813dcc80987e 67 User has to check internal timestamp occurrence using __HAL_RTC_INTERNAL_TIMESTAMP_GET_FLAG.
mbed_official 610:813dcc80987e 68 (+) To read the RTC TimeStamp Time and Date register, use the HAL_RTCEx_GetTimeStamp()
mbed_official 610:813dcc80987e 69 function.
mbed_official 610:813dcc80987e 70
mbed_official 610:813dcc80987e 71 *** Tamper configuration ***
mbed_official 610:813dcc80987e 72 ============================
mbed_official 610:813dcc80987e 73 [..]
mbed_official 610:813dcc80987e 74 (+) Enable the RTC Tamper and configure the Tamper filter count, trigger Edge
mbed_official 610:813dcc80987e 75 or Level according to the Tamper filter (if equal to 0 Edge else Level)
mbed_official 610:813dcc80987e 76 value, sampling frequency, NoErase, MaskFlag, precharge or discharge and
mbed_official 610:813dcc80987e 77 Pull-UP using the HAL_RTCEx_SetTamper() function. You can configure RTC Tamper
mbed_official 610:813dcc80987e 78 with interrupt mode using HAL_RTCEx_SetTamper_IT() function.
mbed_official 610:813dcc80987e 79 (+) The default configuration of the Tamper erases the backup registers. To avoid
mbed_official 610:813dcc80987e 80 erase, enable the NoErase field on the RTC_TAMPCR register.
mbed_official 610:813dcc80987e 81
mbed_official 610:813dcc80987e 82 *** Backup Data Registers configuration ***
mbed_official 610:813dcc80987e 83 ===========================================
mbed_official 610:813dcc80987e 84 [..]
mbed_official 610:813dcc80987e 85 (+) To write to the RTC Backup Data registers, use the HAL_RTCEx_BKUPWrite()
mbed_official 610:813dcc80987e 86 function.
mbed_official 610:813dcc80987e 87 (+) To read the RTC Backup Data registers, use the HAL_RTCEx_BKUPRead()
mbed_official 610:813dcc80987e 88 function.
mbed_official 610:813dcc80987e 89
mbed_official 610:813dcc80987e 90 @endverbatim
mbed_official 610:813dcc80987e 91 ******************************************************************************
mbed_official 610:813dcc80987e 92 * @attention
mbed_official 610:813dcc80987e 93 *
mbed_official 610:813dcc80987e 94 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
mbed_official 610:813dcc80987e 95 *
mbed_official 610:813dcc80987e 96 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 610:813dcc80987e 97 * are permitted provided that the following conditions are met:
mbed_official 610:813dcc80987e 98 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 610:813dcc80987e 99 * this list of conditions and the following disclaimer.
mbed_official 610:813dcc80987e 100 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 610:813dcc80987e 101 * this list of conditions and the following disclaimer in the documentation
mbed_official 610:813dcc80987e 102 * and/or other materials provided with the distribution.
mbed_official 610:813dcc80987e 103 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 610:813dcc80987e 104 * may be used to endorse or promote products derived from this software
mbed_official 610:813dcc80987e 105 * without specific prior written permission.
mbed_official 610:813dcc80987e 106 *
mbed_official 610:813dcc80987e 107 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 610:813dcc80987e 108 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 610:813dcc80987e 109 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 610:813dcc80987e 110 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 610:813dcc80987e 111 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 610:813dcc80987e 112 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 610:813dcc80987e 113 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 610:813dcc80987e 114 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 610:813dcc80987e 115 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 610:813dcc80987e 116 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 610:813dcc80987e 117 *
mbed_official 610:813dcc80987e 118 ******************************************************************************
mbed_official 610:813dcc80987e 119 */
mbed_official 610:813dcc80987e 120
mbed_official 610:813dcc80987e 121 /* Includes ------------------------------------------------------------------*/
mbed_official 610:813dcc80987e 122 #include "stm32l4xx_hal.h"
mbed_official 610:813dcc80987e 123
mbed_official 610:813dcc80987e 124 /** @addtogroup STM32L4xx_HAL_Driver
mbed_official 610:813dcc80987e 125 * @{
mbed_official 610:813dcc80987e 126 */
mbed_official 610:813dcc80987e 127
mbed_official 610:813dcc80987e 128 /** @defgroup RTCEx RTCEx
mbed_official 610:813dcc80987e 129 * @brief RTC Extended HAL module driver
mbed_official 610:813dcc80987e 130 * @{
mbed_official 610:813dcc80987e 131 */
mbed_official 610:813dcc80987e 132
mbed_official 610:813dcc80987e 133 #ifdef HAL_RTC_MODULE_ENABLED
mbed_official 610:813dcc80987e 134
mbed_official 610:813dcc80987e 135 /* Private typedef -----------------------------------------------------------*/
mbed_official 610:813dcc80987e 136 /* Private define ------------------------------------------------------------*/
mbed_official 610:813dcc80987e 137 /* Private macro -------------------------------------------------------------*/
mbed_official 610:813dcc80987e 138 /* Private variables ---------------------------------------------------------*/
mbed_official 610:813dcc80987e 139 /* Private function prototypes -----------------------------------------------*/
mbed_official 610:813dcc80987e 140 /* Exported functions --------------------------------------------------------*/
mbed_official 610:813dcc80987e 141
mbed_official 610:813dcc80987e 142 /** @defgroup RTCEx_Exported_Functions RTCEx Exported Functions
mbed_official 610:813dcc80987e 143 * @{
mbed_official 610:813dcc80987e 144 */
mbed_official 610:813dcc80987e 145
mbed_official 610:813dcc80987e 146
mbed_official 610:813dcc80987e 147 /** @defgroup RTCEx_Exported_Functions_Group1 RTC TimeStamp and Tamper functions
mbed_official 610:813dcc80987e 148 * @brief RTC TimeStamp and Tamper functions
mbed_official 610:813dcc80987e 149 *
mbed_official 610:813dcc80987e 150 @verbatim
mbed_official 610:813dcc80987e 151 ===============================================================================
mbed_official 610:813dcc80987e 152 ##### RTC TimeStamp and Tamper functions #####
mbed_official 610:813dcc80987e 153 ===============================================================================
mbed_official 610:813dcc80987e 154
mbed_official 610:813dcc80987e 155 [..] This section provide functions allowing to configure TimeStamp feature
mbed_official 610:813dcc80987e 156
mbed_official 610:813dcc80987e 157 @endverbatim
mbed_official 610:813dcc80987e 158 * @{
mbed_official 610:813dcc80987e 159 */
mbed_official 610:813dcc80987e 160
mbed_official 610:813dcc80987e 161 /**
mbed_official 610:813dcc80987e 162 * @brief Set TimeStamp.
mbed_official 610:813dcc80987e 163 * @note This API must be called before enabling the TimeStamp feature.
mbed_official 610:813dcc80987e 164 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 165 * @param TimeStampEdge: Specifies the pin edge on which the TimeStamp is
mbed_official 610:813dcc80987e 166 * activated.
mbed_official 610:813dcc80987e 167 * This parameter can be one of the following values:
mbed_official 610:813dcc80987e 168 * @arg RTC_TIMESTAMPEDGE_RISING: the Time stamp event occurs on the
mbed_official 610:813dcc80987e 169 * rising edge of the related pin.
mbed_official 610:813dcc80987e 170 * @arg RTC_TIMESTAMPEDGE_FALLING: the Time stamp event occurs on the
mbed_official 610:813dcc80987e 171 * falling edge of the related pin.
mbed_official 610:813dcc80987e 172 * @param RTC_TimeStampPin: specifies the RTC TimeStamp Pin.
mbed_official 610:813dcc80987e 173 * This parameter can be one of the following values:
mbed_official 610:813dcc80987e 174 * @arg RTC_TIMESTAMPPIN_DEFAULT: PC13 is selected as RTC TimeStamp Pin.
mbed_official 610:813dcc80987e 175 * The RTC TimeStamp Pin is per default PC13, but for reasons of
mbed_official 610:813dcc80987e 176 * compatibility, this parameter is required.
mbed_official 610:813dcc80987e 177 * @retval HAL status
mbed_official 610:813dcc80987e 178 */
mbed_official 610:813dcc80987e 179 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin)
mbed_official 610:813dcc80987e 180 {
mbed_official 610:813dcc80987e 181 uint32_t tmpreg = 0;
mbed_official 610:813dcc80987e 182
mbed_official 610:813dcc80987e 183 /* Check the parameters */
mbed_official 610:813dcc80987e 184 assert_param(IS_TIMESTAMP_EDGE(TimeStampEdge));
mbed_official 610:813dcc80987e 185 assert_param(IS_RTC_TIMESTAMP_PIN(RTC_TimeStampPin));
mbed_official 610:813dcc80987e 186
mbed_official 610:813dcc80987e 187 /* Process Locked */
mbed_official 610:813dcc80987e 188 __HAL_LOCK(hrtc);
mbed_official 610:813dcc80987e 189
mbed_official 610:813dcc80987e 190 hrtc->State = HAL_RTC_STATE_BUSY;
mbed_official 610:813dcc80987e 191
mbed_official 610:813dcc80987e 192 /* Get the RTC_CR register and clear the bits to be configured */
mbed_official 610:813dcc80987e 193 tmpreg = (uint32_t)(hrtc->Instance->CR & (uint32_t)~(RTC_CR_TSEDGE | RTC_CR_TSE));
mbed_official 610:813dcc80987e 194
mbed_official 610:813dcc80987e 195 tmpreg|= TimeStampEdge;
mbed_official 610:813dcc80987e 196
mbed_official 610:813dcc80987e 197 /* Disable the write protection for RTC registers */
mbed_official 610:813dcc80987e 198 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
mbed_official 610:813dcc80987e 199
mbed_official 610:813dcc80987e 200 /* Configure the Time Stamp TSEDGE and Enable bits */
mbed_official 610:813dcc80987e 201 hrtc->Instance->CR = (uint32_t)tmpreg;
mbed_official 610:813dcc80987e 202
mbed_official 610:813dcc80987e 203 __HAL_RTC_TIMESTAMP_ENABLE(hrtc);
mbed_official 610:813dcc80987e 204
mbed_official 610:813dcc80987e 205 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 206 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 207
mbed_official 610:813dcc80987e 208 /* Change RTC state */
mbed_official 610:813dcc80987e 209 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 210
mbed_official 610:813dcc80987e 211 /* Process Unlocked */
mbed_official 610:813dcc80987e 212 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 213
mbed_official 610:813dcc80987e 214 return HAL_OK;
mbed_official 610:813dcc80987e 215 }
mbed_official 610:813dcc80987e 216
mbed_official 610:813dcc80987e 217 /**
mbed_official 610:813dcc80987e 218 * @brief Set TimeStamp with Interrupt.
mbed_official 610:813dcc80987e 219 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 220 * @note This API must be called before enabling the TimeStamp feature.
mbed_official 610:813dcc80987e 221 * @param TimeStampEdge: Specifies the pin edge on which the TimeStamp is
mbed_official 610:813dcc80987e 222 * activated.
mbed_official 610:813dcc80987e 223 * This parameter can be one of the following values:
mbed_official 610:813dcc80987e 224 * @arg RTC_TIMESTAMPEDGE_RISING: the Time stamp event occurs on the
mbed_official 610:813dcc80987e 225 * rising edge of the related pin.
mbed_official 610:813dcc80987e 226 * @arg RTC_TIMESTAMPEDGE_FALLING: the Time stamp event occurs on the
mbed_official 610:813dcc80987e 227 * falling edge of the related pin.
mbed_official 610:813dcc80987e 228 * @param RTC_TimeStampPin: Specifies the RTC TimeStamp Pin.
mbed_official 610:813dcc80987e 229 * This parameter can be one of the following values:
mbed_official 610:813dcc80987e 230 * @arg RTC_TIMESTAMPPIN_DEFAULT: PC13 is selected as RTC TimeStamp Pin.
mbed_official 610:813dcc80987e 231 * The RTC TimeStamp Pin is per default PC13, but for reasons of
mbed_official 610:813dcc80987e 232 * compatibility, this parameter is required.
mbed_official 610:813dcc80987e 233 * @retval HAL status
mbed_official 610:813dcc80987e 234 */
mbed_official 610:813dcc80987e 235 HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge, uint32_t RTC_TimeStampPin)
mbed_official 610:813dcc80987e 236 {
mbed_official 610:813dcc80987e 237 uint32_t tmpreg = 0;
mbed_official 610:813dcc80987e 238
mbed_official 610:813dcc80987e 239 /* Check the parameters */
mbed_official 610:813dcc80987e 240 assert_param(IS_TIMESTAMP_EDGE(TimeStampEdge));
mbed_official 610:813dcc80987e 241 assert_param(IS_RTC_TIMESTAMP_PIN(RTC_TimeStampPin));
mbed_official 610:813dcc80987e 242
mbed_official 610:813dcc80987e 243 /* Process Locked */
mbed_official 610:813dcc80987e 244 __HAL_LOCK(hrtc);
mbed_official 610:813dcc80987e 245
mbed_official 610:813dcc80987e 246 hrtc->State = HAL_RTC_STATE_BUSY;
mbed_official 610:813dcc80987e 247
mbed_official 610:813dcc80987e 248 /* Get the RTC_CR register and clear the bits to be configured */
mbed_official 610:813dcc80987e 249 tmpreg = (uint32_t)(hrtc->Instance->CR & (uint32_t)~(RTC_CR_TSEDGE | RTC_CR_TSE));
mbed_official 610:813dcc80987e 250
mbed_official 610:813dcc80987e 251 tmpreg |= TimeStampEdge;
mbed_official 610:813dcc80987e 252
mbed_official 610:813dcc80987e 253 /* Disable the write protection for RTC registers */
mbed_official 610:813dcc80987e 254 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
mbed_official 610:813dcc80987e 255
mbed_official 610:813dcc80987e 256 /* Configure the Time Stamp TSEDGE and Enable bits */
mbed_official 610:813dcc80987e 257 hrtc->Instance->CR = (uint32_t)tmpreg;
mbed_official 610:813dcc80987e 258
mbed_official 610:813dcc80987e 259 __HAL_RTC_TIMESTAMP_ENABLE(hrtc);
mbed_official 610:813dcc80987e 260
mbed_official 610:813dcc80987e 261 /* Enable IT timestamp */
mbed_official 610:813dcc80987e 262 __HAL_RTC_TIMESTAMP_ENABLE_IT(hrtc,RTC_IT_TS);
mbed_official 610:813dcc80987e 263
mbed_official 610:813dcc80987e 264 /* RTC timestamp Interrupt Configuration: EXTI configuration */
mbed_official 610:813dcc80987e 265 __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT();
mbed_official 610:813dcc80987e 266
mbed_official 610:813dcc80987e 267 __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE();
mbed_official 610:813dcc80987e 268
mbed_official 610:813dcc80987e 269 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 270 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 271
mbed_official 610:813dcc80987e 272 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 273
mbed_official 610:813dcc80987e 274 /* Process Unlocked */
mbed_official 610:813dcc80987e 275 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 276
mbed_official 610:813dcc80987e 277 return HAL_OK;
mbed_official 610:813dcc80987e 278 }
mbed_official 610:813dcc80987e 279
mbed_official 610:813dcc80987e 280 /**
mbed_official 610:813dcc80987e 281 * @brief Deactivate TimeStamp.
mbed_official 610:813dcc80987e 282 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 283 * @retval HAL status
mbed_official 610:813dcc80987e 284 */
mbed_official 610:813dcc80987e 285 HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc)
mbed_official 610:813dcc80987e 286 {
mbed_official 610:813dcc80987e 287 uint32_t tmpreg = 0;
mbed_official 610:813dcc80987e 288
mbed_official 610:813dcc80987e 289 /* Process Locked */
mbed_official 610:813dcc80987e 290 __HAL_LOCK(hrtc);
mbed_official 610:813dcc80987e 291
mbed_official 610:813dcc80987e 292 hrtc->State = HAL_RTC_STATE_BUSY;
mbed_official 610:813dcc80987e 293
mbed_official 610:813dcc80987e 294 /* Disable the write protection for RTC registers */
mbed_official 610:813dcc80987e 295 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
mbed_official 610:813dcc80987e 296
mbed_official 610:813dcc80987e 297 /* In case of interrupt mode is used, the interrupt source must disabled */
mbed_official 610:813dcc80987e 298 __HAL_RTC_TIMESTAMP_DISABLE_IT(hrtc, RTC_IT_TS);
mbed_official 610:813dcc80987e 299
mbed_official 610:813dcc80987e 300 /* Get the RTC_CR register and clear the bits to be configured */
mbed_official 610:813dcc80987e 301 tmpreg = (uint32_t)(hrtc->Instance->CR & (uint32_t)~(RTC_CR_TSEDGE | RTC_CR_TSE));
mbed_official 610:813dcc80987e 302
mbed_official 610:813dcc80987e 303 /* Configure the Time Stamp TSEDGE and Enable bits */
mbed_official 610:813dcc80987e 304 hrtc->Instance->CR = (uint32_t)tmpreg;
mbed_official 610:813dcc80987e 305
mbed_official 610:813dcc80987e 306 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 307 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 308
mbed_official 610:813dcc80987e 309 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 310
mbed_official 610:813dcc80987e 311 /* Process Unlocked */
mbed_official 610:813dcc80987e 312 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 313
mbed_official 610:813dcc80987e 314 return HAL_OK;
mbed_official 610:813dcc80987e 315 }
mbed_official 610:813dcc80987e 316
mbed_official 610:813dcc80987e 317 /**
mbed_official 610:813dcc80987e 318 * @brief Set Internal TimeStamp.
mbed_official 610:813dcc80987e 319 * @note This API must be called before enabling the internal TimeStamp feature.
mbed_official 610:813dcc80987e 320 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
mbed_official 610:813dcc80987e 321 * the configuration information for RTC.
mbed_official 610:813dcc80987e 322 * @retval HAL status
mbed_official 610:813dcc80987e 323 */
mbed_official 610:813dcc80987e 324 HAL_StatusTypeDef HAL_RTCEx_SetInternalTimeStamp(RTC_HandleTypeDef *hrtc)
mbed_official 610:813dcc80987e 325 {
mbed_official 610:813dcc80987e 326 /* Process Locked */
mbed_official 610:813dcc80987e 327 __HAL_LOCK(hrtc);
mbed_official 610:813dcc80987e 328
mbed_official 610:813dcc80987e 329 hrtc->State = HAL_RTC_STATE_BUSY;
mbed_official 610:813dcc80987e 330
mbed_official 610:813dcc80987e 331 /* Disable the write protection for RTC registers */
mbed_official 610:813dcc80987e 332 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
mbed_official 610:813dcc80987e 333
mbed_official 610:813dcc80987e 334 /* Configure the internal Time Stamp Enable bits */
mbed_official 610:813dcc80987e 335 __HAL_RTC_INTERNAL_TIMESTAMP_ENABLE(hrtc);
mbed_official 610:813dcc80987e 336
mbed_official 610:813dcc80987e 337 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 338 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 339
mbed_official 610:813dcc80987e 340 /* Change RTC state */
mbed_official 610:813dcc80987e 341 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 342
mbed_official 610:813dcc80987e 343 /* Process Unlocked */
mbed_official 610:813dcc80987e 344 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 345
mbed_official 610:813dcc80987e 346 return HAL_OK;
mbed_official 610:813dcc80987e 347 }
mbed_official 610:813dcc80987e 348
mbed_official 610:813dcc80987e 349 /**
mbed_official 610:813dcc80987e 350 * @brief Deactivate Internal TimeStamp.
mbed_official 610:813dcc80987e 351 * @param hrtc: pointer to a RTC_HandleTypeDef structure that contains
mbed_official 610:813dcc80987e 352 * the configuration information for RTC.
mbed_official 610:813dcc80987e 353 * @retval HAL status
mbed_official 610:813dcc80987e 354 */
mbed_official 610:813dcc80987e 355 HAL_StatusTypeDef HAL_RTCEx_DeactivateInternalTimeStamp(RTC_HandleTypeDef *hrtc)
mbed_official 610:813dcc80987e 356 {
mbed_official 610:813dcc80987e 357 /* Process Locked */
mbed_official 610:813dcc80987e 358 __HAL_LOCK(hrtc);
mbed_official 610:813dcc80987e 359
mbed_official 610:813dcc80987e 360 hrtc->State = HAL_RTC_STATE_BUSY;
mbed_official 610:813dcc80987e 361
mbed_official 610:813dcc80987e 362 /* Disable the write protection for RTC registers */
mbed_official 610:813dcc80987e 363 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
mbed_official 610:813dcc80987e 364
mbed_official 610:813dcc80987e 365 /* Configure the internal Time Stamp Enable bits */
mbed_official 610:813dcc80987e 366 __HAL_RTC_INTERNAL_TIMESTAMP_DISABLE(hrtc);
mbed_official 610:813dcc80987e 367
mbed_official 610:813dcc80987e 368 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 369 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 370
mbed_official 610:813dcc80987e 371 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 372
mbed_official 610:813dcc80987e 373 /* Process Unlocked */
mbed_official 610:813dcc80987e 374 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 375
mbed_official 610:813dcc80987e 376 return HAL_OK;
mbed_official 610:813dcc80987e 377 }
mbed_official 610:813dcc80987e 378
mbed_official 610:813dcc80987e 379 /**
mbed_official 610:813dcc80987e 380 * @brief Get the RTC TimeStamp value.
mbed_official 610:813dcc80987e 381 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 382 * @param sTimeStamp: Pointer to Time structure
mbed_official 610:813dcc80987e 383 * @param sTimeStampDate: Pointer to Date structure
mbed_official 610:813dcc80987e 384 * @param Format: specifies the format of the entered parameters.
mbed_official 610:813dcc80987e 385 * This parameter can be one of the following values:
mbed_official 610:813dcc80987e 386 * @arg RTC_FORMAT_BIN: Binary data format
mbed_official 610:813dcc80987e 387 * @arg RTC_FORMAT_BCD: BCD data format
mbed_official 610:813dcc80987e 388 * @retval HAL status
mbed_official 610:813dcc80987e 389 */
mbed_official 610:813dcc80987e 390 HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef* sTimeStamp, RTC_DateTypeDef* sTimeStampDate, uint32_t Format)
mbed_official 610:813dcc80987e 391 {
mbed_official 610:813dcc80987e 392 uint32_t tmptime = 0, tmpdate = 0;
mbed_official 610:813dcc80987e 393
mbed_official 610:813dcc80987e 394 /* Check the parameters */
mbed_official 610:813dcc80987e 395 assert_param(IS_RTC_FORMAT(Format));
mbed_official 610:813dcc80987e 396
mbed_official 610:813dcc80987e 397 /* Get the TimeStamp time and date registers values */
mbed_official 610:813dcc80987e 398 tmptime = (uint32_t)(hrtc->Instance->TSTR & RTC_TR_RESERVED_MASK);
mbed_official 610:813dcc80987e 399 tmpdate = (uint32_t)(hrtc->Instance->TSDR & RTC_DR_RESERVED_MASK);
mbed_official 610:813dcc80987e 400
mbed_official 610:813dcc80987e 401 /* Fill the Time structure fields with the read parameters */
mbed_official 610:813dcc80987e 402 sTimeStamp->Hours = (uint8_t)((tmptime & (RTC_TR_HT | RTC_TR_HU)) >> 16);
mbed_official 610:813dcc80987e 403 sTimeStamp->Minutes = (uint8_t)((tmptime & (RTC_TR_MNT | RTC_TR_MNU)) >> 8);
mbed_official 610:813dcc80987e 404 sTimeStamp->Seconds = (uint8_t)(tmptime & (RTC_TR_ST | RTC_TR_SU));
mbed_official 610:813dcc80987e 405 sTimeStamp->TimeFormat = (uint8_t)((tmptime & (RTC_TR_PM)) >> 16);
mbed_official 610:813dcc80987e 406 sTimeStamp->SubSeconds = (uint32_t) hrtc->Instance->TSSSR;
mbed_official 610:813dcc80987e 407
mbed_official 610:813dcc80987e 408 /* Fill the Date structure fields with the read parameters */
mbed_official 610:813dcc80987e 409 sTimeStampDate->Year = 0;
mbed_official 610:813dcc80987e 410 sTimeStampDate->Month = (uint8_t)((tmpdate & (RTC_DR_MT | RTC_DR_MU)) >> 8);
mbed_official 610:813dcc80987e 411 sTimeStampDate->Date = (uint8_t)(tmpdate & (RTC_DR_DT | RTC_DR_DU));
mbed_official 610:813dcc80987e 412 sTimeStampDate->WeekDay = (uint8_t)((tmpdate & (RTC_DR_WDU)) >> 13);
mbed_official 610:813dcc80987e 413
mbed_official 610:813dcc80987e 414 /* Check the input parameters format */
mbed_official 610:813dcc80987e 415 if(Format == RTC_FORMAT_BIN)
mbed_official 610:813dcc80987e 416 {
mbed_official 610:813dcc80987e 417 /* Convert the TimeStamp structure parameters to Binary format */
mbed_official 610:813dcc80987e 418 sTimeStamp->Hours = (uint8_t)RTC_Bcd2ToByte(sTimeStamp->Hours);
mbed_official 610:813dcc80987e 419 sTimeStamp->Minutes = (uint8_t)RTC_Bcd2ToByte(sTimeStamp->Minutes);
mbed_official 610:813dcc80987e 420 sTimeStamp->Seconds = (uint8_t)RTC_Bcd2ToByte(sTimeStamp->Seconds);
mbed_official 610:813dcc80987e 421
mbed_official 610:813dcc80987e 422 /* Convert the DateTimeStamp structure parameters to Binary format */
mbed_official 610:813dcc80987e 423 sTimeStampDate->Month = (uint8_t)RTC_Bcd2ToByte(sTimeStampDate->Month);
mbed_official 610:813dcc80987e 424 sTimeStampDate->Date = (uint8_t)RTC_Bcd2ToByte(sTimeStampDate->Date);
mbed_official 610:813dcc80987e 425 sTimeStampDate->WeekDay = (uint8_t)RTC_Bcd2ToByte(sTimeStampDate->WeekDay);
mbed_official 610:813dcc80987e 426 }
mbed_official 610:813dcc80987e 427
mbed_official 610:813dcc80987e 428 /* Clear the TIMESTAMP Flags */
mbed_official 610:813dcc80987e 429 __HAL_RTC_INTERNAL_TIMESTAMP_CLEAR_FLAG(hrtc, RTC_FLAG_ITSF);
mbed_official 610:813dcc80987e 430 __HAL_RTC_TIMESTAMP_CLEAR_FLAG(hrtc, RTC_FLAG_TSF);
mbed_official 610:813dcc80987e 431
mbed_official 610:813dcc80987e 432 return HAL_OK;
mbed_official 610:813dcc80987e 433 }
mbed_official 610:813dcc80987e 434
mbed_official 610:813dcc80987e 435 /**
mbed_official 610:813dcc80987e 436 * @brief Set Tamper.
mbed_official 610:813dcc80987e 437 * @note By calling this API we disable the tamper interrupt for all tampers.
mbed_official 610:813dcc80987e 438 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 439 * @param sTamper: Pointer to Tamper Structure.
mbed_official 610:813dcc80987e 440 * @retval HAL status
mbed_official 610:813dcc80987e 441 */
mbed_official 610:813dcc80987e 442 HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper)
mbed_official 610:813dcc80987e 443 {
mbed_official 610:813dcc80987e 444 uint32_t tmpreg = 0;
mbed_official 610:813dcc80987e 445
mbed_official 610:813dcc80987e 446 /* Check the parameters */
mbed_official 610:813dcc80987e 447 assert_param(IS_RTC_TAMPER(sTamper->Tamper));
mbed_official 610:813dcc80987e 448 assert_param(IS_RTC_TAMPER_TRIGGER(sTamper->Trigger));
mbed_official 610:813dcc80987e 449 assert_param(IS_RTC_TAMPER_ERASE_MODE(sTamper->NoErase));
mbed_official 610:813dcc80987e 450 assert_param(IS_RTC_TAMPER_MASKFLAG_STATE(sTamper->MaskFlag));
mbed_official 610:813dcc80987e 451 assert_param(IS_RTC_TAMPER_FILTER(sTamper->Filter));
mbed_official 610:813dcc80987e 452 assert_param(IS_RTC_TAMPER_SAMPLING_FREQ(sTamper->SamplingFrequency));
mbed_official 610:813dcc80987e 453 assert_param(IS_RTC_TAMPER_PRECHARGE_DURATION(sTamper->PrechargeDuration));
mbed_official 610:813dcc80987e 454 assert_param(IS_RTC_TAMPER_PULLUP_STATE(sTamper->TamperPullUp));
mbed_official 610:813dcc80987e 455 assert_param(IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(sTamper->TimeStampOnTamperDetection));
mbed_official 610:813dcc80987e 456
mbed_official 610:813dcc80987e 457 /* Process Locked */
mbed_official 610:813dcc80987e 458 __HAL_LOCK(hrtc);
mbed_official 610:813dcc80987e 459
mbed_official 610:813dcc80987e 460 hrtc->State = HAL_RTC_STATE_BUSY;
mbed_official 610:813dcc80987e 461
mbed_official 610:813dcc80987e 462 /* Configure the tamper trigger */
mbed_official 610:813dcc80987e 463 if(sTamper->Trigger != RTC_TAMPERTRIGGER_RISINGEDGE)
mbed_official 610:813dcc80987e 464 {
mbed_official 610:813dcc80987e 465 sTamper->Trigger = (uint32_t)(sTamper->Tamper << 1);
mbed_official 610:813dcc80987e 466 }
mbed_official 610:813dcc80987e 467
mbed_official 610:813dcc80987e 468 if(sTamper->NoErase != RTC_TAMPER_ERASE_BACKUP_ENABLE)
mbed_official 610:813dcc80987e 469 {
mbed_official 610:813dcc80987e 470 sTamper->NoErase = 0;
mbed_official 610:813dcc80987e 471 if((sTamper->Tamper & RTC_TAMPER_1) != 0)
mbed_official 610:813dcc80987e 472 {
mbed_official 610:813dcc80987e 473 sTamper->NoErase |= RTC_TAMPCR_TAMP1NOERASE;
mbed_official 610:813dcc80987e 474 }
mbed_official 610:813dcc80987e 475 if((sTamper->Tamper & RTC_TAMPER_2) != 0)
mbed_official 610:813dcc80987e 476 {
mbed_official 610:813dcc80987e 477 sTamper->NoErase |= RTC_TAMPCR_TAMP2NOERASE;
mbed_official 610:813dcc80987e 478 }
mbed_official 610:813dcc80987e 479 if((sTamper->Tamper & RTC_TAMPER_3) != 0)
mbed_official 610:813dcc80987e 480 {
mbed_official 610:813dcc80987e 481 sTamper->NoErase |= RTC_TAMPCR_TAMP3NOERASE;
mbed_official 610:813dcc80987e 482 }
mbed_official 610:813dcc80987e 483 }
mbed_official 610:813dcc80987e 484
mbed_official 610:813dcc80987e 485 if(sTamper->MaskFlag != RTC_TAMPERMASK_FLAG_DISABLE)
mbed_official 610:813dcc80987e 486 {
mbed_official 610:813dcc80987e 487 sTamper->MaskFlag = 0;
mbed_official 610:813dcc80987e 488 if((sTamper->Tamper & RTC_TAMPER_1) != 0)
mbed_official 610:813dcc80987e 489 {
mbed_official 610:813dcc80987e 490 sTamper->MaskFlag |= RTC_TAMPCR_TAMP1MF;
mbed_official 610:813dcc80987e 491 }
mbed_official 610:813dcc80987e 492 if((sTamper->Tamper & RTC_TAMPER_2) != 0)
mbed_official 610:813dcc80987e 493 {
mbed_official 610:813dcc80987e 494 sTamper->MaskFlag |= RTC_TAMPCR_TAMP2MF;
mbed_official 610:813dcc80987e 495 }
mbed_official 610:813dcc80987e 496 if((sTamper->Tamper & RTC_TAMPER_3) != 0)
mbed_official 610:813dcc80987e 497 {
mbed_official 610:813dcc80987e 498 sTamper->MaskFlag |= RTC_TAMPCR_TAMP3MF;
mbed_official 610:813dcc80987e 499 }
mbed_official 610:813dcc80987e 500 }
mbed_official 610:813dcc80987e 501
mbed_official 610:813dcc80987e 502 tmpreg = ((uint32_t)sTamper->Tamper | (uint32_t)sTamper->Trigger | (uint32_t)sTamper->NoErase |\
mbed_official 610:813dcc80987e 503 (uint32_t)sTamper->MaskFlag | (uint32_t)sTamper->Filter | (uint32_t)sTamper->SamplingFrequency |\
mbed_official 610:813dcc80987e 504 (uint32_t)sTamper->PrechargeDuration | (uint32_t)sTamper->TamperPullUp | sTamper->TimeStampOnTamperDetection);
mbed_official 610:813dcc80987e 505
mbed_official 610:813dcc80987e 506 hrtc->Instance->TAMPCR &= (uint32_t)~((uint32_t)sTamper->Tamper | (uint32_t)(sTamper->Tamper << 1) | (uint32_t)RTC_TAMPCR_TAMPTS |\
mbed_official 610:813dcc80987e 507 (uint32_t)RTC_TAMPCR_TAMPFREQ | (uint32_t)RTC_TAMPCR_TAMPFLT | (uint32_t)RTC_TAMPCR_TAMPPRCH |\
mbed_official 610:813dcc80987e 508 (uint32_t)RTC_TAMPCR_TAMPPUDIS | (uint32_t)RTC_TAMPCR_TAMPIE | (uint32_t)RTC_TAMPCR_TAMP1IE |\
mbed_official 610:813dcc80987e 509 (uint32_t)RTC_TAMPCR_TAMP2IE | (uint32_t)RTC_TAMPCR_TAMP3IE | (uint32_t)RTC_TAMPCR_TAMP1NOERASE |\
mbed_official 610:813dcc80987e 510 (uint32_t)RTC_TAMPCR_TAMP2NOERASE | (uint32_t)RTC_TAMPCR_TAMP3NOERASE | (uint32_t)RTC_TAMPCR_TAMP1MF |\
mbed_official 610:813dcc80987e 511 (uint32_t)RTC_TAMPCR_TAMP2MF | (uint32_t)RTC_TAMPCR_TAMP3MF);
mbed_official 610:813dcc80987e 512
mbed_official 610:813dcc80987e 513 hrtc->Instance->TAMPCR |= tmpreg;
mbed_official 610:813dcc80987e 514
mbed_official 610:813dcc80987e 515 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 516
mbed_official 610:813dcc80987e 517 /* Process Unlocked */
mbed_official 610:813dcc80987e 518 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 519
mbed_official 610:813dcc80987e 520 return HAL_OK;
mbed_official 610:813dcc80987e 521 }
mbed_official 610:813dcc80987e 522
mbed_official 610:813dcc80987e 523 /**
mbed_official 610:813dcc80987e 524 * @brief Set Tamper with interrupt.
mbed_official 610:813dcc80987e 525 * @note By calling this API we force the tamper interrupt for all tampers.
mbed_official 610:813dcc80987e 526 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 527 * @param sTamper: Pointer to RTC Tamper.
mbed_official 610:813dcc80987e 528 * @retval HAL status
mbed_official 610:813dcc80987e 529 */
mbed_official 610:813dcc80987e 530 HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef* sTamper)
mbed_official 610:813dcc80987e 531 {
mbed_official 610:813dcc80987e 532 uint32_t tmpreg = 0;
mbed_official 610:813dcc80987e 533
mbed_official 610:813dcc80987e 534 /* Check the parameters */
mbed_official 610:813dcc80987e 535 assert_param(IS_RTC_TAMPER(sTamper->Tamper));
mbed_official 610:813dcc80987e 536 assert_param(IS_RTC_TAMPER_INTERRUPT(sTamper->Interrupt));
mbed_official 610:813dcc80987e 537 assert_param(IS_RTC_TAMPER_TRIGGER(sTamper->Trigger));
mbed_official 610:813dcc80987e 538 assert_param(IS_RTC_TAMPER_ERASE_MODE(sTamper->NoErase));
mbed_official 610:813dcc80987e 539 assert_param(IS_RTC_TAMPER_MASKFLAG_STATE(sTamper->MaskFlag));
mbed_official 610:813dcc80987e 540 assert_param(IS_RTC_TAMPER_FILTER(sTamper->Filter));
mbed_official 610:813dcc80987e 541 assert_param(IS_RTC_TAMPER_SAMPLING_FREQ(sTamper->SamplingFrequency));
mbed_official 610:813dcc80987e 542 assert_param(IS_RTC_TAMPER_PRECHARGE_DURATION(sTamper->PrechargeDuration));
mbed_official 610:813dcc80987e 543 assert_param(IS_RTC_TAMPER_PULLUP_STATE(sTamper->TamperPullUp));
mbed_official 610:813dcc80987e 544 assert_param(IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(sTamper->TimeStampOnTamperDetection));
mbed_official 610:813dcc80987e 545
mbed_official 610:813dcc80987e 546 /* Process Locked */
mbed_official 610:813dcc80987e 547 __HAL_LOCK(hrtc);
mbed_official 610:813dcc80987e 548
mbed_official 610:813dcc80987e 549 hrtc->State = HAL_RTC_STATE_BUSY;
mbed_official 610:813dcc80987e 550
mbed_official 610:813dcc80987e 551 /* Configure the tamper trigger */
mbed_official 610:813dcc80987e 552 if(sTamper->Trigger != RTC_TAMPERTRIGGER_RISINGEDGE)
mbed_official 610:813dcc80987e 553 {
mbed_official 610:813dcc80987e 554 sTamper->Trigger = (uint32_t)(sTamper->Tamper << 1);
mbed_official 610:813dcc80987e 555 }
mbed_official 610:813dcc80987e 556
mbed_official 610:813dcc80987e 557 if(sTamper->NoErase != RTC_TAMPER_ERASE_BACKUP_ENABLE)
mbed_official 610:813dcc80987e 558 {
mbed_official 610:813dcc80987e 559 sTamper->NoErase = 0;
mbed_official 610:813dcc80987e 560 if((sTamper->Tamper & RTC_TAMPER_1) != 0)
mbed_official 610:813dcc80987e 561 {
mbed_official 610:813dcc80987e 562 sTamper->NoErase |= RTC_TAMPCR_TAMP1NOERASE;
mbed_official 610:813dcc80987e 563 }
mbed_official 610:813dcc80987e 564 if((sTamper->Tamper & RTC_TAMPER_2) != 0)
mbed_official 610:813dcc80987e 565 {
mbed_official 610:813dcc80987e 566 sTamper->NoErase |= RTC_TAMPCR_TAMP2NOERASE;
mbed_official 610:813dcc80987e 567 }
mbed_official 610:813dcc80987e 568 if((sTamper->Tamper & RTC_TAMPER_3) != 0)
mbed_official 610:813dcc80987e 569 {
mbed_official 610:813dcc80987e 570 sTamper->NoErase |= RTC_TAMPCR_TAMP3NOERASE;
mbed_official 610:813dcc80987e 571 }
mbed_official 610:813dcc80987e 572 }
mbed_official 610:813dcc80987e 573
mbed_official 610:813dcc80987e 574 if(sTamper->MaskFlag != RTC_TAMPERMASK_FLAG_DISABLE)
mbed_official 610:813dcc80987e 575 {
mbed_official 610:813dcc80987e 576 sTamper->MaskFlag = 0;
mbed_official 610:813dcc80987e 577 if((sTamper->Tamper & RTC_TAMPER_1) != 0)
mbed_official 610:813dcc80987e 578 {
mbed_official 610:813dcc80987e 579 sTamper->MaskFlag |= RTC_TAMPCR_TAMP1MF;
mbed_official 610:813dcc80987e 580 }
mbed_official 610:813dcc80987e 581 if((sTamper->Tamper & RTC_TAMPER_2) != 0)
mbed_official 610:813dcc80987e 582 {
mbed_official 610:813dcc80987e 583 sTamper->MaskFlag |= RTC_TAMPCR_TAMP2MF;
mbed_official 610:813dcc80987e 584 }
mbed_official 610:813dcc80987e 585 if((sTamper->Tamper & RTC_TAMPER_3) != 0)
mbed_official 610:813dcc80987e 586 {
mbed_official 610:813dcc80987e 587 sTamper->MaskFlag |= RTC_TAMPCR_TAMP3MF;
mbed_official 610:813dcc80987e 588 }
mbed_official 610:813dcc80987e 589 }
mbed_official 610:813dcc80987e 590
mbed_official 610:813dcc80987e 591 tmpreg = ((uint32_t)sTamper->Tamper | (uint32_t)sTamper->Interrupt | (uint32_t)sTamper->Trigger | (uint32_t)sTamper->NoErase |\
mbed_official 610:813dcc80987e 592 (uint32_t)sTamper->MaskFlag | (uint32_t)sTamper->Filter | (uint32_t)sTamper->SamplingFrequency |\
mbed_official 610:813dcc80987e 593 (uint32_t)sTamper->PrechargeDuration | (uint32_t)sTamper->TamperPullUp | sTamper->TimeStampOnTamperDetection);
mbed_official 610:813dcc80987e 594
mbed_official 610:813dcc80987e 595 hrtc->Instance->TAMPCR &= (uint32_t)~((uint32_t)sTamper->Tamper | (uint32_t)(sTamper->Tamper << 1) | (uint32_t)RTC_TAMPCR_TAMPTS |\
mbed_official 610:813dcc80987e 596 (uint32_t)RTC_TAMPCR_TAMPFREQ | (uint32_t)RTC_TAMPCR_TAMPFLT | (uint32_t)RTC_TAMPCR_TAMPPRCH |\
mbed_official 610:813dcc80987e 597 (uint32_t)RTC_TAMPCR_TAMPPUDIS | (uint32_t)RTC_TAMPCR_TAMPIE | (uint32_t)RTC_TAMPCR_TAMP1IE |\
mbed_official 610:813dcc80987e 598 (uint32_t)RTC_TAMPCR_TAMP2IE | (uint32_t)RTC_TAMPCR_TAMP3IE | (uint32_t)RTC_TAMPCR_TAMP1NOERASE |\
mbed_official 610:813dcc80987e 599 (uint32_t)RTC_TAMPCR_TAMP2NOERASE | (uint32_t)RTC_TAMPCR_TAMP3NOERASE | (uint32_t)RTC_TAMPCR_TAMP1MF |\
mbed_official 610:813dcc80987e 600 (uint32_t)RTC_TAMPCR_TAMP2MF | (uint32_t)RTC_TAMPCR_TAMP3MF);
mbed_official 610:813dcc80987e 601
mbed_official 610:813dcc80987e 602 hrtc->Instance->TAMPCR |= tmpreg;
mbed_official 610:813dcc80987e 603
mbed_official 610:813dcc80987e 604 /* RTC Tamper Interrupt Configuration: EXTI configuration */
mbed_official 610:813dcc80987e 605 __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT();
mbed_official 610:813dcc80987e 606
mbed_official 610:813dcc80987e 607 __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE();
mbed_official 610:813dcc80987e 608
mbed_official 610:813dcc80987e 609 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 610
mbed_official 610:813dcc80987e 611 /* Process Unlocked */
mbed_official 610:813dcc80987e 612 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 613
mbed_official 610:813dcc80987e 614 return HAL_OK;
mbed_official 610:813dcc80987e 615 }
mbed_official 610:813dcc80987e 616
mbed_official 610:813dcc80987e 617 /**
mbed_official 610:813dcc80987e 618 * @brief Deactivate Tamper.
mbed_official 610:813dcc80987e 619 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 620 * @param Tamper: Selected tamper pin.
mbed_official 610:813dcc80987e 621 * This parameter can be any combination of RTC_TAMPER_1, RTC_TAMPER_2 and RTC_TAMPER_3.
mbed_official 610:813dcc80987e 622 * @retval HAL status
mbed_official 610:813dcc80987e 623 */
mbed_official 610:813dcc80987e 624 HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper)
mbed_official 610:813dcc80987e 625 {
mbed_official 610:813dcc80987e 626 assert_param(IS_RTC_TAMPER(Tamper));
mbed_official 610:813dcc80987e 627
mbed_official 610:813dcc80987e 628 /* Process Locked */
mbed_official 610:813dcc80987e 629 __HAL_LOCK(hrtc);
mbed_official 610:813dcc80987e 630
mbed_official 610:813dcc80987e 631 hrtc->State = HAL_RTC_STATE_BUSY;
mbed_official 610:813dcc80987e 632
mbed_official 610:813dcc80987e 633 /* Disable the selected Tamper pin */
mbed_official 610:813dcc80987e 634 hrtc->Instance->TAMPCR &= ((uint32_t)~Tamper);
mbed_official 610:813dcc80987e 635
mbed_official 610:813dcc80987e 636 if ((Tamper & RTC_TAMPER_1) != 0)
mbed_official 610:813dcc80987e 637 {
mbed_official 610:813dcc80987e 638 /* Disable the Tamper1 interrupt */
mbed_official 610:813dcc80987e 639 hrtc->Instance->TAMPCR &= ((uint32_t)~(RTC_IT_TAMP | RTC_IT_TAMP1));
mbed_official 610:813dcc80987e 640 }
mbed_official 610:813dcc80987e 641 if ((Tamper & RTC_TAMPER_2) != 0)
mbed_official 610:813dcc80987e 642 {
mbed_official 610:813dcc80987e 643 /* Disable the Tamper2 interrupt */
mbed_official 610:813dcc80987e 644 hrtc->Instance->TAMPCR &= ((uint32_t)~(RTC_IT_TAMP | RTC_IT_TAMP2));
mbed_official 610:813dcc80987e 645 }
mbed_official 610:813dcc80987e 646 if ((Tamper & RTC_TAMPER_3) != 0)
mbed_official 610:813dcc80987e 647 {
mbed_official 610:813dcc80987e 648 /* Disable the Tamper3 interrupt */
mbed_official 610:813dcc80987e 649 hrtc->Instance->TAMPCR &= ((uint32_t)~(RTC_IT_TAMP | RTC_IT_TAMP3));
mbed_official 610:813dcc80987e 650 }
mbed_official 610:813dcc80987e 651
mbed_official 610:813dcc80987e 652 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 653
mbed_official 610:813dcc80987e 654 /* Process Unlocked */
mbed_official 610:813dcc80987e 655 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 656
mbed_official 610:813dcc80987e 657 return HAL_OK;
mbed_official 610:813dcc80987e 658 }
mbed_official 610:813dcc80987e 659
mbed_official 610:813dcc80987e 660 /**
mbed_official 610:813dcc80987e 661 * @brief Handle TimeStamp interrupt request.
mbed_official 610:813dcc80987e 662 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 663 * @retval None
mbed_official 610:813dcc80987e 664 */
mbed_official 610:813dcc80987e 665 void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc)
mbed_official 610:813dcc80987e 666 {
mbed_official 610:813dcc80987e 667 /* Get the TimeStamp interrupt source enable status */
mbed_official 610:813dcc80987e 668 if(__HAL_RTC_TIMESTAMP_GET_IT_SOURCE(hrtc, RTC_IT_TS) != RESET)
mbed_official 610:813dcc80987e 669 {
mbed_official 610:813dcc80987e 670 /* Get the pending status of the TIMESTAMP Interrupt */
mbed_official 610:813dcc80987e 671 if(__HAL_RTC_TIMESTAMP_GET_FLAG(hrtc, RTC_FLAG_TSF) != RESET)
mbed_official 610:813dcc80987e 672 {
mbed_official 610:813dcc80987e 673 /* TIMESTAMP callback */
mbed_official 610:813dcc80987e 674 HAL_RTCEx_TimeStampEventCallback(hrtc);
mbed_official 610:813dcc80987e 675
mbed_official 610:813dcc80987e 676 /* Clear the TIMESTAMP interrupt pending bit */
mbed_official 610:813dcc80987e 677 __HAL_RTC_TIMESTAMP_CLEAR_FLAG(hrtc, RTC_FLAG_TSF);
mbed_official 610:813dcc80987e 678 }
mbed_official 610:813dcc80987e 679 }
mbed_official 610:813dcc80987e 680
mbed_official 610:813dcc80987e 681 /* Get the Tamper1 interrupts source enable status */
mbed_official 610:813dcc80987e 682 if(__HAL_RTC_TAMPER_GET_IT_SOURCE(hrtc, RTC_IT_TAMP | RTC_IT_TAMP1) != RESET)
mbed_official 610:813dcc80987e 683 {
mbed_official 610:813dcc80987e 684 /* Get the pending status of the Tamper1 Interrupt */
mbed_official 610:813dcc80987e 685 if(__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP1F) != RESET)
mbed_official 610:813dcc80987e 686 {
mbed_official 610:813dcc80987e 687 /* Tamper1 callback */
mbed_official 610:813dcc80987e 688 HAL_RTCEx_Tamper1EventCallback(hrtc);
mbed_official 610:813dcc80987e 689
mbed_official 610:813dcc80987e 690 /* Clear the Tamper1 interrupt pending bit */
mbed_official 610:813dcc80987e 691 __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP1F);
mbed_official 610:813dcc80987e 692 }
mbed_official 610:813dcc80987e 693 }
mbed_official 610:813dcc80987e 694
mbed_official 610:813dcc80987e 695 /* Get the Tamper2 interrupts source enable status */
mbed_official 610:813dcc80987e 696 if(__HAL_RTC_TAMPER_GET_IT_SOURCE(hrtc, RTC_IT_TAMP | RTC_IT_TAMP2) != RESET)
mbed_official 610:813dcc80987e 697 {
mbed_official 610:813dcc80987e 698 /* Get the pending status of the Tamper2 Interrupt */
mbed_official 610:813dcc80987e 699 if(__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP2F) != RESET)
mbed_official 610:813dcc80987e 700 {
mbed_official 610:813dcc80987e 701 /* Tamper2 callback */
mbed_official 610:813dcc80987e 702 HAL_RTCEx_Tamper2EventCallback(hrtc);
mbed_official 610:813dcc80987e 703
mbed_official 610:813dcc80987e 704 /* Clear the Tamper2 interrupt pending bit */
mbed_official 610:813dcc80987e 705 __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP2F);
mbed_official 610:813dcc80987e 706 }
mbed_official 610:813dcc80987e 707 }
mbed_official 610:813dcc80987e 708
mbed_official 610:813dcc80987e 709 /* Get the Tamper3 interrupts source enable status */
mbed_official 610:813dcc80987e 710 if(__HAL_RTC_TAMPER_GET_IT_SOURCE(hrtc, RTC_IT_TAMP | RTC_IT_TAMP3) != RESET)
mbed_official 610:813dcc80987e 711 {
mbed_official 610:813dcc80987e 712 /* Get the pending status of the Tamper3 Interrupt */
mbed_official 610:813dcc80987e 713 if(__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP3F) != RESET)
mbed_official 610:813dcc80987e 714 {
mbed_official 610:813dcc80987e 715 /* Tamper3 callback */
mbed_official 610:813dcc80987e 716 HAL_RTCEx_Tamper3EventCallback(hrtc);
mbed_official 610:813dcc80987e 717
mbed_official 610:813dcc80987e 718 /* Clear the Tamper3 interrupt pending bit */
mbed_official 610:813dcc80987e 719 __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP3F);
mbed_official 610:813dcc80987e 720 }
mbed_official 610:813dcc80987e 721 }
mbed_official 610:813dcc80987e 722
mbed_official 610:813dcc80987e 723 /* Clear the EXTI's Flag for RTC TimeStamp and Tamper */
mbed_official 610:813dcc80987e 724 __HAL_RTC_TAMPER_TIMESTAMP_EXTI_CLEAR_FLAG();
mbed_official 610:813dcc80987e 725
mbed_official 610:813dcc80987e 726 /* Change RTC state */
mbed_official 610:813dcc80987e 727 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 728 }
mbed_official 610:813dcc80987e 729
mbed_official 610:813dcc80987e 730 /**
mbed_official 610:813dcc80987e 731 * @brief TimeStamp callback.
mbed_official 610:813dcc80987e 732 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 733 * @retval None
mbed_official 610:813dcc80987e 734 */
mbed_official 610:813dcc80987e 735 __weak void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc)
mbed_official 610:813dcc80987e 736 {
mbed_official 610:813dcc80987e 737 /* NOTE : This function should not be modified, when the callback is needed,
mbed_official 610:813dcc80987e 738 the HAL_RTCEx_TimeStampEventCallback could be implemented in the user file
mbed_official 610:813dcc80987e 739 */
mbed_official 610:813dcc80987e 740 }
mbed_official 610:813dcc80987e 741
mbed_official 610:813dcc80987e 742 /**
mbed_official 610:813dcc80987e 743 * @brief Tamper 1 callback.
mbed_official 610:813dcc80987e 744 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 745 * @retval None
mbed_official 610:813dcc80987e 746 */
mbed_official 610:813dcc80987e 747 __weak void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc)
mbed_official 610:813dcc80987e 748 {
mbed_official 610:813dcc80987e 749 /* NOTE : This function should not be modified, when the callback is needed,
mbed_official 610:813dcc80987e 750 the HAL_RTCEx_Tamper1EventCallback could be implemented in the user file
mbed_official 610:813dcc80987e 751 */
mbed_official 610:813dcc80987e 752 }
mbed_official 610:813dcc80987e 753
mbed_official 610:813dcc80987e 754 /**
mbed_official 610:813dcc80987e 755 * @brief Tamper 2 callback.
mbed_official 610:813dcc80987e 756 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 757 * @retval None
mbed_official 610:813dcc80987e 758 */
mbed_official 610:813dcc80987e 759 __weak void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc)
mbed_official 610:813dcc80987e 760 {
mbed_official 610:813dcc80987e 761 /* NOTE : This function should not be modified, when the callback is needed,
mbed_official 610:813dcc80987e 762 the HAL_RTCEx_Tamper2EventCallback could be implemented in the user file
mbed_official 610:813dcc80987e 763 */
mbed_official 610:813dcc80987e 764 }
mbed_official 610:813dcc80987e 765
mbed_official 610:813dcc80987e 766 /**
mbed_official 610:813dcc80987e 767 * @brief Tamper 3 callback.
mbed_official 610:813dcc80987e 768 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 769 * @retval None
mbed_official 610:813dcc80987e 770 */
mbed_official 610:813dcc80987e 771 __weak void HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef *hrtc)
mbed_official 610:813dcc80987e 772 {
mbed_official 610:813dcc80987e 773 /* NOTE : This function should not be modified, when the callback is needed,
mbed_official 610:813dcc80987e 774 the HAL_RTCEx_Tamper3EventCallback could be implemented in the user file
mbed_official 610:813dcc80987e 775 */
mbed_official 610:813dcc80987e 776 }
mbed_official 610:813dcc80987e 777
mbed_official 610:813dcc80987e 778 /**
mbed_official 610:813dcc80987e 779 * @brief Handle TimeStamp polling request.
mbed_official 610:813dcc80987e 780 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 781 * @param Timeout: Timeout duration
mbed_official 610:813dcc80987e 782 * @retval HAL status
mbed_official 610:813dcc80987e 783 */
mbed_official 610:813dcc80987e 784 HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
mbed_official 610:813dcc80987e 785 {
mbed_official 610:813dcc80987e 786 uint32_t tickstart = HAL_GetTick();
mbed_official 610:813dcc80987e 787
mbed_official 610:813dcc80987e 788 while(__HAL_RTC_TIMESTAMP_GET_FLAG(hrtc, RTC_FLAG_TSF) == RESET)
mbed_official 610:813dcc80987e 789 {
mbed_official 610:813dcc80987e 790 if(__HAL_RTC_TIMESTAMP_GET_FLAG(hrtc, RTC_FLAG_TSOVF) != RESET)
mbed_official 610:813dcc80987e 791 {
mbed_official 610:813dcc80987e 792 /* Clear the TIMESTAMP OverRun Flag */
mbed_official 610:813dcc80987e 793 __HAL_RTC_TIMESTAMP_CLEAR_FLAG(hrtc, RTC_FLAG_TSOVF);
mbed_official 610:813dcc80987e 794
mbed_official 610:813dcc80987e 795 /* Change TIMESTAMP state */
mbed_official 610:813dcc80987e 796 hrtc->State = HAL_RTC_STATE_ERROR;
mbed_official 610:813dcc80987e 797
mbed_official 610:813dcc80987e 798 return HAL_ERROR;
mbed_official 610:813dcc80987e 799 }
mbed_official 610:813dcc80987e 800
mbed_official 610:813dcc80987e 801 if(Timeout != HAL_MAX_DELAY)
mbed_official 610:813dcc80987e 802 {
mbed_official 610:813dcc80987e 803 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
mbed_official 610:813dcc80987e 804 {
mbed_official 610:813dcc80987e 805 hrtc->State = HAL_RTC_STATE_TIMEOUT;
mbed_official 610:813dcc80987e 806 return HAL_TIMEOUT;
mbed_official 610:813dcc80987e 807 }
mbed_official 610:813dcc80987e 808 }
mbed_official 610:813dcc80987e 809 }
mbed_official 610:813dcc80987e 810
mbed_official 610:813dcc80987e 811 /* Change RTC state */
mbed_official 610:813dcc80987e 812 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 813
mbed_official 610:813dcc80987e 814 return HAL_OK;
mbed_official 610:813dcc80987e 815 }
mbed_official 610:813dcc80987e 816
mbed_official 610:813dcc80987e 817 /**
mbed_official 610:813dcc80987e 818 * @brief Handle Tamper 1 Polling.
mbed_official 610:813dcc80987e 819 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 820 * @param Timeout: Timeout duration
mbed_official 610:813dcc80987e 821 * @retval HAL status
mbed_official 610:813dcc80987e 822 */
mbed_official 610:813dcc80987e 823 HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
mbed_official 610:813dcc80987e 824 {
mbed_official 610:813dcc80987e 825 uint32_t tickstart = HAL_GetTick();
mbed_official 610:813dcc80987e 826
mbed_official 610:813dcc80987e 827 /* Get the status of the Interrupt */
mbed_official 610:813dcc80987e 828 while(__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP1F)== RESET)
mbed_official 610:813dcc80987e 829 {
mbed_official 610:813dcc80987e 830 if(Timeout != HAL_MAX_DELAY)
mbed_official 610:813dcc80987e 831 {
mbed_official 610:813dcc80987e 832 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
mbed_official 610:813dcc80987e 833 {
mbed_official 610:813dcc80987e 834 hrtc->State = HAL_RTC_STATE_TIMEOUT;
mbed_official 610:813dcc80987e 835 return HAL_TIMEOUT;
mbed_official 610:813dcc80987e 836 }
mbed_official 610:813dcc80987e 837 }
mbed_official 610:813dcc80987e 838 }
mbed_official 610:813dcc80987e 839
mbed_official 610:813dcc80987e 840 /* Clear the Tamper Flag */
mbed_official 610:813dcc80987e 841 __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP1F);
mbed_official 610:813dcc80987e 842
mbed_official 610:813dcc80987e 843 /* Change RTC state */
mbed_official 610:813dcc80987e 844 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 845
mbed_official 610:813dcc80987e 846 return HAL_OK;
mbed_official 610:813dcc80987e 847 }
mbed_official 610:813dcc80987e 848
mbed_official 610:813dcc80987e 849 /**
mbed_official 610:813dcc80987e 850 * @brief Handle Tamper 2 Polling.
mbed_official 610:813dcc80987e 851 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 852 * @param Timeout: Timeout duration
mbed_official 610:813dcc80987e 853 * @retval HAL status
mbed_official 610:813dcc80987e 854 */
mbed_official 610:813dcc80987e 855 HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
mbed_official 610:813dcc80987e 856 {
mbed_official 610:813dcc80987e 857 uint32_t tickstart = HAL_GetTick();
mbed_official 610:813dcc80987e 858
mbed_official 610:813dcc80987e 859 /* Get the status of the Interrupt */
mbed_official 610:813dcc80987e 860 while(__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP2F) == RESET)
mbed_official 610:813dcc80987e 861 {
mbed_official 610:813dcc80987e 862 if(Timeout != HAL_MAX_DELAY)
mbed_official 610:813dcc80987e 863 {
mbed_official 610:813dcc80987e 864 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
mbed_official 610:813dcc80987e 865 {
mbed_official 610:813dcc80987e 866 hrtc->State = HAL_RTC_STATE_TIMEOUT;
mbed_official 610:813dcc80987e 867 return HAL_TIMEOUT;
mbed_official 610:813dcc80987e 868 }
mbed_official 610:813dcc80987e 869 }
mbed_official 610:813dcc80987e 870 }
mbed_official 610:813dcc80987e 871
mbed_official 610:813dcc80987e 872 /* Clear the Tamper Flag */
mbed_official 610:813dcc80987e 873 __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP2F);
mbed_official 610:813dcc80987e 874
mbed_official 610:813dcc80987e 875 /* Change RTC state */
mbed_official 610:813dcc80987e 876 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 877
mbed_official 610:813dcc80987e 878 return HAL_OK;
mbed_official 610:813dcc80987e 879 }
mbed_official 610:813dcc80987e 880
mbed_official 610:813dcc80987e 881 /**
mbed_official 610:813dcc80987e 882 * @brief Handle Tamper 3 Polling.
mbed_official 610:813dcc80987e 883 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 884 * @param Timeout: Timeout duration
mbed_official 610:813dcc80987e 885 * @retval HAL status
mbed_official 610:813dcc80987e 886 */
mbed_official 610:813dcc80987e 887 HAL_StatusTypeDef HAL_RTCEx_PollForTamper3Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
mbed_official 610:813dcc80987e 888 {
mbed_official 610:813dcc80987e 889 uint32_t tickstart = HAL_GetTick();
mbed_official 610:813dcc80987e 890
mbed_official 610:813dcc80987e 891 /* Get the status of the Interrupt */
mbed_official 610:813dcc80987e 892 while(__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP3F) == RESET)
mbed_official 610:813dcc80987e 893 {
mbed_official 610:813dcc80987e 894 if(Timeout != HAL_MAX_DELAY)
mbed_official 610:813dcc80987e 895 {
mbed_official 610:813dcc80987e 896 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
mbed_official 610:813dcc80987e 897 {
mbed_official 610:813dcc80987e 898 hrtc->State = HAL_RTC_STATE_TIMEOUT;
mbed_official 610:813dcc80987e 899 return HAL_TIMEOUT;
mbed_official 610:813dcc80987e 900 }
mbed_official 610:813dcc80987e 901 }
mbed_official 610:813dcc80987e 902 }
mbed_official 610:813dcc80987e 903
mbed_official 610:813dcc80987e 904 /* Clear the Tamper Flag */
mbed_official 610:813dcc80987e 905 __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP3F);
mbed_official 610:813dcc80987e 906
mbed_official 610:813dcc80987e 907 /* Change RTC state */
mbed_official 610:813dcc80987e 908 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 909
mbed_official 610:813dcc80987e 910 return HAL_OK;
mbed_official 610:813dcc80987e 911 }
mbed_official 610:813dcc80987e 912
mbed_official 610:813dcc80987e 913 /**
mbed_official 610:813dcc80987e 914 * @}
mbed_official 610:813dcc80987e 915 */
mbed_official 610:813dcc80987e 916
mbed_official 610:813dcc80987e 917 /** @defgroup RTCEx_Exported_Functions_Group2 RTC Wake-up functions
mbed_official 610:813dcc80987e 918 * @brief RTC Wake-up functions
mbed_official 610:813dcc80987e 919 *
mbed_official 610:813dcc80987e 920 @verbatim
mbed_official 610:813dcc80987e 921 ===============================================================================
mbed_official 610:813dcc80987e 922 ##### RTC Wake-up functions #####
mbed_official 610:813dcc80987e 923 ===============================================================================
mbed_official 610:813dcc80987e 924
mbed_official 610:813dcc80987e 925 [..] This section provide functions allowing to configure Wake-up feature
mbed_official 610:813dcc80987e 926
mbed_official 610:813dcc80987e 927 @endverbatim
mbed_official 610:813dcc80987e 928 * @{
mbed_official 610:813dcc80987e 929 */
mbed_official 610:813dcc80987e 930
mbed_official 610:813dcc80987e 931 /**
mbed_official 610:813dcc80987e 932 * @brief Set wake up timer.
mbed_official 610:813dcc80987e 933 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 934 * @param WakeUpCounter: Wake up counter
mbed_official 610:813dcc80987e 935 * @param WakeUpClock: Wake up clock
mbed_official 610:813dcc80987e 936 * @retval HAL status
mbed_official 610:813dcc80987e 937 */
mbed_official 610:813dcc80987e 938 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock)
mbed_official 610:813dcc80987e 939 {
mbed_official 610:813dcc80987e 940 uint32_t tickstart = 0;
mbed_official 610:813dcc80987e 941
mbed_official 610:813dcc80987e 942 /* Check the parameters */
mbed_official 610:813dcc80987e 943 assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock));
mbed_official 610:813dcc80987e 944 assert_param(IS_RTC_WAKEUP_COUNTER(WakeUpCounter));
mbed_official 610:813dcc80987e 945
mbed_official 610:813dcc80987e 946 /* Process Locked */
mbed_official 610:813dcc80987e 947 __HAL_LOCK(hrtc);
mbed_official 610:813dcc80987e 948
mbed_official 610:813dcc80987e 949 hrtc->State = HAL_RTC_STATE_BUSY;
mbed_official 610:813dcc80987e 950
mbed_official 610:813dcc80987e 951 /* Disable the write protection for RTC registers */
mbed_official 610:813dcc80987e 952 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
mbed_official 610:813dcc80987e 953
mbed_official 610:813dcc80987e 954 /*Check RTC WUTWF flag is reset only when wake up timer enabled*/
mbed_official 610:813dcc80987e 955 if((hrtc->Instance->CR & RTC_CR_WUTE) != RESET)
mbed_official 610:813dcc80987e 956 {
mbed_official 610:813dcc80987e 957 tickstart = HAL_GetTick();
mbed_official 610:813dcc80987e 958
mbed_official 610:813dcc80987e 959 /* Wait till RTC WUTWF flag is reset and if Time out is reached exit */
mbed_official 610:813dcc80987e 960 while(__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTWF) == SET)
mbed_official 610:813dcc80987e 961 {
mbed_official 610:813dcc80987e 962 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
mbed_official 610:813dcc80987e 963 {
mbed_official 610:813dcc80987e 964 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 965 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 966
mbed_official 610:813dcc80987e 967 hrtc->State = HAL_RTC_STATE_TIMEOUT;
mbed_official 610:813dcc80987e 968
mbed_official 610:813dcc80987e 969 /* Process Unlocked */
mbed_official 610:813dcc80987e 970 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 971
mbed_official 610:813dcc80987e 972 return HAL_TIMEOUT;
mbed_official 610:813dcc80987e 973 }
mbed_official 610:813dcc80987e 974 }
mbed_official 610:813dcc80987e 975 }
mbed_official 610:813dcc80987e 976
mbed_official 610:813dcc80987e 977 __HAL_RTC_WAKEUPTIMER_DISABLE(hrtc);
mbed_official 610:813dcc80987e 978
mbed_official 610:813dcc80987e 979 tickstart = HAL_GetTick();
mbed_official 610:813dcc80987e 980
mbed_official 610:813dcc80987e 981 /* Wait till RTC WUTWF flag is set and if Time out is reached exit */
mbed_official 610:813dcc80987e 982 while(__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTWF) == RESET)
mbed_official 610:813dcc80987e 983 {
mbed_official 610:813dcc80987e 984 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
mbed_official 610:813dcc80987e 985 {
mbed_official 610:813dcc80987e 986 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 987 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 988
mbed_official 610:813dcc80987e 989 hrtc->State = HAL_RTC_STATE_TIMEOUT;
mbed_official 610:813dcc80987e 990
mbed_official 610:813dcc80987e 991 /* Process Unlocked */
mbed_official 610:813dcc80987e 992 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 993
mbed_official 610:813dcc80987e 994 return HAL_TIMEOUT;
mbed_official 610:813dcc80987e 995 }
mbed_official 610:813dcc80987e 996 }
mbed_official 610:813dcc80987e 997
mbed_official 610:813dcc80987e 998 /* Clear the Wakeup Timer clock source bits in CR register */
mbed_official 610:813dcc80987e 999 hrtc->Instance->CR &= (uint32_t)~RTC_CR_WUCKSEL;
mbed_official 610:813dcc80987e 1000
mbed_official 610:813dcc80987e 1001 /* Configure the clock source */
mbed_official 610:813dcc80987e 1002 hrtc->Instance->CR |= (uint32_t)WakeUpClock;
mbed_official 610:813dcc80987e 1003
mbed_official 610:813dcc80987e 1004 /* Configure the Wakeup Timer counter */
mbed_official 610:813dcc80987e 1005 hrtc->Instance->WUTR = (uint32_t)WakeUpCounter;
mbed_official 610:813dcc80987e 1006
mbed_official 610:813dcc80987e 1007 /* Enable the Wakeup Timer */
mbed_official 610:813dcc80987e 1008 __HAL_RTC_WAKEUPTIMER_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1009
mbed_official 610:813dcc80987e 1010 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1011 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1012
mbed_official 610:813dcc80987e 1013 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 1014
mbed_official 610:813dcc80987e 1015 /* Process Unlocked */
mbed_official 610:813dcc80987e 1016 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1017
mbed_official 610:813dcc80987e 1018 return HAL_OK;
mbed_official 610:813dcc80987e 1019 }
mbed_official 610:813dcc80987e 1020
mbed_official 610:813dcc80987e 1021 /**
mbed_official 610:813dcc80987e 1022 * @brief Set wake up timer with interrupt.
mbed_official 610:813dcc80987e 1023 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 1024 * @param WakeUpCounter: Wake up counter
mbed_official 610:813dcc80987e 1025 * @param WakeUpClock: Wake up clock
mbed_official 610:813dcc80987e 1026 * @retval HAL status
mbed_official 610:813dcc80987e 1027 */
mbed_official 610:813dcc80987e 1028 HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock)
mbed_official 610:813dcc80987e 1029 {
mbed_official 610:813dcc80987e 1030 uint32_t tickstart = 0;
mbed_official 610:813dcc80987e 1031
mbed_official 610:813dcc80987e 1032 /* Check the parameters */
mbed_official 610:813dcc80987e 1033 assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock));
mbed_official 610:813dcc80987e 1034 assert_param(IS_RTC_WAKEUP_COUNTER(WakeUpCounter));
mbed_official 610:813dcc80987e 1035
mbed_official 610:813dcc80987e 1036 /* Process Locked */
mbed_official 610:813dcc80987e 1037 __HAL_LOCK(hrtc);
mbed_official 610:813dcc80987e 1038
mbed_official 610:813dcc80987e 1039 hrtc->State = HAL_RTC_STATE_BUSY;
mbed_official 610:813dcc80987e 1040
mbed_official 610:813dcc80987e 1041 /* Disable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1042 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
mbed_official 610:813dcc80987e 1043
mbed_official 610:813dcc80987e 1044 /*Check RTC WUTWF flag is reset only when wake up timer enabled*/
mbed_official 610:813dcc80987e 1045 if((hrtc->Instance->CR & RTC_CR_WUTE) != RESET)
mbed_official 610:813dcc80987e 1046 {
mbed_official 610:813dcc80987e 1047 tickstart = HAL_GetTick();
mbed_official 610:813dcc80987e 1048
mbed_official 610:813dcc80987e 1049 /* Wait till RTC WUTWF flag is reset and if Time out is reached exit */
mbed_official 610:813dcc80987e 1050 while(__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTWF) == SET)
mbed_official 610:813dcc80987e 1051 {
mbed_official 610:813dcc80987e 1052 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
mbed_official 610:813dcc80987e 1053 {
mbed_official 610:813dcc80987e 1054 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1055 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1056
mbed_official 610:813dcc80987e 1057 hrtc->State = HAL_RTC_STATE_TIMEOUT;
mbed_official 610:813dcc80987e 1058
mbed_official 610:813dcc80987e 1059 /* Process Unlocked */
mbed_official 610:813dcc80987e 1060 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1061
mbed_official 610:813dcc80987e 1062 return HAL_TIMEOUT;
mbed_official 610:813dcc80987e 1063 }
mbed_official 610:813dcc80987e 1064 }
mbed_official 610:813dcc80987e 1065 }
mbed_official 610:813dcc80987e 1066
mbed_official 610:813dcc80987e 1067 __HAL_RTC_WAKEUPTIMER_DISABLE(hrtc);
mbed_official 610:813dcc80987e 1068
mbed_official 610:813dcc80987e 1069 tickstart = HAL_GetTick();
mbed_official 610:813dcc80987e 1070
mbed_official 610:813dcc80987e 1071 /* Wait till RTC WUTWF flag is set and if Time out is reached exit */
mbed_official 610:813dcc80987e 1072 while(__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTWF) == RESET)
mbed_official 610:813dcc80987e 1073 {
mbed_official 610:813dcc80987e 1074 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
mbed_official 610:813dcc80987e 1075 {
mbed_official 610:813dcc80987e 1076 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1077 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1078
mbed_official 610:813dcc80987e 1079 hrtc->State = HAL_RTC_STATE_TIMEOUT;
mbed_official 610:813dcc80987e 1080
mbed_official 610:813dcc80987e 1081 /* Process Unlocked */
mbed_official 610:813dcc80987e 1082 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1083
mbed_official 610:813dcc80987e 1084 return HAL_TIMEOUT;
mbed_official 610:813dcc80987e 1085 }
mbed_official 610:813dcc80987e 1086 }
mbed_official 610:813dcc80987e 1087
mbed_official 610:813dcc80987e 1088 /* Configure the Wakeup Timer counter */
mbed_official 610:813dcc80987e 1089 hrtc->Instance->WUTR = (uint32_t)WakeUpCounter;
mbed_official 610:813dcc80987e 1090
mbed_official 610:813dcc80987e 1091 /* Clear the Wakeup Timer clock source bits in CR register */
mbed_official 610:813dcc80987e 1092 hrtc->Instance->CR &= (uint32_t)~RTC_CR_WUCKSEL;
mbed_official 610:813dcc80987e 1093
mbed_official 610:813dcc80987e 1094 /* Configure the clock source */
mbed_official 610:813dcc80987e 1095 hrtc->Instance->CR |= (uint32_t)WakeUpClock;
mbed_official 610:813dcc80987e 1096
mbed_official 610:813dcc80987e 1097 /* RTC WakeUpTimer Interrupt Configuration: EXTI configuration */
mbed_official 610:813dcc80987e 1098 __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT();
mbed_official 610:813dcc80987e 1099
mbed_official 610:813dcc80987e 1100 __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE();
mbed_official 610:813dcc80987e 1101
mbed_official 610:813dcc80987e 1102 /* Configure the Interrupt in the RTC_CR register */
mbed_official 610:813dcc80987e 1103 __HAL_RTC_WAKEUPTIMER_ENABLE_IT(hrtc,RTC_IT_WUT);
mbed_official 610:813dcc80987e 1104
mbed_official 610:813dcc80987e 1105 /* Enable the Wakeup Timer */
mbed_official 610:813dcc80987e 1106 __HAL_RTC_WAKEUPTIMER_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1107
mbed_official 610:813dcc80987e 1108 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1109 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1110
mbed_official 610:813dcc80987e 1111 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 1112
mbed_official 610:813dcc80987e 1113 /* Process Unlocked */
mbed_official 610:813dcc80987e 1114 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1115
mbed_official 610:813dcc80987e 1116 return HAL_OK;
mbed_official 610:813dcc80987e 1117 }
mbed_official 610:813dcc80987e 1118
mbed_official 610:813dcc80987e 1119 /**
mbed_official 610:813dcc80987e 1120 * @brief Deactivate wake up timer counter.
mbed_official 610:813dcc80987e 1121 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 1122 * @retval HAL status
mbed_official 610:813dcc80987e 1123 */
mbed_official 610:813dcc80987e 1124 uint32_t HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc)
mbed_official 610:813dcc80987e 1125 {
mbed_official 610:813dcc80987e 1126 uint32_t tickstart = 0;
mbed_official 610:813dcc80987e 1127
mbed_official 610:813dcc80987e 1128 /* Process Locked */
mbed_official 610:813dcc80987e 1129 __HAL_LOCK(hrtc);
mbed_official 610:813dcc80987e 1130
mbed_official 610:813dcc80987e 1131 hrtc->State = HAL_RTC_STATE_BUSY;
mbed_official 610:813dcc80987e 1132
mbed_official 610:813dcc80987e 1133 /* Disable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1134 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
mbed_official 610:813dcc80987e 1135
mbed_official 610:813dcc80987e 1136 /* Disable the Wakeup Timer */
mbed_official 610:813dcc80987e 1137 __HAL_RTC_WAKEUPTIMER_DISABLE(hrtc);
mbed_official 610:813dcc80987e 1138
mbed_official 610:813dcc80987e 1139 /* In case of interrupt mode is used, the interrupt source must disabled */
mbed_official 610:813dcc80987e 1140 __HAL_RTC_WAKEUPTIMER_DISABLE_IT(hrtc,RTC_IT_WUT);
mbed_official 610:813dcc80987e 1141
mbed_official 610:813dcc80987e 1142 tickstart = HAL_GetTick();
mbed_official 610:813dcc80987e 1143 /* Wait till RTC WUTWF flag is set and if Time out is reached exit */
mbed_official 610:813dcc80987e 1144 while(__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTWF) == RESET)
mbed_official 610:813dcc80987e 1145 {
mbed_official 610:813dcc80987e 1146 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
mbed_official 610:813dcc80987e 1147 {
mbed_official 610:813dcc80987e 1148 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1149 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1150
mbed_official 610:813dcc80987e 1151 hrtc->State = HAL_RTC_STATE_TIMEOUT;
mbed_official 610:813dcc80987e 1152
mbed_official 610:813dcc80987e 1153 /* Process Unlocked */
mbed_official 610:813dcc80987e 1154 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1155
mbed_official 610:813dcc80987e 1156 return HAL_TIMEOUT;
mbed_official 610:813dcc80987e 1157 }
mbed_official 610:813dcc80987e 1158 }
mbed_official 610:813dcc80987e 1159
mbed_official 610:813dcc80987e 1160 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1161 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1162
mbed_official 610:813dcc80987e 1163 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 1164
mbed_official 610:813dcc80987e 1165 /* Process Unlocked */
mbed_official 610:813dcc80987e 1166 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1167
mbed_official 610:813dcc80987e 1168 return HAL_OK;
mbed_official 610:813dcc80987e 1169 }
mbed_official 610:813dcc80987e 1170
mbed_official 610:813dcc80987e 1171 /**
mbed_official 610:813dcc80987e 1172 * @brief Get wake up timer counter.
mbed_official 610:813dcc80987e 1173 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 1174 * @retval Counter value
mbed_official 610:813dcc80987e 1175 */
mbed_official 610:813dcc80987e 1176 uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc)
mbed_official 610:813dcc80987e 1177 {
mbed_official 610:813dcc80987e 1178 /* Get the counter value */
mbed_official 610:813dcc80987e 1179 return ((uint32_t)(hrtc->Instance->WUTR & RTC_WUTR_WUT));
mbed_official 610:813dcc80987e 1180 }
mbed_official 610:813dcc80987e 1181
mbed_official 610:813dcc80987e 1182 /**
mbed_official 610:813dcc80987e 1183 * @brief Handle Wake Up Timer interrupt request.
mbed_official 610:813dcc80987e 1184 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 1185 * @retval None
mbed_official 610:813dcc80987e 1186 */
mbed_official 610:813dcc80987e 1187 void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc)
mbed_official 610:813dcc80987e 1188 {
mbed_official 610:813dcc80987e 1189 /* Get the pending status of the WAKEUPTIMER Interrupt */
mbed_official 610:813dcc80987e 1190 if(__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTF) != RESET)
mbed_official 610:813dcc80987e 1191 {
mbed_official 610:813dcc80987e 1192 /* WAKEUPTIMER callback */
mbed_official 610:813dcc80987e 1193 HAL_RTCEx_WakeUpTimerEventCallback(hrtc);
mbed_official 610:813dcc80987e 1194
mbed_official 610:813dcc80987e 1195 /* Clear the WAKEUPTIMER interrupt pending bit */
mbed_official 610:813dcc80987e 1196 __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(hrtc, RTC_FLAG_WUTF);
mbed_official 610:813dcc80987e 1197 }
mbed_official 610:813dcc80987e 1198
mbed_official 610:813dcc80987e 1199
mbed_official 610:813dcc80987e 1200 /* Clear the EXTI's line Flag for RTC WakeUpTimer */
mbed_official 610:813dcc80987e 1201 __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG();
mbed_official 610:813dcc80987e 1202
mbed_official 610:813dcc80987e 1203 /* Change RTC state */
mbed_official 610:813dcc80987e 1204 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 1205 }
mbed_official 610:813dcc80987e 1206
mbed_official 610:813dcc80987e 1207 /**
mbed_official 610:813dcc80987e 1208 * @brief Wake Up Timer callback.
mbed_official 610:813dcc80987e 1209 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 1210 * @retval None
mbed_official 610:813dcc80987e 1211 */
mbed_official 610:813dcc80987e 1212 __weak void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc)
mbed_official 610:813dcc80987e 1213 {
mbed_official 610:813dcc80987e 1214 /* NOTE : This function should not be modified, when the callback is needed,
mbed_official 610:813dcc80987e 1215 the HAL_RTCEx_WakeUpTimerEventCallback could be implemented in the user file
mbed_official 610:813dcc80987e 1216 */
mbed_official 610:813dcc80987e 1217 }
mbed_official 610:813dcc80987e 1218
mbed_official 610:813dcc80987e 1219 /**
mbed_official 610:813dcc80987e 1220 * @brief Handle Wake Up Timer Polling.
mbed_official 610:813dcc80987e 1221 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 1222 * @param Timeout: Timeout duration
mbed_official 610:813dcc80987e 1223 * @retval HAL status
mbed_official 610:813dcc80987e 1224 */
mbed_official 610:813dcc80987e 1225 HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
mbed_official 610:813dcc80987e 1226 {
mbed_official 610:813dcc80987e 1227 uint32_t tickstart = HAL_GetTick();
mbed_official 610:813dcc80987e 1228
mbed_official 610:813dcc80987e 1229 while(__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTF) == RESET)
mbed_official 610:813dcc80987e 1230 {
mbed_official 610:813dcc80987e 1231 if(Timeout != HAL_MAX_DELAY)
mbed_official 610:813dcc80987e 1232 {
mbed_official 610:813dcc80987e 1233 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
mbed_official 610:813dcc80987e 1234 {
mbed_official 610:813dcc80987e 1235 hrtc->State = HAL_RTC_STATE_TIMEOUT;
mbed_official 610:813dcc80987e 1236
mbed_official 610:813dcc80987e 1237 return HAL_TIMEOUT;
mbed_official 610:813dcc80987e 1238 }
mbed_official 610:813dcc80987e 1239 }
mbed_official 610:813dcc80987e 1240 }
mbed_official 610:813dcc80987e 1241
mbed_official 610:813dcc80987e 1242 /* Clear the WAKEUPTIMER Flag */
mbed_official 610:813dcc80987e 1243 __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(hrtc, RTC_FLAG_WUTF);
mbed_official 610:813dcc80987e 1244
mbed_official 610:813dcc80987e 1245 /* Change RTC state */
mbed_official 610:813dcc80987e 1246 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 1247
mbed_official 610:813dcc80987e 1248 return HAL_OK;
mbed_official 610:813dcc80987e 1249 }
mbed_official 610:813dcc80987e 1250
mbed_official 610:813dcc80987e 1251 /**
mbed_official 610:813dcc80987e 1252 * @}
mbed_official 610:813dcc80987e 1253 */
mbed_official 610:813dcc80987e 1254
mbed_official 610:813dcc80987e 1255
mbed_official 610:813dcc80987e 1256 /** @defgroup RTCEx_Exported_Functions_Group3 Extended Peripheral Control functions
mbed_official 610:813dcc80987e 1257 * @brief Extended Peripheral Control functions
mbed_official 610:813dcc80987e 1258 *
mbed_official 610:813dcc80987e 1259 @verbatim
mbed_official 610:813dcc80987e 1260 ===============================================================================
mbed_official 610:813dcc80987e 1261 ##### Extended Peripheral Control functions #####
mbed_official 610:813dcc80987e 1262 ===============================================================================
mbed_official 610:813dcc80987e 1263 [..]
mbed_official 610:813dcc80987e 1264 This subsection provides functions allowing to
mbed_official 610:813dcc80987e 1265 (+) Write a data in a specified RTC Backup data register
mbed_official 610:813dcc80987e 1266 (+) Read a data in a specified RTC Backup data register
mbed_official 610:813dcc80987e 1267 (+) Set the Coarse calibration parameters.
mbed_official 610:813dcc80987e 1268 (+) Deactivate the Coarse calibration parameters
mbed_official 610:813dcc80987e 1269 (+) Set the Smooth calibration parameters.
mbed_official 610:813dcc80987e 1270 (+) Configure the Synchronization Shift Control Settings.
mbed_official 610:813dcc80987e 1271 (+) Configure the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz).
mbed_official 610:813dcc80987e 1272 (+) Deactivate the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz).
mbed_official 610:813dcc80987e 1273 (+) Enable the RTC reference clock detection.
mbed_official 610:813dcc80987e 1274 (+) Disable the RTC reference clock detection.
mbed_official 610:813dcc80987e 1275 (+) Enable the Bypass Shadow feature.
mbed_official 610:813dcc80987e 1276 (+) Disable the Bypass Shadow feature.
mbed_official 610:813dcc80987e 1277
mbed_official 610:813dcc80987e 1278 @endverbatim
mbed_official 610:813dcc80987e 1279 * @{
mbed_official 610:813dcc80987e 1280 */
mbed_official 610:813dcc80987e 1281
mbed_official 610:813dcc80987e 1282 /**
mbed_official 610:813dcc80987e 1283 * @brief Write a data in a specified RTC Backup data register.
mbed_official 610:813dcc80987e 1284 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 1285 * @param BackupRegister: RTC Backup data Register number.
mbed_official 610:813dcc80987e 1286 * This parameter can be: RTC_BKP_DRx where x can be from 0 to 19 to
mbed_official 610:813dcc80987e 1287 * specify the register.
mbed_official 610:813dcc80987e 1288 * @param Data: Data to be written in the specified RTC Backup data register.
mbed_official 610:813dcc80987e 1289 * @retval None
mbed_official 610:813dcc80987e 1290 */
mbed_official 610:813dcc80987e 1291 void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data)
mbed_official 610:813dcc80987e 1292 {
mbed_official 610:813dcc80987e 1293 uint32_t tmp = 0;
mbed_official 610:813dcc80987e 1294
mbed_official 610:813dcc80987e 1295 /* Check the parameters */
mbed_official 610:813dcc80987e 1296 assert_param(IS_RTC_BKP(BackupRegister));
mbed_official 610:813dcc80987e 1297
mbed_official 610:813dcc80987e 1298 tmp = (uint32_t)&(hrtc->Instance->BKP0R);
mbed_official 610:813dcc80987e 1299 tmp += (BackupRegister * 4);
mbed_official 610:813dcc80987e 1300
mbed_official 610:813dcc80987e 1301 /* Write the specified register */
mbed_official 610:813dcc80987e 1302 *(__IO uint32_t *)tmp = (uint32_t)Data;
mbed_official 610:813dcc80987e 1303 }
mbed_official 610:813dcc80987e 1304
mbed_official 610:813dcc80987e 1305 /**
mbed_official 610:813dcc80987e 1306 * @brief Read data from the specified RTC Backup data Register.
mbed_official 610:813dcc80987e 1307 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 1308 * @param BackupRegister: RTC Backup data Register number.
mbed_official 610:813dcc80987e 1309 * This parameter can be: RTC_BKP_DRx where x can be from 0 to 19 to
mbed_official 610:813dcc80987e 1310 * specify the register.
mbed_official 610:813dcc80987e 1311 * @retval Read value
mbed_official 610:813dcc80987e 1312 */
mbed_official 610:813dcc80987e 1313 uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister)
mbed_official 610:813dcc80987e 1314 {
mbed_official 610:813dcc80987e 1315 uint32_t tmp = 0;
mbed_official 610:813dcc80987e 1316
mbed_official 610:813dcc80987e 1317 /* Check the parameters */
mbed_official 610:813dcc80987e 1318 assert_param(IS_RTC_BKP(BackupRegister));
mbed_official 610:813dcc80987e 1319
mbed_official 610:813dcc80987e 1320 tmp = (uint32_t)&(hrtc->Instance->BKP0R);
mbed_official 610:813dcc80987e 1321 tmp += (BackupRegister * 4);
mbed_official 610:813dcc80987e 1322
mbed_official 610:813dcc80987e 1323 /* Read the specified register */
mbed_official 610:813dcc80987e 1324 return (*(__IO uint32_t *)tmp);
mbed_official 610:813dcc80987e 1325 }
mbed_official 610:813dcc80987e 1326
mbed_official 610:813dcc80987e 1327 /**
mbed_official 610:813dcc80987e 1328 * @brief Set the Smooth calibration parameters.
mbed_official 610:813dcc80987e 1329 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 1330 * @param SmoothCalibPeriod: Select the Smooth Calibration Period.
mbed_official 610:813dcc80987e 1331 * This parameter can be can be one of the following values :
mbed_official 610:813dcc80987e 1332 * @arg RTC_SMOOTHCALIB_PERIOD_32SEC: The smooth calibration period is 32s.
mbed_official 610:813dcc80987e 1333 * @arg RTC_SMOOTHCALIB_PERIOD_16SEC: The smooth calibration period is 16s.
mbed_official 610:813dcc80987e 1334 * @arg RTC_SMOOTHCALIB_PERIOD_8SEC: The smooth calibration period is 8s.
mbed_official 610:813dcc80987e 1335 * @param SmoothCalibPlusPulses: Select to Set or reset the CALP bit.
mbed_official 610:813dcc80987e 1336 * This parameter can be one of the following values:
mbed_official 610:813dcc80987e 1337 * @arg RTC_SMOOTHCALIB_PLUSPULSES_SET: Add one RTCCLK pulse every 2*11 pulses.
mbed_official 610:813dcc80987e 1338 * @arg RTC_SMOOTHCALIB_PLUSPULSES_RESET: No RTCCLK pulses are added.
mbed_official 610:813dcc80987e 1339 * @param SmoothCalibMinusPulsesValue: Select the value of CALM[8:0] bits.
mbed_official 610:813dcc80987e 1340 * This parameter can be one any value from 0 to 0x000001FF.
mbed_official 610:813dcc80987e 1341 * @note To deactivate the smooth calibration, the field SmoothCalibPlusPulses
mbed_official 610:813dcc80987e 1342 * must be equal to SMOOTHCALIB_PLUSPULSES_RESET and the field
mbed_official 610:813dcc80987e 1343 * SmoothCalibMinusPulsesValue must be equal to 0.
mbed_official 610:813dcc80987e 1344 * @retval HAL status
mbed_official 610:813dcc80987e 1345 */
mbed_official 610:813dcc80987e 1346 HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef* hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue)
mbed_official 610:813dcc80987e 1347 {
mbed_official 610:813dcc80987e 1348 uint32_t tickstart = 0;
mbed_official 610:813dcc80987e 1349
mbed_official 610:813dcc80987e 1350 /* Check the parameters */
mbed_official 610:813dcc80987e 1351 assert_param(IS_RTC_SMOOTH_CALIB_PERIOD(SmoothCalibPeriod));
mbed_official 610:813dcc80987e 1352 assert_param(IS_RTC_SMOOTH_CALIB_PLUS(SmoothCalibPlusPulses));
mbed_official 610:813dcc80987e 1353 assert_param(IS_RTC_SMOOTH_CALIB_MINUS(SmoothCalibMinusPulsesValue));
mbed_official 610:813dcc80987e 1354
mbed_official 610:813dcc80987e 1355 /* Process Locked */
mbed_official 610:813dcc80987e 1356 __HAL_LOCK(hrtc);
mbed_official 610:813dcc80987e 1357
mbed_official 610:813dcc80987e 1358 hrtc->State = HAL_RTC_STATE_BUSY;
mbed_official 610:813dcc80987e 1359
mbed_official 610:813dcc80987e 1360 /* Disable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1361 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
mbed_official 610:813dcc80987e 1362
mbed_official 610:813dcc80987e 1363 /* check if a calibration is pending*/
mbed_official 610:813dcc80987e 1364 if((hrtc->Instance->ISR & RTC_ISR_RECALPF) != RESET)
mbed_official 610:813dcc80987e 1365 {
mbed_official 610:813dcc80987e 1366 tickstart = HAL_GetTick();
mbed_official 610:813dcc80987e 1367
mbed_official 610:813dcc80987e 1368 /* check if a calibration is pending*/
mbed_official 610:813dcc80987e 1369 while((hrtc->Instance->ISR & RTC_ISR_RECALPF) != RESET)
mbed_official 610:813dcc80987e 1370 {
mbed_official 610:813dcc80987e 1371 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
mbed_official 610:813dcc80987e 1372 {
mbed_official 610:813dcc80987e 1373 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1374 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1375
mbed_official 610:813dcc80987e 1376 /* Change RTC state */
mbed_official 610:813dcc80987e 1377 hrtc->State = HAL_RTC_STATE_TIMEOUT;
mbed_official 610:813dcc80987e 1378
mbed_official 610:813dcc80987e 1379 /* Process Unlocked */
mbed_official 610:813dcc80987e 1380 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1381
mbed_official 610:813dcc80987e 1382 return HAL_TIMEOUT;
mbed_official 610:813dcc80987e 1383 }
mbed_official 610:813dcc80987e 1384 }
mbed_official 610:813dcc80987e 1385 }
mbed_official 610:813dcc80987e 1386
mbed_official 610:813dcc80987e 1387 /* Configure the Smooth calibration settings */
mbed_official 610:813dcc80987e 1388 hrtc->Instance->CALR = (uint32_t)((uint32_t)SmoothCalibPeriod | (uint32_t)SmoothCalibPlusPulses | (uint32_t)SmoothCalibMinusPulsesValue);
mbed_official 610:813dcc80987e 1389
mbed_official 610:813dcc80987e 1390 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1391 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1392
mbed_official 610:813dcc80987e 1393 /* Change RTC state */
mbed_official 610:813dcc80987e 1394 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 1395
mbed_official 610:813dcc80987e 1396 /* Process Unlocked */
mbed_official 610:813dcc80987e 1397 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1398
mbed_official 610:813dcc80987e 1399 return HAL_OK;
mbed_official 610:813dcc80987e 1400 }
mbed_official 610:813dcc80987e 1401
mbed_official 610:813dcc80987e 1402 /**
mbed_official 610:813dcc80987e 1403 * @brief Configure the Synchronization Shift Control Settings.
mbed_official 610:813dcc80987e 1404 * @note When REFCKON is set, firmware must not write to Shift control register.
mbed_official 610:813dcc80987e 1405 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 1406 * @param ShiftAdd1S: Select to add or not 1 second to the time calendar.
mbed_official 610:813dcc80987e 1407 * This parameter can be one of the following values :
mbed_official 610:813dcc80987e 1408 * @arg RTC_SHIFTADD1S_SET: Add one second to the clock calendar.
mbed_official 610:813dcc80987e 1409 * @arg RTC_SHIFTADD1S_RESET: No effect.
mbed_official 610:813dcc80987e 1410 * @param ShiftSubFS: Select the number of Second Fractions to substitute.
mbed_official 610:813dcc80987e 1411 * This parameter can be one any value from 0 to 0x7FFF.
mbed_official 610:813dcc80987e 1412 * @retval HAL status
mbed_official 610:813dcc80987e 1413 */
mbed_official 610:813dcc80987e 1414 HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef* hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS)
mbed_official 610:813dcc80987e 1415 {
mbed_official 610:813dcc80987e 1416 uint32_t tickstart = 0;
mbed_official 610:813dcc80987e 1417
mbed_official 610:813dcc80987e 1418 /* Check the parameters */
mbed_official 610:813dcc80987e 1419 assert_param(IS_RTC_SHIFT_ADD1S(ShiftAdd1S));
mbed_official 610:813dcc80987e 1420 assert_param(IS_RTC_SHIFT_SUBFS(ShiftSubFS));
mbed_official 610:813dcc80987e 1421
mbed_official 610:813dcc80987e 1422 /* Process Locked */
mbed_official 610:813dcc80987e 1423 __HAL_LOCK(hrtc);
mbed_official 610:813dcc80987e 1424
mbed_official 610:813dcc80987e 1425 hrtc->State = HAL_RTC_STATE_BUSY;
mbed_official 610:813dcc80987e 1426
mbed_official 610:813dcc80987e 1427 /* Disable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1428 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
mbed_official 610:813dcc80987e 1429
mbed_official 610:813dcc80987e 1430 tickstart = HAL_GetTick();
mbed_official 610:813dcc80987e 1431
mbed_official 610:813dcc80987e 1432 /* Wait until the shift is completed*/
mbed_official 610:813dcc80987e 1433 while((hrtc->Instance->ISR & RTC_ISR_SHPF) != RESET)
mbed_official 610:813dcc80987e 1434 {
mbed_official 610:813dcc80987e 1435 if((HAL_GetTick() - tickstart ) > RTC_TIMEOUT_VALUE)
mbed_official 610:813dcc80987e 1436 {
mbed_official 610:813dcc80987e 1437 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1438 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1439
mbed_official 610:813dcc80987e 1440 hrtc->State = HAL_RTC_STATE_TIMEOUT;
mbed_official 610:813dcc80987e 1441
mbed_official 610:813dcc80987e 1442 /* Process Unlocked */
mbed_official 610:813dcc80987e 1443 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1444
mbed_official 610:813dcc80987e 1445 return HAL_TIMEOUT;
mbed_official 610:813dcc80987e 1446 }
mbed_official 610:813dcc80987e 1447 }
mbed_official 610:813dcc80987e 1448
mbed_official 610:813dcc80987e 1449 /* Check if the reference clock detection is disabled */
mbed_official 610:813dcc80987e 1450 if((hrtc->Instance->CR & RTC_CR_REFCKON) == RESET)
mbed_official 610:813dcc80987e 1451 {
mbed_official 610:813dcc80987e 1452 /* Configure the Shift settings */
mbed_official 610:813dcc80987e 1453 hrtc->Instance->SHIFTR = (uint32_t)(uint32_t)(ShiftSubFS) | (uint32_t)(ShiftAdd1S);
mbed_official 610:813dcc80987e 1454
mbed_official 610:813dcc80987e 1455 /* If RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */
mbed_official 610:813dcc80987e 1456 if((hrtc->Instance->CR & RTC_CR_BYPSHAD) == RESET)
mbed_official 610:813dcc80987e 1457 {
mbed_official 610:813dcc80987e 1458 if(HAL_RTC_WaitForSynchro(hrtc) != HAL_OK)
mbed_official 610:813dcc80987e 1459 {
mbed_official 610:813dcc80987e 1460 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1461 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1462
mbed_official 610:813dcc80987e 1463 hrtc->State = HAL_RTC_STATE_ERROR;
mbed_official 610:813dcc80987e 1464
mbed_official 610:813dcc80987e 1465 /* Process Unlocked */
mbed_official 610:813dcc80987e 1466 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1467
mbed_official 610:813dcc80987e 1468 return HAL_ERROR;
mbed_official 610:813dcc80987e 1469 }
mbed_official 610:813dcc80987e 1470 }
mbed_official 610:813dcc80987e 1471 }
mbed_official 610:813dcc80987e 1472 else
mbed_official 610:813dcc80987e 1473 {
mbed_official 610:813dcc80987e 1474 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1475 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1476
mbed_official 610:813dcc80987e 1477 /* Change RTC state */
mbed_official 610:813dcc80987e 1478 hrtc->State = HAL_RTC_STATE_ERROR;
mbed_official 610:813dcc80987e 1479
mbed_official 610:813dcc80987e 1480 /* Process Unlocked */
mbed_official 610:813dcc80987e 1481 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1482
mbed_official 610:813dcc80987e 1483 return HAL_ERROR;
mbed_official 610:813dcc80987e 1484 }
mbed_official 610:813dcc80987e 1485
mbed_official 610:813dcc80987e 1486 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1487 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1488
mbed_official 610:813dcc80987e 1489 /* Change RTC state */
mbed_official 610:813dcc80987e 1490 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 1491
mbed_official 610:813dcc80987e 1492 /* Process Unlocked */
mbed_official 610:813dcc80987e 1493 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1494
mbed_official 610:813dcc80987e 1495 return HAL_OK;
mbed_official 610:813dcc80987e 1496 }
mbed_official 610:813dcc80987e 1497
mbed_official 610:813dcc80987e 1498 /**
mbed_official 610:813dcc80987e 1499 * @brief Configure the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz).
mbed_official 610:813dcc80987e 1500 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 1501 * @param CalibOutput : Select the Calibration output Selection .
mbed_official 610:813dcc80987e 1502 * This parameter can be one of the following values:
mbed_official 610:813dcc80987e 1503 * @arg RTC_CALIBOUTPUT_512HZ: A signal has a regular waveform at 512Hz.
mbed_official 610:813dcc80987e 1504 * @arg RTC_CALIBOUTPUT_1HZ: A signal has a regular waveform at 1Hz.
mbed_official 610:813dcc80987e 1505 * @retval HAL status
mbed_official 610:813dcc80987e 1506 */
mbed_official 610:813dcc80987e 1507 HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef* hrtc, uint32_t CalibOutput)
mbed_official 610:813dcc80987e 1508 {
mbed_official 610:813dcc80987e 1509 /* Check the parameters */
mbed_official 610:813dcc80987e 1510 assert_param(IS_RTC_CALIB_OUTPUT(CalibOutput));
mbed_official 610:813dcc80987e 1511
mbed_official 610:813dcc80987e 1512 /* Process Locked */
mbed_official 610:813dcc80987e 1513 __HAL_LOCK(hrtc);
mbed_official 610:813dcc80987e 1514
mbed_official 610:813dcc80987e 1515 hrtc->State = HAL_RTC_STATE_BUSY;
mbed_official 610:813dcc80987e 1516
mbed_official 610:813dcc80987e 1517 /* Disable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1518 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
mbed_official 610:813dcc80987e 1519
mbed_official 610:813dcc80987e 1520 /* Clear flags before config */
mbed_official 610:813dcc80987e 1521 hrtc->Instance->CR &= (uint32_t)~RTC_CR_COSEL;
mbed_official 610:813dcc80987e 1522
mbed_official 610:813dcc80987e 1523 /* Configure the RTC_CR register */
mbed_official 610:813dcc80987e 1524 hrtc->Instance->CR |= (uint32_t)CalibOutput;
mbed_official 610:813dcc80987e 1525
mbed_official 610:813dcc80987e 1526 __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1527
mbed_official 610:813dcc80987e 1528 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1529 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1530
mbed_official 610:813dcc80987e 1531 /* Change RTC state */
mbed_official 610:813dcc80987e 1532 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 1533
mbed_official 610:813dcc80987e 1534 /* Process Unlocked */
mbed_official 610:813dcc80987e 1535 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1536
mbed_official 610:813dcc80987e 1537 return HAL_OK;
mbed_official 610:813dcc80987e 1538 }
mbed_official 610:813dcc80987e 1539
mbed_official 610:813dcc80987e 1540 /**
mbed_official 610:813dcc80987e 1541 * @brief Deactivate the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz).
mbed_official 610:813dcc80987e 1542 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 1543 * @retval HAL status
mbed_official 610:813dcc80987e 1544 */
mbed_official 610:813dcc80987e 1545 HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef* hrtc)
mbed_official 610:813dcc80987e 1546 {
mbed_official 610:813dcc80987e 1547 /* Process Locked */
mbed_official 610:813dcc80987e 1548 __HAL_LOCK(hrtc);
mbed_official 610:813dcc80987e 1549
mbed_official 610:813dcc80987e 1550 hrtc->State = HAL_RTC_STATE_BUSY;
mbed_official 610:813dcc80987e 1551
mbed_official 610:813dcc80987e 1552 /* Disable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1553 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
mbed_official 610:813dcc80987e 1554
mbed_official 610:813dcc80987e 1555 __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(hrtc);
mbed_official 610:813dcc80987e 1556
mbed_official 610:813dcc80987e 1557 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1558 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1559
mbed_official 610:813dcc80987e 1560 /* Change RTC state */
mbed_official 610:813dcc80987e 1561 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 1562
mbed_official 610:813dcc80987e 1563 /* Process Unlocked */
mbed_official 610:813dcc80987e 1564 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1565
mbed_official 610:813dcc80987e 1566 return HAL_OK;
mbed_official 610:813dcc80987e 1567 }
mbed_official 610:813dcc80987e 1568
mbed_official 610:813dcc80987e 1569 /**
mbed_official 610:813dcc80987e 1570 * @brief Enable the RTC reference clock detection.
mbed_official 610:813dcc80987e 1571 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 1572 * @retval HAL status
mbed_official 610:813dcc80987e 1573 */
mbed_official 610:813dcc80987e 1574 HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef* hrtc)
mbed_official 610:813dcc80987e 1575 {
mbed_official 610:813dcc80987e 1576 /* Process Locked */
mbed_official 610:813dcc80987e 1577 __HAL_LOCK(hrtc);
mbed_official 610:813dcc80987e 1578
mbed_official 610:813dcc80987e 1579 hrtc->State = HAL_RTC_STATE_BUSY;
mbed_official 610:813dcc80987e 1580
mbed_official 610:813dcc80987e 1581 /* Disable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1582 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
mbed_official 610:813dcc80987e 1583
mbed_official 610:813dcc80987e 1584 /* Set Initialization mode */
mbed_official 610:813dcc80987e 1585 if(RTC_EnterInitMode(hrtc) != HAL_OK)
mbed_official 610:813dcc80987e 1586 {
mbed_official 610:813dcc80987e 1587 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1588 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1589
mbed_official 610:813dcc80987e 1590 /* Set RTC state*/
mbed_official 610:813dcc80987e 1591 hrtc->State = HAL_RTC_STATE_ERROR;
mbed_official 610:813dcc80987e 1592
mbed_official 610:813dcc80987e 1593 /* Process Unlocked */
mbed_official 610:813dcc80987e 1594 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1595
mbed_official 610:813dcc80987e 1596 return HAL_ERROR;
mbed_official 610:813dcc80987e 1597 }
mbed_official 610:813dcc80987e 1598 else
mbed_official 610:813dcc80987e 1599 {
mbed_official 610:813dcc80987e 1600 __HAL_RTC_CLOCKREF_DETECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1601
mbed_official 610:813dcc80987e 1602 /* Exit Initialization mode */
mbed_official 610:813dcc80987e 1603 hrtc->Instance->ISR &= (uint32_t)~RTC_ISR_INIT;
mbed_official 610:813dcc80987e 1604 }
mbed_official 610:813dcc80987e 1605
mbed_official 610:813dcc80987e 1606 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1607 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1608
mbed_official 610:813dcc80987e 1609 /* Change RTC state */
mbed_official 610:813dcc80987e 1610 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 1611
mbed_official 610:813dcc80987e 1612 /* Process Unlocked */
mbed_official 610:813dcc80987e 1613 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1614
mbed_official 610:813dcc80987e 1615 return HAL_OK;
mbed_official 610:813dcc80987e 1616 }
mbed_official 610:813dcc80987e 1617
mbed_official 610:813dcc80987e 1618 /**
mbed_official 610:813dcc80987e 1619 * @brief Disable the RTC reference clock detection.
mbed_official 610:813dcc80987e 1620 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 1621 * @retval HAL status
mbed_official 610:813dcc80987e 1622 */
mbed_official 610:813dcc80987e 1623 HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef* hrtc)
mbed_official 610:813dcc80987e 1624 {
mbed_official 610:813dcc80987e 1625 /* Process Locked */
mbed_official 610:813dcc80987e 1626 __HAL_LOCK(hrtc);
mbed_official 610:813dcc80987e 1627
mbed_official 610:813dcc80987e 1628 hrtc->State = HAL_RTC_STATE_BUSY;
mbed_official 610:813dcc80987e 1629
mbed_official 610:813dcc80987e 1630 /* Disable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1631 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
mbed_official 610:813dcc80987e 1632
mbed_official 610:813dcc80987e 1633 /* Set Initialization mode */
mbed_official 610:813dcc80987e 1634 if(RTC_EnterInitMode(hrtc) != HAL_OK)
mbed_official 610:813dcc80987e 1635 {
mbed_official 610:813dcc80987e 1636 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1637 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1638
mbed_official 610:813dcc80987e 1639 /* Set RTC state*/
mbed_official 610:813dcc80987e 1640 hrtc->State = HAL_RTC_STATE_ERROR;
mbed_official 610:813dcc80987e 1641
mbed_official 610:813dcc80987e 1642 /* Process Unlocked */
mbed_official 610:813dcc80987e 1643 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1644
mbed_official 610:813dcc80987e 1645 return HAL_ERROR;
mbed_official 610:813dcc80987e 1646 }
mbed_official 610:813dcc80987e 1647 else
mbed_official 610:813dcc80987e 1648 {
mbed_official 610:813dcc80987e 1649 __HAL_RTC_CLOCKREF_DETECTION_DISABLE(hrtc);
mbed_official 610:813dcc80987e 1650
mbed_official 610:813dcc80987e 1651 /* Exit Initialization mode */
mbed_official 610:813dcc80987e 1652 hrtc->Instance->ISR &= (uint32_t)~RTC_ISR_INIT;
mbed_official 610:813dcc80987e 1653 }
mbed_official 610:813dcc80987e 1654
mbed_official 610:813dcc80987e 1655 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1656 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1657
mbed_official 610:813dcc80987e 1658 /* Change RTC state */
mbed_official 610:813dcc80987e 1659 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 1660
mbed_official 610:813dcc80987e 1661 /* Process Unlocked */
mbed_official 610:813dcc80987e 1662 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1663
mbed_official 610:813dcc80987e 1664 return HAL_OK;
mbed_official 610:813dcc80987e 1665 }
mbed_official 610:813dcc80987e 1666
mbed_official 610:813dcc80987e 1667 /**
mbed_official 610:813dcc80987e 1668 * @brief Enable the Bypass Shadow feature.
mbed_official 610:813dcc80987e 1669 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 1670 * @note When the Bypass Shadow is enabled the calendar value are taken
mbed_official 610:813dcc80987e 1671 * directly from the Calendar counter.
mbed_official 610:813dcc80987e 1672 * @retval HAL status
mbed_official 610:813dcc80987e 1673 */
mbed_official 610:813dcc80987e 1674 HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef* hrtc)
mbed_official 610:813dcc80987e 1675 {
mbed_official 610:813dcc80987e 1676 /* Process Locked */
mbed_official 610:813dcc80987e 1677 __HAL_LOCK(hrtc);
mbed_official 610:813dcc80987e 1678
mbed_official 610:813dcc80987e 1679 hrtc->State = HAL_RTC_STATE_BUSY;
mbed_official 610:813dcc80987e 1680
mbed_official 610:813dcc80987e 1681 /* Disable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1682 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
mbed_official 610:813dcc80987e 1683
mbed_official 610:813dcc80987e 1684 /* Set the BYPSHAD bit */
mbed_official 610:813dcc80987e 1685 hrtc->Instance->CR |= (uint8_t)RTC_CR_BYPSHAD;
mbed_official 610:813dcc80987e 1686
mbed_official 610:813dcc80987e 1687 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1688 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1689
mbed_official 610:813dcc80987e 1690 /* Change RTC state */
mbed_official 610:813dcc80987e 1691 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 1692
mbed_official 610:813dcc80987e 1693 /* Process Unlocked */
mbed_official 610:813dcc80987e 1694 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1695
mbed_official 610:813dcc80987e 1696 return HAL_OK;
mbed_official 610:813dcc80987e 1697 }
mbed_official 610:813dcc80987e 1698
mbed_official 610:813dcc80987e 1699 /**
mbed_official 610:813dcc80987e 1700 * @brief Disable the Bypass Shadow feature.
mbed_official 610:813dcc80987e 1701 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 1702 * @note When the Bypass Shadow is enabled the calendar value are taken
mbed_official 610:813dcc80987e 1703 * directly from the Calendar counter.
mbed_official 610:813dcc80987e 1704 * @retval HAL status
mbed_official 610:813dcc80987e 1705 */
mbed_official 610:813dcc80987e 1706 HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef* hrtc)
mbed_official 610:813dcc80987e 1707 {
mbed_official 610:813dcc80987e 1708 /* Process Locked */
mbed_official 610:813dcc80987e 1709 __HAL_LOCK(hrtc);
mbed_official 610:813dcc80987e 1710
mbed_official 610:813dcc80987e 1711 hrtc->State = HAL_RTC_STATE_BUSY;
mbed_official 610:813dcc80987e 1712
mbed_official 610:813dcc80987e 1713 /* Disable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1714 __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
mbed_official 610:813dcc80987e 1715
mbed_official 610:813dcc80987e 1716 /* Reset the BYPSHAD bit */
mbed_official 610:813dcc80987e 1717 hrtc->Instance->CR &= ((uint8_t)~RTC_CR_BYPSHAD);
mbed_official 610:813dcc80987e 1718
mbed_official 610:813dcc80987e 1719 /* Enable the write protection for RTC registers */
mbed_official 610:813dcc80987e 1720 __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
mbed_official 610:813dcc80987e 1721
mbed_official 610:813dcc80987e 1722 /* Change RTC state */
mbed_official 610:813dcc80987e 1723 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 1724
mbed_official 610:813dcc80987e 1725 /* Process Unlocked */
mbed_official 610:813dcc80987e 1726 __HAL_UNLOCK(hrtc);
mbed_official 610:813dcc80987e 1727
mbed_official 610:813dcc80987e 1728 return HAL_OK;
mbed_official 610:813dcc80987e 1729 }
mbed_official 610:813dcc80987e 1730
mbed_official 610:813dcc80987e 1731 /**
mbed_official 610:813dcc80987e 1732 * @}
mbed_official 610:813dcc80987e 1733 */
mbed_official 610:813dcc80987e 1734
mbed_official 610:813dcc80987e 1735 /** @defgroup RTCEx_Exported_Functions_Group4 Extended features functions
mbed_official 610:813dcc80987e 1736 * @brief Extended features functions
mbed_official 610:813dcc80987e 1737 *
mbed_official 610:813dcc80987e 1738 @verbatim
mbed_official 610:813dcc80987e 1739 ===============================================================================
mbed_official 610:813dcc80987e 1740 ##### Extended features functions #####
mbed_official 610:813dcc80987e 1741 ===============================================================================
mbed_official 610:813dcc80987e 1742 [..] This section provides functions allowing to:
mbed_official 610:813dcc80987e 1743 (+) RTC Alarm B callback
mbed_official 610:813dcc80987e 1744 (+) RTC Poll for Alarm B request
mbed_official 610:813dcc80987e 1745
mbed_official 610:813dcc80987e 1746 @endverbatim
mbed_official 610:813dcc80987e 1747 * @{
mbed_official 610:813dcc80987e 1748 */
mbed_official 610:813dcc80987e 1749
mbed_official 610:813dcc80987e 1750 /**
mbed_official 610:813dcc80987e 1751 * @brief Alarm B callback.
mbed_official 610:813dcc80987e 1752 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 1753 * @retval None
mbed_official 610:813dcc80987e 1754 */
mbed_official 610:813dcc80987e 1755 __weak void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc)
mbed_official 610:813dcc80987e 1756 {
mbed_official 610:813dcc80987e 1757 /* NOTE : This function should not be modified, when the callback is needed,
mbed_official 610:813dcc80987e 1758 the HAL_RTCEx_AlarmBEventCallback could be implemented in the user file
mbed_official 610:813dcc80987e 1759 */
mbed_official 610:813dcc80987e 1760 }
mbed_official 610:813dcc80987e 1761
mbed_official 610:813dcc80987e 1762 /**
mbed_official 610:813dcc80987e 1763 * @brief Handle Alarm B Polling request.
mbed_official 610:813dcc80987e 1764 * @param hrtc: RTC handle
mbed_official 610:813dcc80987e 1765 * @param Timeout: Timeout duration
mbed_official 610:813dcc80987e 1766 * @retval HAL status
mbed_official 610:813dcc80987e 1767 */
mbed_official 610:813dcc80987e 1768 HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
mbed_official 610:813dcc80987e 1769 {
mbed_official 610:813dcc80987e 1770 uint32_t tickstart = HAL_GetTick();
mbed_official 610:813dcc80987e 1771
mbed_official 610:813dcc80987e 1772 while(__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRBF) == RESET)
mbed_official 610:813dcc80987e 1773 {
mbed_official 610:813dcc80987e 1774 if(Timeout != HAL_MAX_DELAY)
mbed_official 610:813dcc80987e 1775 {
mbed_official 610:813dcc80987e 1776 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
mbed_official 610:813dcc80987e 1777 {
mbed_official 610:813dcc80987e 1778 hrtc->State = HAL_RTC_STATE_TIMEOUT;
mbed_official 610:813dcc80987e 1779 return HAL_TIMEOUT;
mbed_official 610:813dcc80987e 1780 }
mbed_official 610:813dcc80987e 1781 }
mbed_official 610:813dcc80987e 1782 }
mbed_official 610:813dcc80987e 1783
mbed_official 610:813dcc80987e 1784 /* Clear the Alarm Flag */
mbed_official 610:813dcc80987e 1785 __HAL_RTC_ALARM_CLEAR_FLAG(hrtc, RTC_FLAG_ALRBF);
mbed_official 610:813dcc80987e 1786
mbed_official 610:813dcc80987e 1787 /* Change RTC state */
mbed_official 610:813dcc80987e 1788 hrtc->State = HAL_RTC_STATE_READY;
mbed_official 610:813dcc80987e 1789
mbed_official 610:813dcc80987e 1790 return HAL_OK;
mbed_official 610:813dcc80987e 1791 }
mbed_official 610:813dcc80987e 1792
mbed_official 610:813dcc80987e 1793 /**
mbed_official 610:813dcc80987e 1794 * @}
mbed_official 610:813dcc80987e 1795 */
mbed_official 610:813dcc80987e 1796
mbed_official 610:813dcc80987e 1797 /**
mbed_official 610:813dcc80987e 1798 * @}
mbed_official 610:813dcc80987e 1799 */
mbed_official 610:813dcc80987e 1800
mbed_official 610:813dcc80987e 1801 #endif /* HAL_RTC_MODULE_ENABLED */
mbed_official 610:813dcc80987e 1802 /**
mbed_official 610:813dcc80987e 1803 * @}
mbed_official 610:813dcc80987e 1804 */
mbed_official 610:813dcc80987e 1805
mbed_official 610:813dcc80987e 1806 /**
mbed_official 610:813dcc80987e 1807 * @}
mbed_official 610:813dcc80987e 1808 */
mbed_official 610:813dcc80987e 1809
mbed_official 610:813dcc80987e 1810 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/