mbed library sources modified for open wear
Dependents: openwear-lifelogger-example
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F302R8/stm32f30x_dbgmcu.c@125:23cc3068a9e4, 2014-03-19 (annotated)
- Committer:
- mbed_official
- Date:
- Wed Mar 19 10:15:22 2014 +0000
- Revision:
- 125:23cc3068a9e4
Synchronized with git revision ace35dfba3748c7cdc102eb38ec6b9e1067c3252
Full URL: https://github.com/mbedmicro/mbed/commit/ace35dfba3748c7cdc102eb38ec6b9e1067c3252/
[NUCLEO_F302R8] Add cmsis and hal files + change F401RE clock to 84MHz
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 125:23cc3068a9e4 | 1 | /** |
mbed_official | 125:23cc3068a9e4 | 2 | ****************************************************************************** |
mbed_official | 125:23cc3068a9e4 | 3 | * @file stm32f30x_dbgmcu.c |
mbed_official | 125:23cc3068a9e4 | 4 | * @author MCD Application Team |
mbed_official | 125:23cc3068a9e4 | 5 | * @version V1.1.0 |
mbed_official | 125:23cc3068a9e4 | 6 | * @date 27-February-2014 |
mbed_official | 125:23cc3068a9e4 | 7 | * @brief This file provides firmware functions to manage the following |
mbed_official | 125:23cc3068a9e4 | 8 | * functionalities of the Debug MCU (DBGMCU) peripheral: |
mbed_official | 125:23cc3068a9e4 | 9 | * + Device and Revision ID management |
mbed_official | 125:23cc3068a9e4 | 10 | * + Peripherals Configuration |
mbed_official | 125:23cc3068a9e4 | 11 | ****************************************************************************** |
mbed_official | 125:23cc3068a9e4 | 12 | * @attention |
mbed_official | 125:23cc3068a9e4 | 13 | * |
mbed_official | 125:23cc3068a9e4 | 14 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 125:23cc3068a9e4 | 15 | * |
mbed_official | 125:23cc3068a9e4 | 16 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 125:23cc3068a9e4 | 17 | * are permitted provided that the following conditions are met: |
mbed_official | 125:23cc3068a9e4 | 18 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 125:23cc3068a9e4 | 19 | * this list of conditions and the following disclaimer. |
mbed_official | 125:23cc3068a9e4 | 20 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 125:23cc3068a9e4 | 21 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 125:23cc3068a9e4 | 22 | * and/or other materials provided with the distribution. |
mbed_official | 125:23cc3068a9e4 | 23 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 125:23cc3068a9e4 | 24 | * may be used to endorse or promote products derived from this software |
mbed_official | 125:23cc3068a9e4 | 25 | * without specific prior written permission. |
mbed_official | 125:23cc3068a9e4 | 26 | * |
mbed_official | 125:23cc3068a9e4 | 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 125:23cc3068a9e4 | 28 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 125:23cc3068a9e4 | 29 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 125:23cc3068a9e4 | 30 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 125:23cc3068a9e4 | 31 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 125:23cc3068a9e4 | 32 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 125:23cc3068a9e4 | 33 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 125:23cc3068a9e4 | 34 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 125:23cc3068a9e4 | 35 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 125:23cc3068a9e4 | 36 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 125:23cc3068a9e4 | 37 | * |
mbed_official | 125:23cc3068a9e4 | 38 | ****************************************************************************** |
mbed_official | 125:23cc3068a9e4 | 39 | */ |
mbed_official | 125:23cc3068a9e4 | 40 | |
mbed_official | 125:23cc3068a9e4 | 41 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 125:23cc3068a9e4 | 42 | #include "stm32f30x_dbgmcu.h" |
mbed_official | 125:23cc3068a9e4 | 43 | |
mbed_official | 125:23cc3068a9e4 | 44 | /** @addtogroup STM32F30x_StdPeriph_Driver |
mbed_official | 125:23cc3068a9e4 | 45 | * @{ |
mbed_official | 125:23cc3068a9e4 | 46 | */ |
mbed_official | 125:23cc3068a9e4 | 47 | |
mbed_official | 125:23cc3068a9e4 | 48 | /** @defgroup DBGMCU |
mbed_official | 125:23cc3068a9e4 | 49 | * @brief DBGMCU driver modules |
mbed_official | 125:23cc3068a9e4 | 50 | * @{ |
mbed_official | 125:23cc3068a9e4 | 51 | */ |
mbed_official | 125:23cc3068a9e4 | 52 | |
mbed_official | 125:23cc3068a9e4 | 53 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 125:23cc3068a9e4 | 54 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 125:23cc3068a9e4 | 55 | #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF) |
mbed_official | 125:23cc3068a9e4 | 56 | |
mbed_official | 125:23cc3068a9e4 | 57 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 125:23cc3068a9e4 | 58 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 125:23cc3068a9e4 | 59 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 125:23cc3068a9e4 | 60 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 125:23cc3068a9e4 | 61 | |
mbed_official | 125:23cc3068a9e4 | 62 | /** @defgroup DBGMCU_Private_Functions |
mbed_official | 125:23cc3068a9e4 | 63 | * @{ |
mbed_official | 125:23cc3068a9e4 | 64 | */ |
mbed_official | 125:23cc3068a9e4 | 65 | |
mbed_official | 125:23cc3068a9e4 | 66 | /** @defgroup DBGMCU_Group1 Device and Revision ID management functions |
mbed_official | 125:23cc3068a9e4 | 67 | * @brief Device and Revision ID management functions |
mbed_official | 125:23cc3068a9e4 | 68 | * |
mbed_official | 125:23cc3068a9e4 | 69 | @verbatim |
mbed_official | 125:23cc3068a9e4 | 70 | ============================================================================== |
mbed_official | 125:23cc3068a9e4 | 71 | ##### Device and Revision ID management functions ##### |
mbed_official | 125:23cc3068a9e4 | 72 | ============================================================================== |
mbed_official | 125:23cc3068a9e4 | 73 | |
mbed_official | 125:23cc3068a9e4 | 74 | @endverbatim |
mbed_official | 125:23cc3068a9e4 | 75 | * @{ |
mbed_official | 125:23cc3068a9e4 | 76 | */ |
mbed_official | 125:23cc3068a9e4 | 77 | |
mbed_official | 125:23cc3068a9e4 | 78 | /** |
mbed_official | 125:23cc3068a9e4 | 79 | * @brief Returns the device revision identifier. |
mbed_official | 125:23cc3068a9e4 | 80 | * @param None |
mbed_official | 125:23cc3068a9e4 | 81 | * @retval Device revision identifier |
mbed_official | 125:23cc3068a9e4 | 82 | */ |
mbed_official | 125:23cc3068a9e4 | 83 | uint32_t DBGMCU_GetREVID(void) |
mbed_official | 125:23cc3068a9e4 | 84 | { |
mbed_official | 125:23cc3068a9e4 | 85 | return(DBGMCU->IDCODE >> 16); |
mbed_official | 125:23cc3068a9e4 | 86 | } |
mbed_official | 125:23cc3068a9e4 | 87 | |
mbed_official | 125:23cc3068a9e4 | 88 | /** |
mbed_official | 125:23cc3068a9e4 | 89 | * @brief Returns the device identifier. |
mbed_official | 125:23cc3068a9e4 | 90 | * @param None |
mbed_official | 125:23cc3068a9e4 | 91 | * @retval Device identifier |
mbed_official | 125:23cc3068a9e4 | 92 | */ |
mbed_official | 125:23cc3068a9e4 | 93 | uint32_t DBGMCU_GetDEVID(void) |
mbed_official | 125:23cc3068a9e4 | 94 | { |
mbed_official | 125:23cc3068a9e4 | 95 | return(DBGMCU->IDCODE & IDCODE_DEVID_MASK); |
mbed_official | 125:23cc3068a9e4 | 96 | } |
mbed_official | 125:23cc3068a9e4 | 97 | |
mbed_official | 125:23cc3068a9e4 | 98 | /** |
mbed_official | 125:23cc3068a9e4 | 99 | * @} |
mbed_official | 125:23cc3068a9e4 | 100 | */ |
mbed_official | 125:23cc3068a9e4 | 101 | |
mbed_official | 125:23cc3068a9e4 | 102 | /** @defgroup DBGMCU_Group2 Peripherals Configuration functions |
mbed_official | 125:23cc3068a9e4 | 103 | * @brief Peripherals Configuration |
mbed_official | 125:23cc3068a9e4 | 104 | * |
mbed_official | 125:23cc3068a9e4 | 105 | @verbatim |
mbed_official | 125:23cc3068a9e4 | 106 | ============================================================================== |
mbed_official | 125:23cc3068a9e4 | 107 | ##### Peripherals Configuration functions ##### |
mbed_official | 125:23cc3068a9e4 | 108 | ============================================================================== |
mbed_official | 125:23cc3068a9e4 | 109 | |
mbed_official | 125:23cc3068a9e4 | 110 | @endverbatim |
mbed_official | 125:23cc3068a9e4 | 111 | * @{ |
mbed_official | 125:23cc3068a9e4 | 112 | */ |
mbed_official | 125:23cc3068a9e4 | 113 | |
mbed_official | 125:23cc3068a9e4 | 114 | /** |
mbed_official | 125:23cc3068a9e4 | 115 | * @brief Configures low power mode behavior when the MCU is in Debug mode. |
mbed_official | 125:23cc3068a9e4 | 116 | * @param DBGMCU_Periph: specifies the low power mode. |
mbed_official | 125:23cc3068a9e4 | 117 | * This parameter can be any combination of the following values: |
mbed_official | 125:23cc3068a9e4 | 118 | * @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode. |
mbed_official | 125:23cc3068a9e4 | 119 | * @arg DBGMCU_STOP: Keep debugger connection during STOP mode. |
mbed_official | 125:23cc3068a9e4 | 120 | * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode. |
mbed_official | 125:23cc3068a9e4 | 121 | * @param NewState: new state of the specified low power mode in Debug mode. |
mbed_official | 125:23cc3068a9e4 | 122 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 125:23cc3068a9e4 | 123 | * @retval None |
mbed_official | 125:23cc3068a9e4 | 124 | */ |
mbed_official | 125:23cc3068a9e4 | 125 | void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState) |
mbed_official | 125:23cc3068a9e4 | 126 | { |
mbed_official | 125:23cc3068a9e4 | 127 | /* Check the parameters */ |
mbed_official | 125:23cc3068a9e4 | 128 | assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph)); |
mbed_official | 125:23cc3068a9e4 | 129 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 125:23cc3068a9e4 | 130 | if (NewState != DISABLE) |
mbed_official | 125:23cc3068a9e4 | 131 | { |
mbed_official | 125:23cc3068a9e4 | 132 | DBGMCU->CR |= DBGMCU_Periph; |
mbed_official | 125:23cc3068a9e4 | 133 | } |
mbed_official | 125:23cc3068a9e4 | 134 | else |
mbed_official | 125:23cc3068a9e4 | 135 | { |
mbed_official | 125:23cc3068a9e4 | 136 | DBGMCU->CR &= ~DBGMCU_Periph; |
mbed_official | 125:23cc3068a9e4 | 137 | } |
mbed_official | 125:23cc3068a9e4 | 138 | } |
mbed_official | 125:23cc3068a9e4 | 139 | |
mbed_official | 125:23cc3068a9e4 | 140 | /** |
mbed_official | 125:23cc3068a9e4 | 141 | * @brief Configures APB1 peripheral behavior when the MCU is in Debug mode. |
mbed_official | 125:23cc3068a9e4 | 142 | * @param DBGMCU_Periph: specifies the APB1 peripheral. |
mbed_official | 125:23cc3068a9e4 | 143 | * This parameter can be any combination of the following values: |
mbed_official | 125:23cc3068a9e4 | 144 | * @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted. |
mbed_official | 125:23cc3068a9e4 | 145 | * @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted. |
mbed_official | 125:23cc3068a9e4 | 146 | * @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted. |
mbed_official | 125:23cc3068a9e4 | 147 | * @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted. |
mbed_official | 125:23cc3068a9e4 | 148 | * @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted. |
mbed_official | 125:23cc3068a9e4 | 149 | * @arg DBGMCU_RTC_STOP: RTC Calendar and Wakeup counter are stopped when |
mbed_official | 125:23cc3068a9e4 | 150 | * Core is halted. |
mbed_official | 125:23cc3068a9e4 | 151 | * @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted. |
mbed_official | 125:23cc3068a9e4 | 152 | * @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted. |
mbed_official | 125:23cc3068a9e4 | 153 | * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when |
mbed_official | 125:23cc3068a9e4 | 154 | * Core is halted. |
mbed_official | 125:23cc3068a9e4 | 155 | * @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when |
mbed_official | 125:23cc3068a9e4 | 156 | * Core is halted. |
mbed_official | 125:23cc3068a9e4 | 157 | * @arg DBGMCU_CAN1_STOP: Debug CAN2 stopped when Core is halted. |
mbed_official | 125:23cc3068a9e4 | 158 | * @param NewState: new state of the specified APB1 peripheral in Debug mode. |
mbed_official | 125:23cc3068a9e4 | 159 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 125:23cc3068a9e4 | 160 | * @retval None |
mbed_official | 125:23cc3068a9e4 | 161 | */ |
mbed_official | 125:23cc3068a9e4 | 162 | void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState) |
mbed_official | 125:23cc3068a9e4 | 163 | { |
mbed_official | 125:23cc3068a9e4 | 164 | /* Check the parameters */ |
mbed_official | 125:23cc3068a9e4 | 165 | assert_param(IS_DBGMCU_APB1PERIPH(DBGMCU_Periph)); |
mbed_official | 125:23cc3068a9e4 | 166 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 125:23cc3068a9e4 | 167 | |
mbed_official | 125:23cc3068a9e4 | 168 | if (NewState != DISABLE) |
mbed_official | 125:23cc3068a9e4 | 169 | { |
mbed_official | 125:23cc3068a9e4 | 170 | DBGMCU->APB1FZ |= DBGMCU_Periph; |
mbed_official | 125:23cc3068a9e4 | 171 | } |
mbed_official | 125:23cc3068a9e4 | 172 | else |
mbed_official | 125:23cc3068a9e4 | 173 | { |
mbed_official | 125:23cc3068a9e4 | 174 | DBGMCU->APB1FZ &= ~DBGMCU_Periph; |
mbed_official | 125:23cc3068a9e4 | 175 | } |
mbed_official | 125:23cc3068a9e4 | 176 | } |
mbed_official | 125:23cc3068a9e4 | 177 | |
mbed_official | 125:23cc3068a9e4 | 178 | /** |
mbed_official | 125:23cc3068a9e4 | 179 | * @brief Configures APB2 peripheral behavior when the MCU is in Debug mode. |
mbed_official | 125:23cc3068a9e4 | 180 | * @param DBGMCU_Periph: specifies the APB2 peripheral. |
mbed_official | 125:23cc3068a9e4 | 181 | * This parameter can be any combination of the following values: |
mbed_official | 125:23cc3068a9e4 | 182 | * @arg DBGMCU_TIM1_STOP: TIM1 counter stopped when Core is halted. |
mbed_official | 125:23cc3068a9e4 | 183 | * @arg DBGMCU_TIM8_STOP: TIM8 counter stopped when Core is halted. |
mbed_official | 125:23cc3068a9e4 | 184 | * @arg DBGMCU_TIM15_STOP: TIM15 counter stopped when Core is halted. |
mbed_official | 125:23cc3068a9e4 | 185 | * @arg DBGMCU_TIM16_STOP: TIM16 counter stopped when Core is halted. |
mbed_official | 125:23cc3068a9e4 | 186 | * @arg DBGMCU_TIM17_STOP: TIM17 counter stopped when Core is halted. |
mbed_official | 125:23cc3068a9e4 | 187 | * @param NewState: new state of the specified APB2 peripheral in Debug mode. |
mbed_official | 125:23cc3068a9e4 | 188 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 125:23cc3068a9e4 | 189 | * @retval None |
mbed_official | 125:23cc3068a9e4 | 190 | */ |
mbed_official | 125:23cc3068a9e4 | 191 | void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState) |
mbed_official | 125:23cc3068a9e4 | 192 | { |
mbed_official | 125:23cc3068a9e4 | 193 | /* Check the parameters */ |
mbed_official | 125:23cc3068a9e4 | 194 | assert_param(IS_DBGMCU_APB2PERIPH(DBGMCU_Periph)); |
mbed_official | 125:23cc3068a9e4 | 195 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 125:23cc3068a9e4 | 196 | |
mbed_official | 125:23cc3068a9e4 | 197 | if (NewState != DISABLE) |
mbed_official | 125:23cc3068a9e4 | 198 | { |
mbed_official | 125:23cc3068a9e4 | 199 | DBGMCU->APB2FZ |= DBGMCU_Periph; |
mbed_official | 125:23cc3068a9e4 | 200 | } |
mbed_official | 125:23cc3068a9e4 | 201 | else |
mbed_official | 125:23cc3068a9e4 | 202 | { |
mbed_official | 125:23cc3068a9e4 | 203 | DBGMCU->APB2FZ &= ~DBGMCU_Periph; |
mbed_official | 125:23cc3068a9e4 | 204 | } |
mbed_official | 125:23cc3068a9e4 | 205 | } |
mbed_official | 125:23cc3068a9e4 | 206 | |
mbed_official | 125:23cc3068a9e4 | 207 | /** |
mbed_official | 125:23cc3068a9e4 | 208 | * @} |
mbed_official | 125:23cc3068a9e4 | 209 | */ |
mbed_official | 125:23cc3068a9e4 | 210 | |
mbed_official | 125:23cc3068a9e4 | 211 | /** |
mbed_official | 125:23cc3068a9e4 | 212 | * @} |
mbed_official | 125:23cc3068a9e4 | 213 | */ |
mbed_official | 125:23cc3068a9e4 | 214 | |
mbed_official | 125:23cc3068a9e4 | 215 | /** |
mbed_official | 125:23cc3068a9e4 | 216 | * @} |
mbed_official | 125:23cc3068a9e4 | 217 | */ |
mbed_official | 125:23cc3068a9e4 | 218 | |
mbed_official | 125:23cc3068a9e4 | 219 | /** |
mbed_official | 125:23cc3068a9e4 | 220 | * @} |
mbed_official | 125:23cc3068a9e4 | 221 | */ |
mbed_official | 125:23cc3068a9e4 | 222 | |
mbed_official | 125:23cc3068a9e4 | 223 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |