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