mbed library sources for GR-PEACH rev.B.

Fork of mbed-src by mbed official

Committer:
RyoheiHagimoto
Date:
Wed Apr 15 01:34:29 2015 +0000
Revision:
514:cf59050bad8e
Parent:
155:8435094ec241
mbed library sources for GR-PEACH rev.B.

Who changed what in which revision?

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