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