2 ******************************************************************************
3 * @file stm32f30x_dbgmcu.c
4 * @author MCD Application Team
6 * @date 27-February-2014
7 * @brief This file provides firmware functions to manage the following
8 * functionalities of the Debug MCU (DBGMCU) peripheral:
9 * + Device and Revision ID management
10 * + Peripherals Configuration
11 ******************************************************************************
14 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
16 * Redistribution and use in source and binary forms, with or without modification,
17 * are permitted provided that the following conditions are met:
18 * 1. Redistributions of source code must retain the above copyright notice,
19 * this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright notice,
21 * this list of conditions and the following disclaimer in the documentation
22 * and/or other materials provided with the distribution.
23 * 3. Neither the name of STMicroelectronics nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 ******************************************************************************
41 /* Includes ------------------------------------------------------------------*/
42 #include "stm32f30x_dbgmcu.h"
44 /** @addtogroup STM32F30x_StdPeriph_Driver
49 * @brief DBGMCU driver modules
53 /* Private typedef -----------------------------------------------------------*/
54 /* Private define ------------------------------------------------------------*/
55 #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF)
57 /* Private macro -------------------------------------------------------------*/
58 /* Private variables ---------------------------------------------------------*/
59 /* Private function prototypes -----------------------------------------------*/
60 /* Private functions ---------------------------------------------------------*/
62 /** @defgroup DBGMCU_Private_Functions
66 /** @defgroup DBGMCU_Group1 Device and Revision ID management functions
67 * @brief Device and Revision ID management functions
70 ==============================================================================
71 ##### Device and Revision ID management functions #####
72 ==============================================================================
79 * @brief Returns the device revision identifier.
81 * @retval Device revision identifier
83 uint32_t DBGMCU_GetREVID(void)
85 return(DBGMCU->IDCODE >> 16);
89 * @brief Returns the device identifier.
91 * @retval Device identifier
93 uint32_t DBGMCU_GetDEVID(void)
95 return(DBGMCU->IDCODE & IDCODE_DEVID_MASK);
102 /** @defgroup DBGMCU_Group2 Peripherals Configuration functions
103 * @brief Peripherals Configuration
106 ==============================================================================
107 ##### Peripherals Configuration functions #####
108 ==============================================================================
115 * @brief Configures low power mode behavior when the MCU is in Debug mode.
116 * @param DBGMCU_Periph: specifies the low power mode.
117 * This parameter can be any combination of the following values:
118 * @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode.
119 * @arg DBGMCU_STOP: Keep debugger connection during STOP mode.
120 * @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode.
121 * @param NewState: new state of the specified low power mode in Debug mode.
122 * This parameter can be: ENABLE or DISABLE.
125 void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState)
127 /* Check the parameters */
128 assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph));
129 assert_param(IS_FUNCTIONAL_STATE(NewState));
130 if (NewState != DISABLE)
132 DBGMCU->CR |= DBGMCU_Periph;
136 DBGMCU->CR &= ~DBGMCU_Periph;
141 * @brief Configures APB1 peripheral behavior when the MCU is in Debug mode.
142 * @param DBGMCU_Periph: specifies the APB1 peripheral.
143 * This parameter can be any combination of the following values:
144 * @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted.
145 * @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted.
146 * @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted.
147 * @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted.
148 * @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted.
149 * @arg DBGMCU_RTC_STOP: RTC Calendar and Wakeup counter are stopped when
151 * @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted.
152 * @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted.
153 * @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when
155 * @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when
157 * @arg DBGMCU_CAN1_STOP: Debug CAN2 stopped when Core is halted.
158 * @param NewState: new state of the specified APB1 peripheral in Debug mode.
159 * This parameter can be: ENABLE or DISABLE.
162 void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)
164 /* Check the parameters */
165 assert_param(IS_DBGMCU_APB1PERIPH(DBGMCU_Periph));
166 assert_param(IS_FUNCTIONAL_STATE(NewState));
168 if (NewState != DISABLE)
170 DBGMCU->APB1FZ |= DBGMCU_Periph;
174 DBGMCU->APB1FZ &= ~DBGMCU_Periph;
179 * @brief Configures APB2 peripheral behavior when the MCU is in Debug mode.
180 * @param DBGMCU_Periph: specifies the APB2 peripheral.
181 * This parameter can be any combination of the following values:
182 * @arg DBGMCU_TIM1_STOP: TIM1 counter stopped when Core is halted.
183 * @arg DBGMCU_TIM8_STOP: TIM8 counter stopped when Core is halted.
184 * @arg DBGMCU_TIM15_STOP: TIM15 counter stopped when Core is halted.
185 * @arg DBGMCU_TIM16_STOP: TIM16 counter stopped when Core is halted.
186 * @arg DBGMCU_TIM17_STOP: TIM17 counter stopped when Core is halted.
187 * @param NewState: new state of the specified APB2 peripheral in Debug mode.
188 * This parameter can be: ENABLE or DISABLE.
191 void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)
193 /* Check the parameters */
194 assert_param(IS_DBGMCU_APB2PERIPH(DBGMCU_Periph));
195 assert_param(IS_FUNCTIONAL_STATE(NewState));
197 if (NewState != DISABLE)
199 DBGMCU->APB2FZ |= DBGMCU_Periph;
203 DBGMCU->APB2FZ &= ~DBGMCU_Periph;
223 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/