]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F3XX/stm32f30x_dbgmcu.c
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F3XX / stm32f30x_dbgmcu.c
1 /**
2   ******************************************************************************
3   * @file    stm32f30x_dbgmcu.c
4   * @author  MCD Application Team
5   * @version V1.1.0
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   ******************************************************************************
12   * @attention
13   *
14   * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
15   *
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.
26   *
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.
37   *
38   ******************************************************************************
39   */
40
41 /* Includes ------------------------------------------------------------------*/
42 #include "stm32f30x_dbgmcu.h"
43
44 /** @addtogroup STM32F30x_StdPeriph_Driver
45   * @{
46   */
47
48 /** @defgroup DBGMCU 
49   * @brief DBGMCU driver modules
50   * @{
51   */ 
52
53 /* Private typedef -----------------------------------------------------------*/
54 /* Private define ------------------------------------------------------------*/
55 #define IDCODE_DEVID_MASK    ((uint32_t)0x00000FFF)
56
57 /* Private macro -------------------------------------------------------------*/
58 /* Private variables ---------------------------------------------------------*/
59 /* Private function prototypes -----------------------------------------------*/
60 /* Private functions ---------------------------------------------------------*/
61
62 /** @defgroup DBGMCU_Private_Functions
63   * @{
64   */ 
65
66 /** @defgroup DBGMCU_Group1 Device and Revision ID management functions
67  *  @brief   Device and Revision ID management functions
68  *
69 @verbatim
70   ==============================================================================
71             ##### Device and Revision ID management functions #####
72   ==============================================================================
73
74 @endverbatim
75   * @{
76   */
77
78 /**
79   * @brief  Returns the device revision identifier.
80   * @param  None
81   * @retval Device revision identifier
82   */
83 uint32_t DBGMCU_GetREVID(void)
84 {
85    return(DBGMCU->IDCODE >> 16);
86 }
87
88 /**
89   * @brief   Returns the device identifier.
90   * @param  None
91   * @retval Device identifier
92   */
93 uint32_t DBGMCU_GetDEVID(void)
94 {
95    return(DBGMCU->IDCODE & IDCODE_DEVID_MASK);
96 }
97
98 /**
99   * @}
100   */
101   
102 /** @defgroup DBGMCU_Group2 Peripherals Configuration functions
103  *  @brief   Peripherals Configuration
104  *
105 @verbatim
106   ==============================================================================
107                ##### Peripherals Configuration functions #####
108   ==============================================================================
109
110 @endverbatim
111   * @{
112   */
113
114 /**
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.
123   * @retval None
124   */
125 void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState)
126 {
127   /* Check the parameters */
128   assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph));
129   assert_param(IS_FUNCTIONAL_STATE(NewState));
130   if (NewState != DISABLE)
131   {
132     DBGMCU->CR |= DBGMCU_Periph;
133   }
134   else
135   {
136     DBGMCU->CR &= ~DBGMCU_Periph;
137   }
138 }
139
140 /**
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 
150   *          Core is halted. 
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 
154   *          Core is halted.
155   *     @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when 
156   *          Core is halted.
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.
160   * @retval None
161   */
162 void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)
163 {
164   /* Check the parameters */
165   assert_param(IS_DBGMCU_APB1PERIPH(DBGMCU_Periph));
166   assert_param(IS_FUNCTIONAL_STATE(NewState));
167
168   if (NewState != DISABLE)
169   {
170     DBGMCU->APB1FZ |= DBGMCU_Periph;
171   }
172   else
173   {
174     DBGMCU->APB1FZ &= ~DBGMCU_Periph;
175   }
176 }
177
178 /**
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.
189   * @retval None
190   */
191 void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)
192 {
193   /* Check the parameters */
194   assert_param(IS_DBGMCU_APB2PERIPH(DBGMCU_Periph));
195   assert_param(IS_FUNCTIONAL_STATE(NewState));
196
197   if (NewState != DISABLE)
198   {
199     DBGMCU->APB2FZ |= DBGMCU_Periph;
200   }
201   else
202   {
203     DBGMCU->APB2FZ &= ~DBGMCU_Periph;
204   }
205 }
206
207 /**
208   * @}
209   */ 
210
211 /**
212   * @}
213   */ 
214
215 /**
216   * @}
217   */ 
218
219 /**
220   * @}
221   */ 
222   
223 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/