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