]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_STM32L152_Discovery_IAR/ST_Code/Libraries/STM32L1xx_StdPeriph_Driver/src/stm32l1xx_dbgmcu.c
bc720c6eebfe1d8bec7641839ab6d51ee6f82373
[freertos] / FreeRTOS / Demo / CORTEX_STM32L152_Discovery_IAR / ST_Code / Libraries / STM32L1xx_StdPeriph_Driver / src / stm32l1xx_dbgmcu.c
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32l1xx_dbgmcu.c\r
4   * @author  MCD Application Team\r
5   * @version V1.1.1\r
6   * @date    05-March-2012\r
7   * @brief   This file provides all the DBGMCU firmware functions.\r
8   ******************************************************************************\r
9   * @attention\r
10   *\r
11   * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>\r
12   *\r
13   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");\r
14   * You may not use this file except in compliance with the License.\r
15   * You may obtain a copy of the License at:\r
16   *\r
17   *        http://www.st.com/software_license_agreement_liberty_v2\r
18   *\r
19   * Unless required by applicable law or agreed to in writing, software \r
20   * distributed under the License is distributed on an "AS IS" BASIS, \r
21   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
22   * See the License for the specific language governing permissions and\r
23   * limitations under the License.\r
24   *\r
25   ******************************************************************************\r
26   */\r
27 \r
28 /* Includes ------------------------------------------------------------------*/\r
29 #include "stm32l1xx_dbgmcu.h"\r
30 \r
31 /** @addtogroup STM32L1xx_StdPeriph_Driver\r
32   * @{\r
33   */\r
34 \r
35 /** @defgroup DBGMCU \r
36   * @brief DBGMCU driver modules\r
37   * @{\r
38   */ \r
39 \r
40 /* Private typedef -----------------------------------------------------------*/\r
41 /* Private define ------------------------------------------------------------*/\r
42 #define IDCODE_DEVID_MASK    ((uint32_t)0x00000FFF)\r
43 \r
44 /* Private macro -------------------------------------------------------------*/\r
45 /* Private variables ---------------------------------------------------------*/\r
46 /* Private function prototypes -----------------------------------------------*/\r
47 /* Private functions ---------------------------------------------------------*/\r
48 \r
49 /** @defgroup DBGMCU_Private_Functions\r
50   * @{\r
51   */\r
52 \r
53 /**\r
54   * @brief  Returns the device revision identifier.\r
55   * @param  None\r
56   * @retval Device revision identifier\r
57   */\r
58 uint32_t DBGMCU_GetREVID(void)\r
59 {\r
60    return(DBGMCU->IDCODE >> 16);\r
61 }\r
62 \r
63 /**\r
64   * @brief  Returns the device identifier.\r
65   * @param  None\r
66   * @retval Device identifier\r
67   */\r
68 uint32_t DBGMCU_GetDEVID(void)\r
69 {\r
70    return(DBGMCU->IDCODE & IDCODE_DEVID_MASK);\r
71 }\r
72 \r
73 /**\r
74   * @brief  Configures low power mode behavior when the MCU is in Debug mode.\r
75   * @param  DBGMCU_Periph: specifies the low power mode.\r
76   *   This parameter can be any combination of the following values:\r
77   *     @arg DBGMCU_SLEEP: Keep debugger connection during SLEEP mode\r
78   *     @arg DBGMCU_STOP: Keep debugger connection during STOP mode\r
79   *     @arg DBGMCU_STANDBY: Keep debugger connection during STANDBY mode\r
80   * @param  NewState: new state of the specified low power mode in Debug mode.\r
81   *   This parameter can be: ENABLE or DISABLE.\r
82   * @retval None\r
83   */\r
84 void DBGMCU_Config(uint32_t DBGMCU_Periph, FunctionalState NewState)\r
85 {\r
86   /* Check the parameters */\r
87   assert_param(IS_DBGMCU_PERIPH(DBGMCU_Periph));\r
88   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
89 \r
90   if (NewState != DISABLE)\r
91   {\r
92     DBGMCU->CR |= DBGMCU_Periph;\r
93   }\r
94   else\r
95   {\r
96     DBGMCU->CR &= ~DBGMCU_Periph;\r
97   }\r
98 }\r
99 \r
100 \r
101 /**\r
102   * @brief  Configures APB1 peripheral behavior when the MCU is in Debug mode.\r
103   * @param  DBGMCU_Periph: specifies the APB1 peripheral.\r
104   *   This parameter can be any combination of the following values:\r
105   *     @arg DBGMCU_TIM2_STOP: TIM2 counter stopped when Core is halted\r
106   *     @arg DBGMCU_TIM3_STOP: TIM3 counter stopped when Core is halted\r
107   *     @arg DBGMCU_TIM4_STOP: TIM4 counter stopped when Core is halted\r
108   *     @arg DBGMCU_TIM5_STOP: TIM5 counter stopped when Core is halted  \r
109   *     @arg DBGMCU_TIM6_STOP: TIM6 counter stopped when Core is halted\r
110   *     @arg DBGMCU_TIM7_STOP: TIM7 counter stopped when Core is halted\r
111   *     @arg DBGMCU_RTC_STOP:\r
112   *       + On STM32L1xx Medium-density devices: RTC Wakeup counter stopped when \r
113   *         Core is halted.\r
114   *       + On STM32L1xx High-density and Medium-density Plus devices: RTC Calendar \r
115   *         and Wakeup counter stopped when Core is halted.\r
116   *     @arg DBGMCU_WWDG_STOP: Debug WWDG stopped when Core is halted\r
117   *     @arg DBGMCU_IWDG_STOP: Debug IWDG stopped when Core is halted\r
118   *     @arg DBGMCU_I2C1_SMBUS_TIMEOUT: I2C1 SMBUS timeout mode stopped when Core is \r
119   *                                     halted\r
120   *     @arg DBGMCU_I2C2_SMBUS_TIMEOUT: I2C2 SMBUS timeout mode stopped when Core is \r
121   *                                     halted\r
122   * @param  NewState: new state of the specified APB1 peripheral in Debug mode.\r
123   *   This parameter can be: ENABLE or DISABLE.\r
124   * @retval None\r
125   */\r
126 void DBGMCU_APB1PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)\r
127 {\r
128   /* Check the parameters */\r
129   assert_param(IS_DBGMCU_APB1PERIPH(DBGMCU_Periph));\r
130   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
131 \r
132   if (NewState != DISABLE)\r
133   {\r
134     DBGMCU->APB1FZ |= DBGMCU_Periph;\r
135   }\r
136   else\r
137   {\r
138     DBGMCU->APB1FZ &= ~DBGMCU_Periph;\r
139   }\r
140 }\r
141 \r
142 /**\r
143   * @brief  Configures APB2 peripheral behavior when the MCU is in Debug mode.\r
144   * @param  DBGMCU_Periph: specifies the APB2 peripheral.\r
145   *   This parameter can be any combination of the following values:\r
146   *     @arg DBGMCU_TIM9_STOP: TIM9 counter stopped when Core is halted\r
147   *     @arg DBGMCU_TIM10_STOP: TIM10 counter stopped when Core is halted\r
148   *     @arg DBGMCU_TIM11_STOP: TIM11 counter stopped when Core is halted\r
149   * @param  NewState: new state of the specified APB2 peripheral in Debug mode.\r
150   *   This parameter can be: ENABLE or DISABLE.\r
151   * @retval None\r
152   */\r
153 void DBGMCU_APB2PeriphConfig(uint32_t DBGMCU_Periph, FunctionalState NewState)\r
154 {\r
155   /* Check the parameters */\r
156   assert_param(IS_DBGMCU_APB2PERIPH(DBGMCU_Periph));\r
157   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
158 \r
159   if (NewState != DISABLE)\r
160   {\r
161     DBGMCU->APB2FZ |= DBGMCU_Periph;\r
162   }\r
163   else\r
164   {\r
165     DBGMCU->APB2FZ &= ~DBGMCU_Periph;\r
166   }\r
167 }\r
168 \r
169 /**\r
170   * @}\r
171   */\r
172 \r
173 /**\r
174   * @}\r
175   */\r
176 \r
177 /**\r
178   * @}\r
179   */\r
180 \r
181 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r