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