mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_DISCO_F100RB/stm32f10x_bkp.c@323:9e901b0a5aa1, 2014-09-13 (annotated)
- Committer:
- shaoziyang
- Date:
- Sat Sep 13 14:25:46 2014 +0000
- Revision:
- 323:9e901b0a5aa1
- Parent:
- 126:549ba18ddd81
test with CLOCK_SETUP = 0
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_bkp.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 BKP 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_bkp.h" |
mbed_official | 126:549ba18ddd81 | 39 | #include "stm32f10x_rcc.h" |
mbed_official | 126:549ba18ddd81 | 40 | |
mbed_official | 126:549ba18ddd81 | 41 | /** @addtogroup STM32F10x_StdPeriph_Driver |
mbed_official | 126:549ba18ddd81 | 42 | * @{ |
mbed_official | 126:549ba18ddd81 | 43 | */ |
mbed_official | 126:549ba18ddd81 | 44 | |
mbed_official | 126:549ba18ddd81 | 45 | /** @defgroup BKP |
mbed_official | 126:549ba18ddd81 | 46 | * @brief BKP driver modules |
mbed_official | 126:549ba18ddd81 | 47 | * @{ |
mbed_official | 126:549ba18ddd81 | 48 | */ |
mbed_official | 126:549ba18ddd81 | 49 | |
mbed_official | 126:549ba18ddd81 | 50 | /** @defgroup BKP_Private_TypesDefinitions |
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 | */ |
mbed_official | 126:549ba18ddd81 | 57 | |
mbed_official | 126:549ba18ddd81 | 58 | /** @defgroup BKP_Private_Defines |
mbed_official | 126:549ba18ddd81 | 59 | * @{ |
mbed_official | 126:549ba18ddd81 | 60 | */ |
mbed_official | 126:549ba18ddd81 | 61 | |
mbed_official | 126:549ba18ddd81 | 62 | /* ------------ BKP registers bit address in the alias region --------------- */ |
mbed_official | 126:549ba18ddd81 | 63 | #define BKP_OFFSET (BKP_BASE - PERIPH_BASE) |
mbed_official | 126:549ba18ddd81 | 64 | |
mbed_official | 126:549ba18ddd81 | 65 | /* --- CR Register ----*/ |
mbed_official | 126:549ba18ddd81 | 66 | |
mbed_official | 126:549ba18ddd81 | 67 | /* Alias word address of TPAL bit */ |
mbed_official | 126:549ba18ddd81 | 68 | #define CR_OFFSET (BKP_OFFSET + 0x30) |
mbed_official | 126:549ba18ddd81 | 69 | #define TPAL_BitNumber 0x01 |
mbed_official | 126:549ba18ddd81 | 70 | #define CR_TPAL_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (TPAL_BitNumber * 4)) |
mbed_official | 126:549ba18ddd81 | 71 | |
mbed_official | 126:549ba18ddd81 | 72 | /* Alias word address of TPE bit */ |
mbed_official | 126:549ba18ddd81 | 73 | #define TPE_BitNumber 0x00 |
mbed_official | 126:549ba18ddd81 | 74 | #define CR_TPE_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (TPE_BitNumber * 4)) |
mbed_official | 126:549ba18ddd81 | 75 | |
mbed_official | 126:549ba18ddd81 | 76 | /* --- CSR Register ---*/ |
mbed_official | 126:549ba18ddd81 | 77 | |
mbed_official | 126:549ba18ddd81 | 78 | /* Alias word address of TPIE bit */ |
mbed_official | 126:549ba18ddd81 | 79 | #define CSR_OFFSET (BKP_OFFSET + 0x34) |
mbed_official | 126:549ba18ddd81 | 80 | #define TPIE_BitNumber 0x02 |
mbed_official | 126:549ba18ddd81 | 81 | #define CSR_TPIE_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (TPIE_BitNumber * 4)) |
mbed_official | 126:549ba18ddd81 | 82 | |
mbed_official | 126:549ba18ddd81 | 83 | /* Alias word address of TIF bit */ |
mbed_official | 126:549ba18ddd81 | 84 | #define TIF_BitNumber 0x09 |
mbed_official | 126:549ba18ddd81 | 85 | #define CSR_TIF_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (TIF_BitNumber * 4)) |
mbed_official | 126:549ba18ddd81 | 86 | |
mbed_official | 126:549ba18ddd81 | 87 | /* Alias word address of TEF bit */ |
mbed_official | 126:549ba18ddd81 | 88 | #define TEF_BitNumber 0x08 |
mbed_official | 126:549ba18ddd81 | 89 | #define CSR_TEF_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (TEF_BitNumber * 4)) |
mbed_official | 126:549ba18ddd81 | 90 | |
mbed_official | 126:549ba18ddd81 | 91 | /* ---------------------- BKP registers bit mask ------------------------ */ |
mbed_official | 126:549ba18ddd81 | 92 | |
mbed_official | 126:549ba18ddd81 | 93 | /* RTCCR register bit mask */ |
mbed_official | 126:549ba18ddd81 | 94 | #define RTCCR_CAL_MASK ((uint16_t)0xFF80) |
mbed_official | 126:549ba18ddd81 | 95 | #define RTCCR_MASK ((uint16_t)0xFC7F) |
mbed_official | 126:549ba18ddd81 | 96 | |
mbed_official | 126:549ba18ddd81 | 97 | /** |
mbed_official | 126:549ba18ddd81 | 98 | * @} |
mbed_official | 126:549ba18ddd81 | 99 | */ |
mbed_official | 126:549ba18ddd81 | 100 | |
mbed_official | 126:549ba18ddd81 | 101 | |
mbed_official | 126:549ba18ddd81 | 102 | /** @defgroup BKP_Private_Macros |
mbed_official | 126:549ba18ddd81 | 103 | * @{ |
mbed_official | 126:549ba18ddd81 | 104 | */ |
mbed_official | 126:549ba18ddd81 | 105 | |
mbed_official | 126:549ba18ddd81 | 106 | /** |
mbed_official | 126:549ba18ddd81 | 107 | * @} |
mbed_official | 126:549ba18ddd81 | 108 | */ |
mbed_official | 126:549ba18ddd81 | 109 | |
mbed_official | 126:549ba18ddd81 | 110 | /** @defgroup BKP_Private_Variables |
mbed_official | 126:549ba18ddd81 | 111 | * @{ |
mbed_official | 126:549ba18ddd81 | 112 | */ |
mbed_official | 126:549ba18ddd81 | 113 | |
mbed_official | 126:549ba18ddd81 | 114 | /** |
mbed_official | 126:549ba18ddd81 | 115 | * @} |
mbed_official | 126:549ba18ddd81 | 116 | */ |
mbed_official | 126:549ba18ddd81 | 117 | |
mbed_official | 126:549ba18ddd81 | 118 | /** @defgroup BKP_Private_FunctionPrototypes |
mbed_official | 126:549ba18ddd81 | 119 | * @{ |
mbed_official | 126:549ba18ddd81 | 120 | */ |
mbed_official | 126:549ba18ddd81 | 121 | |
mbed_official | 126:549ba18ddd81 | 122 | /** |
mbed_official | 126:549ba18ddd81 | 123 | * @} |
mbed_official | 126:549ba18ddd81 | 124 | */ |
mbed_official | 126:549ba18ddd81 | 125 | |
mbed_official | 126:549ba18ddd81 | 126 | /** @defgroup BKP_Private_Functions |
mbed_official | 126:549ba18ddd81 | 127 | * @{ |
mbed_official | 126:549ba18ddd81 | 128 | */ |
mbed_official | 126:549ba18ddd81 | 129 | |
mbed_official | 126:549ba18ddd81 | 130 | /** |
mbed_official | 126:549ba18ddd81 | 131 | * @brief Deinitializes the BKP peripheral registers to their default reset values. |
mbed_official | 126:549ba18ddd81 | 132 | * @param None |
mbed_official | 126:549ba18ddd81 | 133 | * @retval None |
mbed_official | 126:549ba18ddd81 | 134 | */ |
mbed_official | 126:549ba18ddd81 | 135 | void BKP_DeInit(void) |
mbed_official | 126:549ba18ddd81 | 136 | { |
mbed_official | 126:549ba18ddd81 | 137 | RCC_BackupResetCmd(ENABLE); |
mbed_official | 126:549ba18ddd81 | 138 | RCC_BackupResetCmd(DISABLE); |
mbed_official | 126:549ba18ddd81 | 139 | } |
mbed_official | 126:549ba18ddd81 | 140 | |
mbed_official | 126:549ba18ddd81 | 141 | /** |
mbed_official | 126:549ba18ddd81 | 142 | * @brief Configures the Tamper Pin active level. |
mbed_official | 126:549ba18ddd81 | 143 | * @param BKP_TamperPinLevel: specifies the Tamper Pin active level. |
mbed_official | 126:549ba18ddd81 | 144 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 145 | * @arg BKP_TamperPinLevel_High: Tamper pin active on high level |
mbed_official | 126:549ba18ddd81 | 146 | * @arg BKP_TamperPinLevel_Low: Tamper pin active on low level |
mbed_official | 126:549ba18ddd81 | 147 | * @retval None |
mbed_official | 126:549ba18ddd81 | 148 | */ |
mbed_official | 126:549ba18ddd81 | 149 | void BKP_TamperPinLevelConfig(uint16_t BKP_TamperPinLevel) |
mbed_official | 126:549ba18ddd81 | 150 | { |
mbed_official | 126:549ba18ddd81 | 151 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 152 | assert_param(IS_BKP_TAMPER_PIN_LEVEL(BKP_TamperPinLevel)); |
mbed_official | 126:549ba18ddd81 | 153 | *(__IO uint32_t *) CR_TPAL_BB = BKP_TamperPinLevel; |
mbed_official | 126:549ba18ddd81 | 154 | } |
mbed_official | 126:549ba18ddd81 | 155 | |
mbed_official | 126:549ba18ddd81 | 156 | /** |
mbed_official | 126:549ba18ddd81 | 157 | * @brief Enables or disables the Tamper Pin activation. |
mbed_official | 126:549ba18ddd81 | 158 | * @param NewState: new state of the Tamper Pin activation. |
mbed_official | 126:549ba18ddd81 | 159 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 126:549ba18ddd81 | 160 | * @retval None |
mbed_official | 126:549ba18ddd81 | 161 | */ |
mbed_official | 126:549ba18ddd81 | 162 | void BKP_TamperPinCmd(FunctionalState NewState) |
mbed_official | 126:549ba18ddd81 | 163 | { |
mbed_official | 126:549ba18ddd81 | 164 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 165 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 126:549ba18ddd81 | 166 | *(__IO uint32_t *) CR_TPE_BB = (uint32_t)NewState; |
mbed_official | 126:549ba18ddd81 | 167 | } |
mbed_official | 126:549ba18ddd81 | 168 | |
mbed_official | 126:549ba18ddd81 | 169 | /** |
mbed_official | 126:549ba18ddd81 | 170 | * @brief Enables or disables the Tamper Pin Interrupt. |
mbed_official | 126:549ba18ddd81 | 171 | * @param NewState: new state of the Tamper Pin Interrupt. |
mbed_official | 126:549ba18ddd81 | 172 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 126:549ba18ddd81 | 173 | * @retval None |
mbed_official | 126:549ba18ddd81 | 174 | */ |
mbed_official | 126:549ba18ddd81 | 175 | void BKP_ITConfig(FunctionalState NewState) |
mbed_official | 126:549ba18ddd81 | 176 | { |
mbed_official | 126:549ba18ddd81 | 177 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 178 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 126:549ba18ddd81 | 179 | *(__IO uint32_t *) CSR_TPIE_BB = (uint32_t)NewState; |
mbed_official | 126:549ba18ddd81 | 180 | } |
mbed_official | 126:549ba18ddd81 | 181 | |
mbed_official | 126:549ba18ddd81 | 182 | /** |
mbed_official | 126:549ba18ddd81 | 183 | * @brief Select the RTC output source to output on the Tamper pin. |
mbed_official | 126:549ba18ddd81 | 184 | * @param BKP_RTCOutputSource: specifies the RTC output source. |
mbed_official | 126:549ba18ddd81 | 185 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 186 | * @arg BKP_RTCOutputSource_None: no RTC output on the Tamper pin. |
mbed_official | 126:549ba18ddd81 | 187 | * @arg BKP_RTCOutputSource_CalibClock: output the RTC clock with frequency |
mbed_official | 126:549ba18ddd81 | 188 | * divided by 64 on the Tamper pin. |
mbed_official | 126:549ba18ddd81 | 189 | * @arg BKP_RTCOutputSource_Alarm: output the RTC Alarm pulse signal on |
mbed_official | 126:549ba18ddd81 | 190 | * the Tamper pin. |
mbed_official | 126:549ba18ddd81 | 191 | * @arg BKP_RTCOutputSource_Second: output the RTC Second pulse signal on |
mbed_official | 126:549ba18ddd81 | 192 | * the Tamper pin. |
mbed_official | 126:549ba18ddd81 | 193 | * @retval None |
mbed_official | 126:549ba18ddd81 | 194 | */ |
mbed_official | 126:549ba18ddd81 | 195 | void BKP_RTCOutputConfig(uint16_t BKP_RTCOutputSource) |
mbed_official | 126:549ba18ddd81 | 196 | { |
mbed_official | 126:549ba18ddd81 | 197 | uint16_t tmpreg = 0; |
mbed_official | 126:549ba18ddd81 | 198 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 199 | assert_param(IS_BKP_RTC_OUTPUT_SOURCE(BKP_RTCOutputSource)); |
mbed_official | 126:549ba18ddd81 | 200 | tmpreg = BKP->RTCCR; |
mbed_official | 126:549ba18ddd81 | 201 | /* Clear CCO, ASOE and ASOS bits */ |
mbed_official | 126:549ba18ddd81 | 202 | tmpreg &= RTCCR_MASK; |
mbed_official | 126:549ba18ddd81 | 203 | |
mbed_official | 126:549ba18ddd81 | 204 | /* Set CCO, ASOE and ASOS bits according to BKP_RTCOutputSource value */ |
mbed_official | 126:549ba18ddd81 | 205 | tmpreg |= BKP_RTCOutputSource; |
mbed_official | 126:549ba18ddd81 | 206 | /* Store the new value */ |
mbed_official | 126:549ba18ddd81 | 207 | BKP->RTCCR = tmpreg; |
mbed_official | 126:549ba18ddd81 | 208 | } |
mbed_official | 126:549ba18ddd81 | 209 | |
mbed_official | 126:549ba18ddd81 | 210 | /** |
mbed_official | 126:549ba18ddd81 | 211 | * @brief Sets RTC Clock Calibration value. |
mbed_official | 126:549ba18ddd81 | 212 | * @param CalibrationValue: specifies the RTC Clock Calibration value. |
mbed_official | 126:549ba18ddd81 | 213 | * This parameter must be a number between 0 and 0x7F. |
mbed_official | 126:549ba18ddd81 | 214 | * @retval None |
mbed_official | 126:549ba18ddd81 | 215 | */ |
mbed_official | 126:549ba18ddd81 | 216 | void BKP_SetRTCCalibrationValue(uint8_t CalibrationValue) |
mbed_official | 126:549ba18ddd81 | 217 | { |
mbed_official | 126:549ba18ddd81 | 218 | uint16_t tmpreg = 0; |
mbed_official | 126:549ba18ddd81 | 219 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 220 | assert_param(IS_BKP_CALIBRATION_VALUE(CalibrationValue)); |
mbed_official | 126:549ba18ddd81 | 221 | tmpreg = BKP->RTCCR; |
mbed_official | 126:549ba18ddd81 | 222 | /* Clear CAL[6:0] bits */ |
mbed_official | 126:549ba18ddd81 | 223 | tmpreg &= RTCCR_CAL_MASK; |
mbed_official | 126:549ba18ddd81 | 224 | /* Set CAL[6:0] bits according to CalibrationValue value */ |
mbed_official | 126:549ba18ddd81 | 225 | tmpreg |= CalibrationValue; |
mbed_official | 126:549ba18ddd81 | 226 | /* Store the new value */ |
mbed_official | 126:549ba18ddd81 | 227 | BKP->RTCCR = tmpreg; |
mbed_official | 126:549ba18ddd81 | 228 | } |
mbed_official | 126:549ba18ddd81 | 229 | |
mbed_official | 126:549ba18ddd81 | 230 | /** |
mbed_official | 126:549ba18ddd81 | 231 | * @brief Writes user data to the specified Data Backup Register. |
mbed_official | 126:549ba18ddd81 | 232 | * @param BKP_DR: specifies the Data Backup Register. |
mbed_official | 126:549ba18ddd81 | 233 | * This parameter can be BKP_DRx where x:[1, 42] |
mbed_official | 126:549ba18ddd81 | 234 | * @param Data: data to write |
mbed_official | 126:549ba18ddd81 | 235 | * @retval None |
mbed_official | 126:549ba18ddd81 | 236 | */ |
mbed_official | 126:549ba18ddd81 | 237 | void BKP_WriteBackupRegister(uint16_t BKP_DR, uint16_t Data) |
mbed_official | 126:549ba18ddd81 | 238 | { |
mbed_official | 126:549ba18ddd81 | 239 | __IO uint32_t tmp = 0; |
mbed_official | 126:549ba18ddd81 | 240 | |
mbed_official | 126:549ba18ddd81 | 241 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 242 | assert_param(IS_BKP_DR(BKP_DR)); |
mbed_official | 126:549ba18ddd81 | 243 | |
mbed_official | 126:549ba18ddd81 | 244 | tmp = (uint32_t)BKP_BASE; |
mbed_official | 126:549ba18ddd81 | 245 | tmp += BKP_DR; |
mbed_official | 126:549ba18ddd81 | 246 | |
mbed_official | 126:549ba18ddd81 | 247 | *(__IO uint32_t *) tmp = Data; |
mbed_official | 126:549ba18ddd81 | 248 | } |
mbed_official | 126:549ba18ddd81 | 249 | |
mbed_official | 126:549ba18ddd81 | 250 | /** |
mbed_official | 126:549ba18ddd81 | 251 | * @brief Reads data from the specified Data Backup Register. |
mbed_official | 126:549ba18ddd81 | 252 | * @param BKP_DR: specifies the Data Backup Register. |
mbed_official | 126:549ba18ddd81 | 253 | * This parameter can be BKP_DRx where x:[1, 42] |
mbed_official | 126:549ba18ddd81 | 254 | * @retval The content of the specified Data Backup Register |
mbed_official | 126:549ba18ddd81 | 255 | */ |
mbed_official | 126:549ba18ddd81 | 256 | uint16_t BKP_ReadBackupRegister(uint16_t BKP_DR) |
mbed_official | 126:549ba18ddd81 | 257 | { |
mbed_official | 126:549ba18ddd81 | 258 | __IO uint32_t tmp = 0; |
mbed_official | 126:549ba18ddd81 | 259 | |
mbed_official | 126:549ba18ddd81 | 260 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 261 | assert_param(IS_BKP_DR(BKP_DR)); |
mbed_official | 126:549ba18ddd81 | 262 | |
mbed_official | 126:549ba18ddd81 | 263 | tmp = (uint32_t)BKP_BASE; |
mbed_official | 126:549ba18ddd81 | 264 | tmp += BKP_DR; |
mbed_official | 126:549ba18ddd81 | 265 | |
mbed_official | 126:549ba18ddd81 | 266 | return (*(__IO uint16_t *) tmp); |
mbed_official | 126:549ba18ddd81 | 267 | } |
mbed_official | 126:549ba18ddd81 | 268 | |
mbed_official | 126:549ba18ddd81 | 269 | /** |
mbed_official | 126:549ba18ddd81 | 270 | * @brief Checks whether the Tamper Pin Event flag is set or not. |
mbed_official | 126:549ba18ddd81 | 271 | * @param None |
mbed_official | 126:549ba18ddd81 | 272 | * @retval The new state of the Tamper Pin Event flag (SET or RESET). |
mbed_official | 126:549ba18ddd81 | 273 | */ |
mbed_official | 126:549ba18ddd81 | 274 | FlagStatus BKP_GetFlagStatus(void) |
mbed_official | 126:549ba18ddd81 | 275 | { |
mbed_official | 126:549ba18ddd81 | 276 | return (FlagStatus)(*(__IO uint32_t *) CSR_TEF_BB); |
mbed_official | 126:549ba18ddd81 | 277 | } |
mbed_official | 126:549ba18ddd81 | 278 | |
mbed_official | 126:549ba18ddd81 | 279 | /** |
mbed_official | 126:549ba18ddd81 | 280 | * @brief Clears Tamper Pin Event pending flag. |
mbed_official | 126:549ba18ddd81 | 281 | * @param None |
mbed_official | 126:549ba18ddd81 | 282 | * @retval None |
mbed_official | 126:549ba18ddd81 | 283 | */ |
mbed_official | 126:549ba18ddd81 | 284 | void BKP_ClearFlag(void) |
mbed_official | 126:549ba18ddd81 | 285 | { |
mbed_official | 126:549ba18ddd81 | 286 | /* Set CTE bit to clear Tamper Pin Event flag */ |
mbed_official | 126:549ba18ddd81 | 287 | BKP->CSR |= BKP_CSR_CTE; |
mbed_official | 126:549ba18ddd81 | 288 | } |
mbed_official | 126:549ba18ddd81 | 289 | |
mbed_official | 126:549ba18ddd81 | 290 | /** |
mbed_official | 126:549ba18ddd81 | 291 | * @brief Checks whether the Tamper Pin Interrupt has occurred or not. |
mbed_official | 126:549ba18ddd81 | 292 | * @param None |
mbed_official | 126:549ba18ddd81 | 293 | * @retval The new state of the Tamper Pin Interrupt (SET or RESET). |
mbed_official | 126:549ba18ddd81 | 294 | */ |
mbed_official | 126:549ba18ddd81 | 295 | ITStatus BKP_GetITStatus(void) |
mbed_official | 126:549ba18ddd81 | 296 | { |
mbed_official | 126:549ba18ddd81 | 297 | return (ITStatus)(*(__IO uint32_t *) CSR_TIF_BB); |
mbed_official | 126:549ba18ddd81 | 298 | } |
mbed_official | 126:549ba18ddd81 | 299 | |
mbed_official | 126:549ba18ddd81 | 300 | /** |
mbed_official | 126:549ba18ddd81 | 301 | * @brief Clears Tamper Pin Interrupt pending bit. |
mbed_official | 126:549ba18ddd81 | 302 | * @param None |
mbed_official | 126:549ba18ddd81 | 303 | * @retval None |
mbed_official | 126:549ba18ddd81 | 304 | */ |
mbed_official | 126:549ba18ddd81 | 305 | void BKP_ClearITPendingBit(void) |
mbed_official | 126:549ba18ddd81 | 306 | { |
mbed_official | 126:549ba18ddd81 | 307 | /* Set CTI bit to clear Tamper Pin Interrupt pending bit */ |
mbed_official | 126:549ba18ddd81 | 308 | BKP->CSR |= BKP_CSR_CTI; |
mbed_official | 126:549ba18ddd81 | 309 | } |
mbed_official | 126:549ba18ddd81 | 310 | |
mbed_official | 126:549ba18ddd81 | 311 | /** |
mbed_official | 126:549ba18ddd81 | 312 | * @} |
mbed_official | 126:549ba18ddd81 | 313 | */ |
mbed_official | 126:549ba18ddd81 | 314 | |
mbed_official | 126:549ba18ddd81 | 315 | /** |
mbed_official | 126:549ba18ddd81 | 316 | * @} |
mbed_official | 126:549ba18ddd81 | 317 | */ |
mbed_official | 126:549ba18ddd81 | 318 | |
mbed_official | 126:549ba18ddd81 | 319 | /** |
mbed_official | 126:549ba18ddd81 | 320 | * @} |
mbed_official | 126:549ba18ddd81 | 321 | */ |
mbed_official | 126:549ba18ddd81 | 322 | |
mbed_official | 126:549ba18ddd81 | 323 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |