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