mbed library sources modified for open wear
Dependents: openwear-lifelogger-example
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_DISCO_F100RB/stm32f10x_rtc.c@310:6188e0254baa, 2014-09-16 (annotated)
- Committer:
- janekm
- Date:
- Tue Sep 16 22:42:01 2014 +0000
- Revision:
- 310:6188e0254baa
- Parent:
- 126:549ba18ddd81
N/A
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 126:549ba18ddd81 | 1 | /** |
mbed_official | 126:549ba18ddd81 | 2 | ****************************************************************************** |
mbed_official | 126:549ba18ddd81 | 3 | * @file stm32f10x_rtc.c |
mbed_official | 126:549ba18ddd81 | 4 | * @author MCD Application Team |
mbed_official | 126:549ba18ddd81 | 5 | * @version V3.6.1 |
mbed_official | 126:549ba18ddd81 | 6 | * @date 05-March-2012 |
mbed_official | 126:549ba18ddd81 | 7 | * @brief This file provides all the RTC firmware functions. |
mbed_official | 126:549ba18ddd81 | 8 | ******************************************************************************* |
mbed_official | 126:549ba18ddd81 | 9 | * Copyright (c) 2014, STMicroelectronics |
mbed_official | 126:549ba18ddd81 | 10 | * All rights reserved. |
mbed_official | 126:549ba18ddd81 | 11 | * |
mbed_official | 126:549ba18ddd81 | 12 | * Redistribution and use in source and binary forms, with or without |
mbed_official | 126:549ba18ddd81 | 13 | * modification, are permitted provided that the following conditions are met: |
mbed_official | 126:549ba18ddd81 | 14 | * |
mbed_official | 126:549ba18ddd81 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 126:549ba18ddd81 | 16 | * this list of conditions and the following disclaimer. |
mbed_official | 126:549ba18ddd81 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 126:549ba18ddd81 | 18 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 126:549ba18ddd81 | 19 | * and/or other materials provided with the distribution. |
mbed_official | 126:549ba18ddd81 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 126:549ba18ddd81 | 21 | * may be used to endorse or promote products derived from this software |
mbed_official | 126:549ba18ddd81 | 22 | * without specific prior written permission. |
mbed_official | 126:549ba18ddd81 | 23 | * |
mbed_official | 126:549ba18ddd81 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 126:549ba18ddd81 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 126:549ba18ddd81 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 126:549ba18ddd81 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 126:549ba18ddd81 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 126:549ba18ddd81 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 126:549ba18ddd81 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 126:549ba18ddd81 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 126:549ba18ddd81 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 126:549ba18ddd81 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 126:549ba18ddd81 | 34 | ******************************************************************************* |
mbed_official | 126:549ba18ddd81 | 35 | */ |
mbed_official | 126:549ba18ddd81 | 36 | |
mbed_official | 126:549ba18ddd81 | 37 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 126:549ba18ddd81 | 38 | #include "stm32f10x_rtc.h" |
mbed_official | 126:549ba18ddd81 | 39 | |
mbed_official | 126:549ba18ddd81 | 40 | /** @addtogroup STM32F10x_StdPeriph_Driver |
mbed_official | 126:549ba18ddd81 | 41 | * @{ |
mbed_official | 126:549ba18ddd81 | 42 | */ |
mbed_official | 126:549ba18ddd81 | 43 | |
mbed_official | 126:549ba18ddd81 | 44 | /** @defgroup RTC |
mbed_official | 126:549ba18ddd81 | 45 | * @brief RTC driver modules |
mbed_official | 126:549ba18ddd81 | 46 | * @{ |
mbed_official | 126:549ba18ddd81 | 47 | */ |
mbed_official | 126:549ba18ddd81 | 48 | |
mbed_official | 126:549ba18ddd81 | 49 | /** @defgroup RTC_Private_TypesDefinitions |
mbed_official | 126:549ba18ddd81 | 50 | * @{ |
mbed_official | 126:549ba18ddd81 | 51 | */ |
mbed_official | 126:549ba18ddd81 | 52 | /** |
mbed_official | 126:549ba18ddd81 | 53 | * @} |
mbed_official | 126:549ba18ddd81 | 54 | */ |
mbed_official | 126:549ba18ddd81 | 55 | |
mbed_official | 126:549ba18ddd81 | 56 | /** @defgroup RTC_Private_Defines |
mbed_official | 126:549ba18ddd81 | 57 | * @{ |
mbed_official | 126:549ba18ddd81 | 58 | */ |
mbed_official | 126:549ba18ddd81 | 59 | #define RTC_LSB_MASK ((uint32_t)0x0000FFFF) /*!< RTC LSB Mask */ |
mbed_official | 126:549ba18ddd81 | 60 | #define PRLH_MSB_MASK ((uint32_t)0x000F0000) /*!< RTC Prescaler MSB Mask */ |
mbed_official | 126:549ba18ddd81 | 61 | |
mbed_official | 126:549ba18ddd81 | 62 | /** |
mbed_official | 126:549ba18ddd81 | 63 | * @} |
mbed_official | 126:549ba18ddd81 | 64 | */ |
mbed_official | 126:549ba18ddd81 | 65 | |
mbed_official | 126:549ba18ddd81 | 66 | /** @defgroup RTC_Private_Macros |
mbed_official | 126:549ba18ddd81 | 67 | * @{ |
mbed_official | 126:549ba18ddd81 | 68 | */ |
mbed_official | 126:549ba18ddd81 | 69 | |
mbed_official | 126:549ba18ddd81 | 70 | /** |
mbed_official | 126:549ba18ddd81 | 71 | * @} |
mbed_official | 126:549ba18ddd81 | 72 | */ |
mbed_official | 126:549ba18ddd81 | 73 | |
mbed_official | 126:549ba18ddd81 | 74 | /** @defgroup RTC_Private_Variables |
mbed_official | 126:549ba18ddd81 | 75 | * @{ |
mbed_official | 126:549ba18ddd81 | 76 | */ |
mbed_official | 126:549ba18ddd81 | 77 | |
mbed_official | 126:549ba18ddd81 | 78 | /** |
mbed_official | 126:549ba18ddd81 | 79 | * @} |
mbed_official | 126:549ba18ddd81 | 80 | */ |
mbed_official | 126:549ba18ddd81 | 81 | |
mbed_official | 126:549ba18ddd81 | 82 | /** @defgroup RTC_Private_FunctionPrototypes |
mbed_official | 126:549ba18ddd81 | 83 | * @{ |
mbed_official | 126:549ba18ddd81 | 84 | */ |
mbed_official | 126:549ba18ddd81 | 85 | |
mbed_official | 126:549ba18ddd81 | 86 | /** |
mbed_official | 126:549ba18ddd81 | 87 | * @} |
mbed_official | 126:549ba18ddd81 | 88 | */ |
mbed_official | 126:549ba18ddd81 | 89 | |
mbed_official | 126:549ba18ddd81 | 90 | /** @defgroup RTC_Private_Functions |
mbed_official | 126:549ba18ddd81 | 91 | * @{ |
mbed_official | 126:549ba18ddd81 | 92 | */ |
mbed_official | 126:549ba18ddd81 | 93 | |
mbed_official | 126:549ba18ddd81 | 94 | /** |
mbed_official | 126:549ba18ddd81 | 95 | * @brief Enables or disables the specified RTC interrupts. |
mbed_official | 126:549ba18ddd81 | 96 | * @param RTC_IT: specifies the RTC interrupts sources to be enabled or disabled. |
mbed_official | 126:549ba18ddd81 | 97 | * This parameter can be any combination of the following values: |
mbed_official | 126:549ba18ddd81 | 98 | * @arg RTC_IT_OW: Overflow interrupt |
mbed_official | 126:549ba18ddd81 | 99 | * @arg RTC_IT_ALR: Alarm interrupt |
mbed_official | 126:549ba18ddd81 | 100 | * @arg RTC_IT_SEC: Second interrupt |
mbed_official | 126:549ba18ddd81 | 101 | * @param NewState: new state of the specified RTC interrupts. |
mbed_official | 126:549ba18ddd81 | 102 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 126:549ba18ddd81 | 103 | * @retval None |
mbed_official | 126:549ba18ddd81 | 104 | */ |
mbed_official | 126:549ba18ddd81 | 105 | void RTC_ITConfig(uint16_t RTC_IT, FunctionalState NewState) |
mbed_official | 126:549ba18ddd81 | 106 | { |
mbed_official | 126:549ba18ddd81 | 107 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 108 | assert_param(IS_RTC_IT(RTC_IT)); |
mbed_official | 126:549ba18ddd81 | 109 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 126:549ba18ddd81 | 110 | |
mbed_official | 126:549ba18ddd81 | 111 | if (NewState != DISABLE) |
mbed_official | 126:549ba18ddd81 | 112 | { |
mbed_official | 126:549ba18ddd81 | 113 | RTC->CRH |= RTC_IT; |
mbed_official | 126:549ba18ddd81 | 114 | } |
mbed_official | 126:549ba18ddd81 | 115 | else |
mbed_official | 126:549ba18ddd81 | 116 | { |
mbed_official | 126:549ba18ddd81 | 117 | RTC->CRH &= (uint16_t)~RTC_IT; |
mbed_official | 126:549ba18ddd81 | 118 | } |
mbed_official | 126:549ba18ddd81 | 119 | } |
mbed_official | 126:549ba18ddd81 | 120 | |
mbed_official | 126:549ba18ddd81 | 121 | /** |
mbed_official | 126:549ba18ddd81 | 122 | * @brief Enters the RTC configuration mode. |
mbed_official | 126:549ba18ddd81 | 123 | * @param None |
mbed_official | 126:549ba18ddd81 | 124 | * @retval None |
mbed_official | 126:549ba18ddd81 | 125 | */ |
mbed_official | 126:549ba18ddd81 | 126 | void RTC_EnterConfigMode(void) |
mbed_official | 126:549ba18ddd81 | 127 | { |
mbed_official | 126:549ba18ddd81 | 128 | /* Set the CNF flag to enter in the Configuration Mode */ |
mbed_official | 126:549ba18ddd81 | 129 | RTC->CRL |= RTC_CRL_CNF; |
mbed_official | 126:549ba18ddd81 | 130 | } |
mbed_official | 126:549ba18ddd81 | 131 | |
mbed_official | 126:549ba18ddd81 | 132 | /** |
mbed_official | 126:549ba18ddd81 | 133 | * @brief Exits from the RTC configuration mode. |
mbed_official | 126:549ba18ddd81 | 134 | * @param None |
mbed_official | 126:549ba18ddd81 | 135 | * @retval None |
mbed_official | 126:549ba18ddd81 | 136 | */ |
mbed_official | 126:549ba18ddd81 | 137 | void RTC_ExitConfigMode(void) |
mbed_official | 126:549ba18ddd81 | 138 | { |
mbed_official | 126:549ba18ddd81 | 139 | /* Reset the CNF flag to exit from the Configuration Mode */ |
mbed_official | 126:549ba18ddd81 | 140 | RTC->CRL &= (uint16_t)~((uint16_t)RTC_CRL_CNF); |
mbed_official | 126:549ba18ddd81 | 141 | } |
mbed_official | 126:549ba18ddd81 | 142 | |
mbed_official | 126:549ba18ddd81 | 143 | /** |
mbed_official | 126:549ba18ddd81 | 144 | * @brief Gets the RTC counter value. |
mbed_official | 126:549ba18ddd81 | 145 | * @param None |
mbed_official | 126:549ba18ddd81 | 146 | * @retval RTC counter value. |
mbed_official | 126:549ba18ddd81 | 147 | */ |
mbed_official | 126:549ba18ddd81 | 148 | uint32_t RTC_GetCounter(void) |
mbed_official | 126:549ba18ddd81 | 149 | { |
mbed_official | 126:549ba18ddd81 | 150 | uint16_t high1 = 0, high2 = 0, low = 0; |
mbed_official | 126:549ba18ddd81 | 151 | |
mbed_official | 126:549ba18ddd81 | 152 | high1 = RTC->CNTH; |
mbed_official | 126:549ba18ddd81 | 153 | low = RTC->CNTL; |
mbed_official | 126:549ba18ddd81 | 154 | high2 = RTC->CNTH; |
mbed_official | 126:549ba18ddd81 | 155 | |
mbed_official | 126:549ba18ddd81 | 156 | if (high1 != high2) |
mbed_official | 126:549ba18ddd81 | 157 | { /* In this case the counter roll over during reading of CNTL and CNTH registers, |
mbed_official | 126:549ba18ddd81 | 158 | read again CNTL register then return the counter value */ |
mbed_official | 126:549ba18ddd81 | 159 | return (((uint32_t) high2 << 16 ) | RTC->CNTL); |
mbed_official | 126:549ba18ddd81 | 160 | } |
mbed_official | 126:549ba18ddd81 | 161 | else |
mbed_official | 126:549ba18ddd81 | 162 | { /* No counter roll over during reading of CNTL and CNTH registers, counter |
mbed_official | 126:549ba18ddd81 | 163 | value is equal to first value of CNTL and CNTH */ |
mbed_official | 126:549ba18ddd81 | 164 | return (((uint32_t) high1 << 16 ) | low); |
mbed_official | 126:549ba18ddd81 | 165 | } |
mbed_official | 126:549ba18ddd81 | 166 | } |
mbed_official | 126:549ba18ddd81 | 167 | |
mbed_official | 126:549ba18ddd81 | 168 | /** |
mbed_official | 126:549ba18ddd81 | 169 | * @brief Sets the RTC counter value. |
mbed_official | 126:549ba18ddd81 | 170 | * @param CounterValue: RTC counter new value. |
mbed_official | 126:549ba18ddd81 | 171 | * @retval None |
mbed_official | 126:549ba18ddd81 | 172 | */ |
mbed_official | 126:549ba18ddd81 | 173 | void RTC_SetCounter(uint32_t CounterValue) |
mbed_official | 126:549ba18ddd81 | 174 | { |
mbed_official | 126:549ba18ddd81 | 175 | RTC_EnterConfigMode(); |
mbed_official | 126:549ba18ddd81 | 176 | /* Set RTC COUNTER MSB word */ |
mbed_official | 126:549ba18ddd81 | 177 | RTC->CNTH = CounterValue >> 16; |
mbed_official | 126:549ba18ddd81 | 178 | /* Set RTC COUNTER LSB word */ |
mbed_official | 126:549ba18ddd81 | 179 | RTC->CNTL = (CounterValue & RTC_LSB_MASK); |
mbed_official | 126:549ba18ddd81 | 180 | RTC_ExitConfigMode(); |
mbed_official | 126:549ba18ddd81 | 181 | } |
mbed_official | 126:549ba18ddd81 | 182 | |
mbed_official | 126:549ba18ddd81 | 183 | /** |
mbed_official | 126:549ba18ddd81 | 184 | * @brief Sets the RTC prescaler value. |
mbed_official | 126:549ba18ddd81 | 185 | * @param PrescalerValue: RTC prescaler new value. |
mbed_official | 126:549ba18ddd81 | 186 | * @retval None |
mbed_official | 126:549ba18ddd81 | 187 | */ |
mbed_official | 126:549ba18ddd81 | 188 | void RTC_SetPrescaler(uint32_t PrescalerValue) |
mbed_official | 126:549ba18ddd81 | 189 | { |
mbed_official | 126:549ba18ddd81 | 190 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 191 | assert_param(IS_RTC_PRESCALER(PrescalerValue)); |
mbed_official | 126:549ba18ddd81 | 192 | |
mbed_official | 126:549ba18ddd81 | 193 | RTC_EnterConfigMode(); |
mbed_official | 126:549ba18ddd81 | 194 | /* Set RTC PRESCALER MSB word */ |
mbed_official | 126:549ba18ddd81 | 195 | RTC->PRLH = (PrescalerValue & PRLH_MSB_MASK) >> 16; |
mbed_official | 126:549ba18ddd81 | 196 | /* Set RTC PRESCALER LSB word */ |
mbed_official | 126:549ba18ddd81 | 197 | RTC->PRLL = (PrescalerValue & RTC_LSB_MASK); |
mbed_official | 126:549ba18ddd81 | 198 | RTC_ExitConfigMode(); |
mbed_official | 126:549ba18ddd81 | 199 | } |
mbed_official | 126:549ba18ddd81 | 200 | |
mbed_official | 126:549ba18ddd81 | 201 | /** |
mbed_official | 126:549ba18ddd81 | 202 | * @brief Sets the RTC alarm value. |
mbed_official | 126:549ba18ddd81 | 203 | * @param AlarmValue: RTC alarm new value. |
mbed_official | 126:549ba18ddd81 | 204 | * @retval None |
mbed_official | 126:549ba18ddd81 | 205 | */ |
mbed_official | 126:549ba18ddd81 | 206 | void RTC_SetAlarm(uint32_t AlarmValue) |
mbed_official | 126:549ba18ddd81 | 207 | { |
mbed_official | 126:549ba18ddd81 | 208 | RTC_EnterConfigMode(); |
mbed_official | 126:549ba18ddd81 | 209 | /* Set the ALARM MSB word */ |
mbed_official | 126:549ba18ddd81 | 210 | RTC->ALRH = AlarmValue >> 16; |
mbed_official | 126:549ba18ddd81 | 211 | /* Set the ALARM LSB word */ |
mbed_official | 126:549ba18ddd81 | 212 | RTC->ALRL = (AlarmValue & RTC_LSB_MASK); |
mbed_official | 126:549ba18ddd81 | 213 | RTC_ExitConfigMode(); |
mbed_official | 126:549ba18ddd81 | 214 | } |
mbed_official | 126:549ba18ddd81 | 215 | |
mbed_official | 126:549ba18ddd81 | 216 | /** |
mbed_official | 126:549ba18ddd81 | 217 | * @brief Gets the RTC divider value. |
mbed_official | 126:549ba18ddd81 | 218 | * @param None |
mbed_official | 126:549ba18ddd81 | 219 | * @retval RTC Divider value. |
mbed_official | 126:549ba18ddd81 | 220 | */ |
mbed_official | 126:549ba18ddd81 | 221 | uint32_t RTC_GetDivider(void) |
mbed_official | 126:549ba18ddd81 | 222 | { |
mbed_official | 126:549ba18ddd81 | 223 | uint32_t tmp = 0x00; |
mbed_official | 126:549ba18ddd81 | 224 | tmp = ((uint32_t)RTC->DIVH & (uint32_t)0x000F) << 16; |
mbed_official | 126:549ba18ddd81 | 225 | tmp |= RTC->DIVL; |
mbed_official | 126:549ba18ddd81 | 226 | return tmp; |
mbed_official | 126:549ba18ddd81 | 227 | } |
mbed_official | 126:549ba18ddd81 | 228 | |
mbed_official | 126:549ba18ddd81 | 229 | /** |
mbed_official | 126:549ba18ddd81 | 230 | * @brief Waits until last write operation on RTC registers has finished. |
mbed_official | 126:549ba18ddd81 | 231 | * @note This function must be called before any write to RTC registers. |
mbed_official | 126:549ba18ddd81 | 232 | * @param None |
mbed_official | 126:549ba18ddd81 | 233 | * @retval None |
mbed_official | 126:549ba18ddd81 | 234 | */ |
mbed_official | 126:549ba18ddd81 | 235 | void RTC_WaitForLastTask(void) |
mbed_official | 126:549ba18ddd81 | 236 | { |
mbed_official | 126:549ba18ddd81 | 237 | /* Loop until RTOFF flag is set */ |
mbed_official | 126:549ba18ddd81 | 238 | while ((RTC->CRL & RTC_FLAG_RTOFF) == (uint16_t)RESET) |
mbed_official | 126:549ba18ddd81 | 239 | { |
mbed_official | 126:549ba18ddd81 | 240 | } |
mbed_official | 126:549ba18ddd81 | 241 | } |
mbed_official | 126:549ba18ddd81 | 242 | |
mbed_official | 126:549ba18ddd81 | 243 | /** |
mbed_official | 126:549ba18ddd81 | 244 | * @brief Waits until the RTC registers (RTC_CNT, RTC_ALR and RTC_PRL) |
mbed_official | 126:549ba18ddd81 | 245 | * are synchronized with RTC APB clock. |
mbed_official | 126:549ba18ddd81 | 246 | * @note This function must be called before any read operation after an APB reset |
mbed_official | 126:549ba18ddd81 | 247 | * or an APB clock stop. |
mbed_official | 126:549ba18ddd81 | 248 | * @param None |
mbed_official | 126:549ba18ddd81 | 249 | * @retval None |
mbed_official | 126:549ba18ddd81 | 250 | */ |
mbed_official | 126:549ba18ddd81 | 251 | void RTC_WaitForSynchro(void) |
mbed_official | 126:549ba18ddd81 | 252 | { |
mbed_official | 126:549ba18ddd81 | 253 | /* Clear RSF flag */ |
mbed_official | 126:549ba18ddd81 | 254 | RTC->CRL &= (uint16_t)~RTC_FLAG_RSF; |
mbed_official | 126:549ba18ddd81 | 255 | /* Loop until RSF flag is set */ |
mbed_official | 126:549ba18ddd81 | 256 | while ((RTC->CRL & RTC_FLAG_RSF) == (uint16_t)RESET) |
mbed_official | 126:549ba18ddd81 | 257 | { |
mbed_official | 126:549ba18ddd81 | 258 | } |
mbed_official | 126:549ba18ddd81 | 259 | } |
mbed_official | 126:549ba18ddd81 | 260 | |
mbed_official | 126:549ba18ddd81 | 261 | /** |
mbed_official | 126:549ba18ddd81 | 262 | * @brief Checks whether the specified RTC flag is set or not. |
mbed_official | 126:549ba18ddd81 | 263 | * @param RTC_FLAG: specifies the flag to check. |
mbed_official | 126:549ba18ddd81 | 264 | * This parameter can be one the following values: |
mbed_official | 126:549ba18ddd81 | 265 | * @arg RTC_FLAG_RTOFF: RTC Operation OFF flag |
mbed_official | 126:549ba18ddd81 | 266 | * @arg RTC_FLAG_RSF: Registers Synchronized flag |
mbed_official | 126:549ba18ddd81 | 267 | * @arg RTC_FLAG_OW: Overflow flag |
mbed_official | 126:549ba18ddd81 | 268 | * @arg RTC_FLAG_ALR: Alarm flag |
mbed_official | 126:549ba18ddd81 | 269 | * @arg RTC_FLAG_SEC: Second flag |
mbed_official | 126:549ba18ddd81 | 270 | * @retval The new state of RTC_FLAG (SET or RESET). |
mbed_official | 126:549ba18ddd81 | 271 | */ |
mbed_official | 126:549ba18ddd81 | 272 | FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG) |
mbed_official | 126:549ba18ddd81 | 273 | { |
mbed_official | 126:549ba18ddd81 | 274 | FlagStatus bitstatus = RESET; |
mbed_official | 126:549ba18ddd81 | 275 | |
mbed_official | 126:549ba18ddd81 | 276 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 277 | assert_param(IS_RTC_GET_FLAG(RTC_FLAG)); |
mbed_official | 126:549ba18ddd81 | 278 | |
mbed_official | 126:549ba18ddd81 | 279 | if ((RTC->CRL & RTC_FLAG) != (uint16_t)RESET) |
mbed_official | 126:549ba18ddd81 | 280 | { |
mbed_official | 126:549ba18ddd81 | 281 | bitstatus = SET; |
mbed_official | 126:549ba18ddd81 | 282 | } |
mbed_official | 126:549ba18ddd81 | 283 | else |
mbed_official | 126:549ba18ddd81 | 284 | { |
mbed_official | 126:549ba18ddd81 | 285 | bitstatus = RESET; |
mbed_official | 126:549ba18ddd81 | 286 | } |
mbed_official | 126:549ba18ddd81 | 287 | return bitstatus; |
mbed_official | 126:549ba18ddd81 | 288 | } |
mbed_official | 126:549ba18ddd81 | 289 | |
mbed_official | 126:549ba18ddd81 | 290 | /** |
mbed_official | 126:549ba18ddd81 | 291 | * @brief Clears the RTC's pending flags. |
mbed_official | 126:549ba18ddd81 | 292 | * @param RTC_FLAG: specifies the flag to clear. |
mbed_official | 126:549ba18ddd81 | 293 | * This parameter can be any combination of the following values: |
mbed_official | 126:549ba18ddd81 | 294 | * @arg RTC_FLAG_RSF: Registers Synchronized flag. This flag is cleared only after |
mbed_official | 126:549ba18ddd81 | 295 | * an APB reset or an APB Clock stop. |
mbed_official | 126:549ba18ddd81 | 296 | * @arg RTC_FLAG_OW: Overflow flag |
mbed_official | 126:549ba18ddd81 | 297 | * @arg RTC_FLAG_ALR: Alarm flag |
mbed_official | 126:549ba18ddd81 | 298 | * @arg RTC_FLAG_SEC: Second flag |
mbed_official | 126:549ba18ddd81 | 299 | * @retval None |
mbed_official | 126:549ba18ddd81 | 300 | */ |
mbed_official | 126:549ba18ddd81 | 301 | void RTC_ClearFlag(uint16_t RTC_FLAG) |
mbed_official | 126:549ba18ddd81 | 302 | { |
mbed_official | 126:549ba18ddd81 | 303 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 304 | assert_param(IS_RTC_CLEAR_FLAG(RTC_FLAG)); |
mbed_official | 126:549ba18ddd81 | 305 | |
mbed_official | 126:549ba18ddd81 | 306 | /* Clear the corresponding RTC flag */ |
mbed_official | 126:549ba18ddd81 | 307 | RTC->CRL &= (uint16_t)~RTC_FLAG; |
mbed_official | 126:549ba18ddd81 | 308 | } |
mbed_official | 126:549ba18ddd81 | 309 | |
mbed_official | 126:549ba18ddd81 | 310 | /** |
mbed_official | 126:549ba18ddd81 | 311 | * @brief Checks whether the specified RTC interrupt has occurred or not. |
mbed_official | 126:549ba18ddd81 | 312 | * @param RTC_IT: specifies the RTC interrupts sources to check. |
mbed_official | 126:549ba18ddd81 | 313 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 314 | * @arg RTC_IT_OW: Overflow interrupt |
mbed_official | 126:549ba18ddd81 | 315 | * @arg RTC_IT_ALR: Alarm interrupt |
mbed_official | 126:549ba18ddd81 | 316 | * @arg RTC_IT_SEC: Second interrupt |
mbed_official | 126:549ba18ddd81 | 317 | * @retval The new state of the RTC_IT (SET or RESET). |
mbed_official | 126:549ba18ddd81 | 318 | */ |
mbed_official | 126:549ba18ddd81 | 319 | ITStatus RTC_GetITStatus(uint16_t RTC_IT) |
mbed_official | 126:549ba18ddd81 | 320 | { |
mbed_official | 126:549ba18ddd81 | 321 | ITStatus bitstatus = RESET; |
mbed_official | 126:549ba18ddd81 | 322 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 323 | assert_param(IS_RTC_GET_IT(RTC_IT)); |
mbed_official | 126:549ba18ddd81 | 324 | |
mbed_official | 126:549ba18ddd81 | 325 | bitstatus = (ITStatus)(RTC->CRL & RTC_IT); |
mbed_official | 126:549ba18ddd81 | 326 | if (((RTC->CRH & RTC_IT) != (uint16_t)RESET) && (bitstatus != (uint16_t)RESET)) |
mbed_official | 126:549ba18ddd81 | 327 | { |
mbed_official | 126:549ba18ddd81 | 328 | bitstatus = SET; |
mbed_official | 126:549ba18ddd81 | 329 | } |
mbed_official | 126:549ba18ddd81 | 330 | else |
mbed_official | 126:549ba18ddd81 | 331 | { |
mbed_official | 126:549ba18ddd81 | 332 | bitstatus = RESET; |
mbed_official | 126:549ba18ddd81 | 333 | } |
mbed_official | 126:549ba18ddd81 | 334 | return bitstatus; |
mbed_official | 126:549ba18ddd81 | 335 | } |
mbed_official | 126:549ba18ddd81 | 336 | |
mbed_official | 126:549ba18ddd81 | 337 | /** |
mbed_official | 126:549ba18ddd81 | 338 | * @brief Clears the RTC's interrupt pending bits. |
mbed_official | 126:549ba18ddd81 | 339 | * @param RTC_IT: specifies the interrupt pending bit to clear. |
mbed_official | 126:549ba18ddd81 | 340 | * This parameter can be any combination of the following values: |
mbed_official | 126:549ba18ddd81 | 341 | * @arg RTC_IT_OW: Overflow interrupt |
mbed_official | 126:549ba18ddd81 | 342 | * @arg RTC_IT_ALR: Alarm interrupt |
mbed_official | 126:549ba18ddd81 | 343 | * @arg RTC_IT_SEC: Second interrupt |
mbed_official | 126:549ba18ddd81 | 344 | * @retval None |
mbed_official | 126:549ba18ddd81 | 345 | */ |
mbed_official | 126:549ba18ddd81 | 346 | void RTC_ClearITPendingBit(uint16_t RTC_IT) |
mbed_official | 126:549ba18ddd81 | 347 | { |
mbed_official | 126:549ba18ddd81 | 348 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 349 | assert_param(IS_RTC_IT(RTC_IT)); |
mbed_official | 126:549ba18ddd81 | 350 | |
mbed_official | 126:549ba18ddd81 | 351 | /* Clear the corresponding RTC pending bit */ |
mbed_official | 126:549ba18ddd81 | 352 | RTC->CRL &= (uint16_t)~RTC_IT; |
mbed_official | 126:549ba18ddd81 | 353 | } |
mbed_official | 126:549ba18ddd81 | 354 | |
mbed_official | 126:549ba18ddd81 | 355 | /** |
mbed_official | 126:549ba18ddd81 | 356 | * @} |
mbed_official | 126:549ba18ddd81 | 357 | */ |
mbed_official | 126:549ba18ddd81 | 358 | |
mbed_official | 126:549ba18ddd81 | 359 | /** |
mbed_official | 126:549ba18ddd81 | 360 | * @} |
mbed_official | 126:549ba18ddd81 | 361 | */ |
mbed_official | 126:549ba18ddd81 | 362 | |
mbed_official | 126:549ba18ddd81 | 363 | /** |
mbed_official | 126:549ba18ddd81 | 364 | * @} |
mbed_official | 126:549ba18ddd81 | 365 | */ |
mbed_official | 126:549ba18ddd81 | 366 | |
mbed_official | 126:549ba18ddd81 | 367 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |