Merge pull request #93 from zyp/master
[fw/stlink] / example / libs_stm / src / stm32l1xx / stm32l1xx_dbgmcu.c
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32l1xx_dbgmcu.c\r
4   * @author  MCD Application Team\r
5   * @version V1.0.0\r
6   * @date    31-December-2010\r
7   * @brief   This file provides all the DBGMCU firmware functions.\r
8   ******************************************************************************\r
9   * @attention\r
10   *\r
11   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS\r
12   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE\r
13   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY\r
14   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING\r
15   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE\r
16   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.\r
17   *\r
18   * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>\r
19   ******************************************************************************  \r
20   */ \r
21 \r
22 /* Includes ------------------------------------------------------------------*/\r
23 #include "stm32l1xx_dbgmcu.h"\r
24 \r
25 /** @addtogroup STM32L1xx_StdPeriph_Driver\r
26   * @{\r
27   */\r
28 \r
29 /** @defgroup DBGMCU \r
30   * @brief DBGMCU driver modules\r
31   * @{\r
32   */ \r
33 \r
34 /* Private typedef -----------------------------------------------------------*/\r
35 /* Private define ------------------------------------------------------------*/\r
36 #define IDCODE_DEVID_MASK    ((uint32_t)0x00000FFF)\r
37 \r
38 /* Private macro -------------------------------------------------------------*/\r
39 /* Private variables ---------------------------------------------------------*/\r
40 /* Private function prototypes -----------------------------------------------*/\r
41 /* Private functions ---------------------------------------------------------*/\r
42 \r
43 /** @defgroup DBGMCU_Private_Functions\r
44   * @{\r
45   */\r
46 \r
47 /**\r
48   * @brief  Returns the device revision identifier.\r
49   * @param  None\r
50   * @retval Device revision identifier\r
51   */\r
52 uint32_t DBGMCU_GetREVID(void)\r
53 {\r
54    return(DBGMCU->IDCODE >> 16);\r
55 }\r
56 \r
57 /**\r
58   * @brief  Returns the device identifier.\r
59   * @param  None\r
60   * @retval Device identifier\r
61   */\r
62 uint32_t DBGMCU_GetDEVID(void)\r
63 {\r
64    return(DBGMCU->IDCODE & IDCODE_DEVID_MASK);\r
65 }\r
66 \r
67 /**\r
68   * @brief  Configures low power mode behavior when the MCU is in Debug mode.\r
69   * @param  DBGMCU_Periph: specifies the low power mode.\r
70   *   This parameter can be any combination of the following values:\r
71   *     @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode              \r
72   *     @arg DBGMCU_STOP: Keep debugger connection during STOP mode               \r
73   *     @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode                    \r
74   * @param  NewState: new state of the specified low power mode in Debug mode.\r
75   *   This parameter can be: ENABLE or DISABLE.\r
76   * @retval None\r
77   */\r
78 void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState)\r
79 {\r
80   /* Check the parameters */\r
81   assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph));\r
82   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
83 \r
84   if (NewState != DISABLE)\r
85   {\r
86     DBGMCU->CR |= DBGMCU_Periph;\r
87   }\r
88   else\r
89   {\r
90     DBGMCU->CR &= ~DBGMCU_Periph;\r
91   }\r
92 }\r
93 \r
94 \r
95 /**\r
96   * @brief  Configures APB1 peripheral behavior when the MCU is in Debug mode.\r
97   * @param  DBGMCU_Periph: specifies the APB1 peripheral.\r
98   *   This parameter can be any combination of the following values:\r
99   *     @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted              \r
100   *     @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted               \r
101   *     @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted\r
102   *     @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted\r
103   *     @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted\r
104   *     @arg DBGMCU_RTC_STOP: RTC Wakeup counter stopped when Core is halted  \r
105   *     @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted\r
106   *     @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted\r
107   *     @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is \r
108   *                                     halted\r
109   *     @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is \r
110   *                                     halted                               \r
111   * @param  NewState: new state of the specified APB1 peripheral in Debug mode.\r
112   *   This parameter can be: ENABLE or DISABLE.\r
113   * @retval None\r
114   */\r
115 void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)\r
116 {\r
117   /* Check the parameters */\r
118   assert_param(IS_DBGMCU_APB1PERIPH(DBGMCU_Periph));\r
119   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
120 \r
121   if (NewState != DISABLE)\r
122   {\r
123     DBGMCU->APB1FZ |= DBGMCU_Periph;\r
124   }\r
125   else\r
126   {\r
127     DBGMCU->APB1FZ &= ~DBGMCU_Periph;\r
128   }\r
129 }\r
130 \r
131 /**\r
132   * @brief  Configures APB2 peripheral behavior when the MCU is in Debug mode.\r
133   * @param  DBGMCU_Periph: specifies the APB2 peripheral.\r
134   *   This parameter can be any combination of the following values:\r
135   *     @arg DBGMCU_TIM9_STOP: TIM9 counter stopped when Core is halted              \r
136   *     @arg DBGMCU_TIM10_STOP: TIM10 counter stopped when Core is halted               \r
137   *     @arg DBGMCU_TIM11_STOP: TIM11 counter stopped when Core is halted                              \r
138   * @param  NewState: new state of the specified APB2 peripheral in Debug mode.\r
139   *   This parameter can be: ENABLE or DISABLE.\r
140   * @retval None\r
141   */\r
142 void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)\r
143 {\r
144   /* Check the parameters */\r
145   assert_param(IS_DBGMCU_APB2PERIPH(DBGMCU_Periph));\r
146   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
147 \r
148   if (NewState != DISABLE)\r
149   {\r
150     DBGMCU->APB2FZ |= DBGMCU_Periph;\r
151   }\r
152   else\r
153   {\r
154     DBGMCU->APB2FZ &= ~DBGMCU_Periph;\r
155   }\r
156 }\r
157 \r
158 /**\r
159   * @}\r
160   */\r
161 \r
162 /**\r
163   * @}\r
164   */\r
165 \r
166 /**\r
167   * @}\r
168   */\r
169 \r
170 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/\r