mbed SDK library sources
Fork of mbed-src by
Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.
If you are looking for a stable and tested release, please import one of the official mbed library releases:
Import librarymbed
The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F103RB/stm32f10x_rtc.c@84:f54042cbc282, 2014-02-03 (annotated)
- Committer:
- mbed_official
- Date:
- Mon Feb 03 09:30:05 2014 +0000
- Revision:
- 84:f54042cbc282
- Parent:
- 70:c1fbde68b492
Synchronized with git revision bbbd8699601c42149ccf0c37bc42bb6856ccc4c6
Full URL: https://github.com/mbedmicro/mbed/commit/bbbd8699601c42149ccf0c37bc42bb6856ccc4c6/
[NUCLEO_L152RE/F030_R8] SPI, I2C, Ticker, PWM updates
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 | 84:f54042cbc282 | 5 | * @version V3.6.1 |
mbed_official | 84:f54042cbc282 | 6 | * @date 05-March-2012 |
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 | 84:f54042cbc282 | 150 | uint16_t high1 = 0, high2 = 0, low = 0; |
mbed_official | 84:f54042cbc282 | 151 | |
mbed_official | 84:f54042cbc282 | 152 | high1 = RTC->CNTH; |
mbed_official | 84:f54042cbc282 | 153 | low = RTC->CNTL; |
mbed_official | 84:f54042cbc282 | 154 | high2 = RTC->CNTH; |
mbed_official | 84:f54042cbc282 | 155 | |
mbed_official | 84:f54042cbc282 | 156 | if (high1 != high2) |
mbed_official | 84:f54042cbc282 | 157 | { /* In this case the counter roll over during reading of CNTL and CNTH registers, |
mbed_official | 84:f54042cbc282 | 158 | read again CNTL register then return the counter value */ |
mbed_official | 84:f54042cbc282 | 159 | return (((uint32_t) high2 << 16 ) | RTC->CNTL); |
mbed_official | 84:f54042cbc282 | 160 | } |
mbed_official | 84:f54042cbc282 | 161 | else |
mbed_official | 84:f54042cbc282 | 162 | { /* No counter roll over during reading of CNTL and CNTH registers, counter |
mbed_official | 84:f54042cbc282 | 163 | value is equal to first value of CNTL and CNTH */ |
mbed_official | 84:f54042cbc282 | 164 | return (((uint32_t) high1 << 16 ) | low); |
mbed_official | 84:f54042cbc282 | 165 | } |
mbed_official | 52:a51c77007319 | 166 | } |
mbed_official | 52:a51c77007319 | 167 | |
mbed_official | 52:a51c77007319 | 168 | /** |
mbed_official | 52:a51c77007319 | 169 | * @brief Sets the RTC counter value. |
mbed_official | 52:a51c77007319 | 170 | * @param CounterValue: RTC counter new value. |
mbed_official | 52:a51c77007319 | 171 | * @retval None |
mbed_official | 52:a51c77007319 | 172 | */ |
mbed_official | 52:a51c77007319 | 173 | void RTC_SetCounter(uint32_t CounterValue) |
mbed_official | 52:a51c77007319 | 174 | { |
mbed_official | 52:a51c77007319 | 175 | RTC_EnterConfigMode(); |
mbed_official | 52:a51c77007319 | 176 | /* Set RTC COUNTER MSB word */ |
mbed_official | 52:a51c77007319 | 177 | RTC->CNTH = CounterValue >> 16; |
mbed_official | 52:a51c77007319 | 178 | /* Set RTC COUNTER LSB word */ |
mbed_official | 52:a51c77007319 | 179 | RTC->CNTL = (CounterValue & RTC_LSB_MASK); |
mbed_official | 52:a51c77007319 | 180 | RTC_ExitConfigMode(); |
mbed_official | 52:a51c77007319 | 181 | } |
mbed_official | 52:a51c77007319 | 182 | |
mbed_official | 52:a51c77007319 | 183 | /** |
mbed_official | 52:a51c77007319 | 184 | * @brief Sets the RTC prescaler value. |
mbed_official | 52:a51c77007319 | 185 | * @param PrescalerValue: RTC prescaler new value. |
mbed_official | 52:a51c77007319 | 186 | * @retval None |
mbed_official | 52:a51c77007319 | 187 | */ |
mbed_official | 52:a51c77007319 | 188 | void RTC_SetPrescaler(uint32_t PrescalerValue) |
mbed_official | 52:a51c77007319 | 189 | { |
mbed_official | 52:a51c77007319 | 190 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 191 | assert_param(IS_RTC_PRESCALER(PrescalerValue)); |
mbed_official | 52:a51c77007319 | 192 | |
mbed_official | 52:a51c77007319 | 193 | RTC_EnterConfigMode(); |
mbed_official | 52:a51c77007319 | 194 | /* Set RTC PRESCALER MSB word */ |
mbed_official | 52:a51c77007319 | 195 | RTC->PRLH = (PrescalerValue & PRLH_MSB_MASK) >> 16; |
mbed_official | 52:a51c77007319 | 196 | /* Set RTC PRESCALER LSB word */ |
mbed_official | 52:a51c77007319 | 197 | RTC->PRLL = (PrescalerValue & RTC_LSB_MASK); |
mbed_official | 52:a51c77007319 | 198 | RTC_ExitConfigMode(); |
mbed_official | 52:a51c77007319 | 199 | } |
mbed_official | 52:a51c77007319 | 200 | |
mbed_official | 52:a51c77007319 | 201 | /** |
mbed_official | 52:a51c77007319 | 202 | * @brief Sets the RTC alarm value. |
mbed_official | 52:a51c77007319 | 203 | * @param AlarmValue: RTC alarm new value. |
mbed_official | 52:a51c77007319 | 204 | * @retval None |
mbed_official | 52:a51c77007319 | 205 | */ |
mbed_official | 52:a51c77007319 | 206 | void RTC_SetAlarm(uint32_t AlarmValue) |
mbed_official | 52:a51c77007319 | 207 | { |
mbed_official | 52:a51c77007319 | 208 | RTC_EnterConfigMode(); |
mbed_official | 52:a51c77007319 | 209 | /* Set the ALARM MSB word */ |
mbed_official | 52:a51c77007319 | 210 | RTC->ALRH = AlarmValue >> 16; |
mbed_official | 52:a51c77007319 | 211 | /* Set the ALARM LSB word */ |
mbed_official | 52:a51c77007319 | 212 | RTC->ALRL = (AlarmValue & RTC_LSB_MASK); |
mbed_official | 52:a51c77007319 | 213 | RTC_ExitConfigMode(); |
mbed_official | 52:a51c77007319 | 214 | } |
mbed_official | 52:a51c77007319 | 215 | |
mbed_official | 52:a51c77007319 | 216 | /** |
mbed_official | 52:a51c77007319 | 217 | * @brief Gets the RTC divider value. |
mbed_official | 52:a51c77007319 | 218 | * @param None |
mbed_official | 52:a51c77007319 | 219 | * @retval RTC Divider value. |
mbed_official | 52:a51c77007319 | 220 | */ |
mbed_official | 52:a51c77007319 | 221 | uint32_t RTC_GetDivider(void) |
mbed_official | 52:a51c77007319 | 222 | { |
mbed_official | 52:a51c77007319 | 223 | uint32_t tmp = 0x00; |
mbed_official | 52:a51c77007319 | 224 | tmp = ((uint32_t)RTC->DIVH & (uint32_t)0x000F) << 16; |
mbed_official | 52:a51c77007319 | 225 | tmp |= RTC->DIVL; |
mbed_official | 52:a51c77007319 | 226 | return tmp; |
mbed_official | 52:a51c77007319 | 227 | } |
mbed_official | 52:a51c77007319 | 228 | |
mbed_official | 52:a51c77007319 | 229 | /** |
mbed_official | 52:a51c77007319 | 230 | * @brief Waits until last write operation on RTC registers has finished. |
mbed_official | 52:a51c77007319 | 231 | * @note This function must be called before any write to RTC registers. |
mbed_official | 52:a51c77007319 | 232 | * @param None |
mbed_official | 52:a51c77007319 | 233 | * @retval None |
mbed_official | 52:a51c77007319 | 234 | */ |
mbed_official | 52:a51c77007319 | 235 | void RTC_WaitForLastTask(void) |
mbed_official | 52:a51c77007319 | 236 | { |
mbed_official | 52:a51c77007319 | 237 | /* Loop until RTOFF flag is set */ |
mbed_official | 52:a51c77007319 | 238 | while ((RTC->CRL & RTC_FLAG_RTOFF) == (uint16_t)RESET) |
mbed_official | 52:a51c77007319 | 239 | { |
mbed_official | 52:a51c77007319 | 240 | } |
mbed_official | 52:a51c77007319 | 241 | } |
mbed_official | 52:a51c77007319 | 242 | |
mbed_official | 52:a51c77007319 | 243 | /** |
mbed_official | 52:a51c77007319 | 244 | * @brief Waits until the RTC registers (RTC_CNT, RTC_ALR and RTC_PRL) |
mbed_official | 52:a51c77007319 | 245 | * are synchronized with RTC APB clock. |
mbed_official | 52:a51c77007319 | 246 | * @note This function must be called before any read operation after an APB reset |
mbed_official | 52:a51c77007319 | 247 | * or an APB clock stop. |
mbed_official | 52:a51c77007319 | 248 | * @param None |
mbed_official | 52:a51c77007319 | 249 | * @retval None |
mbed_official | 52:a51c77007319 | 250 | */ |
mbed_official | 52:a51c77007319 | 251 | void RTC_WaitForSynchro(void) |
mbed_official | 52:a51c77007319 | 252 | { |
mbed_official | 52:a51c77007319 | 253 | /* Clear RSF flag */ |
mbed_official | 52:a51c77007319 | 254 | RTC->CRL &= (uint16_t)~RTC_FLAG_RSF; |
mbed_official | 52:a51c77007319 | 255 | /* Loop until RSF flag is set */ |
mbed_official | 52:a51c77007319 | 256 | while ((RTC->CRL & RTC_FLAG_RSF) == (uint16_t)RESET) |
mbed_official | 52:a51c77007319 | 257 | { |
mbed_official | 52:a51c77007319 | 258 | } |
mbed_official | 52:a51c77007319 | 259 | } |
mbed_official | 52:a51c77007319 | 260 | |
mbed_official | 52:a51c77007319 | 261 | /** |
mbed_official | 52:a51c77007319 | 262 | * @brief Checks whether the specified RTC flag is set or not. |
mbed_official | 52:a51c77007319 | 263 | * @param RTC_FLAG: specifies the flag to check. |
mbed_official | 52:a51c77007319 | 264 | * This parameter can be one the following values: |
mbed_official | 52:a51c77007319 | 265 | * @arg RTC_FLAG_RTOFF: RTC Operation OFF flag |
mbed_official | 52:a51c77007319 | 266 | * @arg RTC_FLAG_RSF: Registers Synchronized flag |
mbed_official | 52:a51c77007319 | 267 | * @arg RTC_FLAG_OW: Overflow flag |
mbed_official | 52:a51c77007319 | 268 | * @arg RTC_FLAG_ALR: Alarm flag |
mbed_official | 52:a51c77007319 | 269 | * @arg RTC_FLAG_SEC: Second flag |
mbed_official | 52:a51c77007319 | 270 | * @retval The new state of RTC_FLAG (SET or RESET). |
mbed_official | 52:a51c77007319 | 271 | */ |
mbed_official | 52:a51c77007319 | 272 | FlagStatus RTC_GetFlagStatus(uint16_t RTC_FLAG) |
mbed_official | 52:a51c77007319 | 273 | { |
mbed_official | 52:a51c77007319 | 274 | FlagStatus bitstatus = RESET; |
mbed_official | 52:a51c77007319 | 275 | |
mbed_official | 52:a51c77007319 | 276 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 277 | assert_param(IS_RTC_GET_FLAG(RTC_FLAG)); |
mbed_official | 52:a51c77007319 | 278 | |
mbed_official | 52:a51c77007319 | 279 | if ((RTC->CRL & RTC_FLAG) != (uint16_t)RESET) |
mbed_official | 52:a51c77007319 | 280 | { |
mbed_official | 52:a51c77007319 | 281 | bitstatus = SET; |
mbed_official | 52:a51c77007319 | 282 | } |
mbed_official | 52:a51c77007319 | 283 | else |
mbed_official | 52:a51c77007319 | 284 | { |
mbed_official | 52:a51c77007319 | 285 | bitstatus = RESET; |
mbed_official | 52:a51c77007319 | 286 | } |
mbed_official | 52:a51c77007319 | 287 | return bitstatus; |
mbed_official | 52:a51c77007319 | 288 | } |
mbed_official | 52:a51c77007319 | 289 | |
mbed_official | 52:a51c77007319 | 290 | /** |
mbed_official | 52:a51c77007319 | 291 | * @brief Clears the RTC's pending flags. |
mbed_official | 52:a51c77007319 | 292 | * @param RTC_FLAG: specifies the flag to clear. |
mbed_official | 52:a51c77007319 | 293 | * This parameter can be any combination of the following values: |
mbed_official | 52:a51c77007319 | 294 | * @arg RTC_FLAG_RSF: Registers Synchronized flag. This flag is cleared only after |
mbed_official | 52:a51c77007319 | 295 | * an APB reset or an APB Clock stop. |
mbed_official | 52:a51c77007319 | 296 | * @arg RTC_FLAG_OW: Overflow flag |
mbed_official | 52:a51c77007319 | 297 | * @arg RTC_FLAG_ALR: Alarm flag |
mbed_official | 52:a51c77007319 | 298 | * @arg RTC_FLAG_SEC: Second flag |
mbed_official | 52:a51c77007319 | 299 | * @retval None |
mbed_official | 52:a51c77007319 | 300 | */ |
mbed_official | 52:a51c77007319 | 301 | void RTC_ClearFlag(uint16_t RTC_FLAG) |
mbed_official | 52:a51c77007319 | 302 | { |
mbed_official | 52:a51c77007319 | 303 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 304 | assert_param(IS_RTC_CLEAR_FLAG(RTC_FLAG)); |
mbed_official | 52:a51c77007319 | 305 | |
mbed_official | 52:a51c77007319 | 306 | /* Clear the corresponding RTC flag */ |
mbed_official | 52:a51c77007319 | 307 | RTC->CRL &= (uint16_t)~RTC_FLAG; |
mbed_official | 52:a51c77007319 | 308 | } |
mbed_official | 52:a51c77007319 | 309 | |
mbed_official | 52:a51c77007319 | 310 | /** |
mbed_official | 52:a51c77007319 | 311 | * @brief Checks whether the specified RTC interrupt has occurred or not. |
mbed_official | 52:a51c77007319 | 312 | * @param RTC_IT: specifies the RTC interrupts sources to check. |
mbed_official | 52:a51c77007319 | 313 | * This parameter can be one of the following values: |
mbed_official | 52:a51c77007319 | 314 | * @arg RTC_IT_OW: Overflow interrupt |
mbed_official | 52:a51c77007319 | 315 | * @arg RTC_IT_ALR: Alarm interrupt |
mbed_official | 52:a51c77007319 | 316 | * @arg RTC_IT_SEC: Second interrupt |
mbed_official | 52:a51c77007319 | 317 | * @retval The new state of the RTC_IT (SET or RESET). |
mbed_official | 52:a51c77007319 | 318 | */ |
mbed_official | 52:a51c77007319 | 319 | ITStatus RTC_GetITStatus(uint16_t RTC_IT) |
mbed_official | 52:a51c77007319 | 320 | { |
mbed_official | 52:a51c77007319 | 321 | ITStatus bitstatus = RESET; |
mbed_official | 52:a51c77007319 | 322 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 323 | assert_param(IS_RTC_GET_IT(RTC_IT)); |
mbed_official | 52:a51c77007319 | 324 | |
mbed_official | 52:a51c77007319 | 325 | bitstatus = (ITStatus)(RTC->CRL & RTC_IT); |
mbed_official | 52:a51c77007319 | 326 | if (((RTC->CRH & RTC_IT) != (uint16_t)RESET) && (bitstatus != (uint16_t)RESET)) |
mbed_official | 52:a51c77007319 | 327 | { |
mbed_official | 52:a51c77007319 | 328 | bitstatus = SET; |
mbed_official | 52:a51c77007319 | 329 | } |
mbed_official | 52:a51c77007319 | 330 | else |
mbed_official | 52:a51c77007319 | 331 | { |
mbed_official | 52:a51c77007319 | 332 | bitstatus = RESET; |
mbed_official | 52:a51c77007319 | 333 | } |
mbed_official | 52:a51c77007319 | 334 | return bitstatus; |
mbed_official | 52:a51c77007319 | 335 | } |
mbed_official | 52:a51c77007319 | 336 | |
mbed_official | 52:a51c77007319 | 337 | /** |
mbed_official | 52:a51c77007319 | 338 | * @brief Clears the RTC's interrupt pending bits. |
mbed_official | 52:a51c77007319 | 339 | * @param RTC_IT: specifies the interrupt pending bit to clear. |
mbed_official | 52:a51c77007319 | 340 | * This parameter can be any combination of the following values: |
mbed_official | 52:a51c77007319 | 341 | * @arg RTC_IT_OW: Overflow interrupt |
mbed_official | 52:a51c77007319 | 342 | * @arg RTC_IT_ALR: Alarm interrupt |
mbed_official | 52:a51c77007319 | 343 | * @arg RTC_IT_SEC: Second interrupt |
mbed_official | 52:a51c77007319 | 344 | * @retval None |
mbed_official | 52:a51c77007319 | 345 | */ |
mbed_official | 52:a51c77007319 | 346 | void RTC_ClearITPendingBit(uint16_t RTC_IT) |
mbed_official | 52:a51c77007319 | 347 | { |
mbed_official | 52:a51c77007319 | 348 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 349 | assert_param(IS_RTC_IT(RTC_IT)); |
mbed_official | 52:a51c77007319 | 350 | |
mbed_official | 52:a51c77007319 | 351 | /* Clear the corresponding RTC pending bit */ |
mbed_official | 52:a51c77007319 | 352 | RTC->CRL &= (uint16_t)~RTC_IT; |
mbed_official | 52:a51c77007319 | 353 | } |
mbed_official | 52:a51c77007319 | 354 | |
mbed_official | 52:a51c77007319 | 355 | /** |
mbed_official | 52:a51c77007319 | 356 | * @} |
mbed_official | 52:a51c77007319 | 357 | */ |
mbed_official | 52:a51c77007319 | 358 | |
mbed_official | 52:a51c77007319 | 359 | /** |
mbed_official | 52:a51c77007319 | 360 | * @} |
mbed_official | 52:a51c77007319 | 361 | */ |
mbed_official | 52:a51c77007319 | 362 | |
mbed_official | 52:a51c77007319 | 363 | /** |
mbed_official | 52:a51c77007319 | 364 | * @} |
mbed_official | 52:a51c77007319 | 365 | */ |
mbed_official | 52:a51c77007319 | 366 | |
mbed_official | 84:f54042cbc282 | 367 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |