1 /**
2   ******************************************************************************
3   * @file    stm32f1xx_hal.h
4   * @author  MCD Application Team
5   * @brief   This file contains all the functions prototypes for the HAL
6   *          module driver.
7   ******************************************************************************
8   * @attention
9   *
10   * Copyright (c) 2017 STMicroelectronics.
11   * All rights reserved.
12   *
13   * This software is licensed under terms that can be found in the LICENSE file
14   * in the root directory of this software component.
15   * If no LICENSE file comes with this software, it is provided AS-IS.
16   *
17   ******************************************************************************
18   */
19 
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef __STM32F1xx_HAL_H
22 #define __STM32F1xx_HAL_H
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32f1xx_hal_conf.h"
30 
31 /** @addtogroup STM32F1xx_HAL_Driver
32   * @{
33   */
34 
35 /** @addtogroup HAL
36   * @{
37   */
38 
39 /* Exported constants --------------------------------------------------------*/
40 
41 /** @defgroup HAL_Exported_Constants HAL Exported Constants
42   * @{
43   */
44 
45 /** @defgroup HAL_TICK_FREQ Tick Frequency
46   * @{
47   */
48 typedef enum
49 {
50   HAL_TICK_FREQ_10HZ         = 100U,
51   HAL_TICK_FREQ_100HZ        = 10U,
52   HAL_TICK_FREQ_1KHZ         = 1U,
53   HAL_TICK_FREQ_DEFAULT      = HAL_TICK_FREQ_1KHZ
54 } HAL_TickFreqTypeDef;
55 /**
56   * @}
57   */
58 /* Exported types ------------------------------------------------------------*/
59 extern __IO uint32_t uwTick;
60 extern uint32_t uwTickPrio;
61 extern HAL_TickFreqTypeDef uwTickFreq;
62 
63 /**
64   * @}
65   */
66 /* Exported macro ------------------------------------------------------------*/
67 /** @defgroup HAL_Exported_Macros HAL Exported Macros
68   * @{
69   */
70 
71 /** @defgroup DBGMCU_Freeze_Unfreeze Freeze Unfreeze Peripherals in Debug mode
72   * @brief   Freeze/Unfreeze Peripherals in Debug mode
73   * Note: On devices STM32F10xx8 and STM32F10xxB,
74   *                  STM32F101xC/D/E and STM32F103xC/D/E,
75   *                  STM32F101xF/G and STM32F103xF/G
76   *                  STM32F10xx4 and STM32F10xx6
77   *       Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
78   *       debug mode (not accessible by the user software in normal mode).
79   *       Refer to errata sheet of these devices for more details.
80   * @{
81   */
82 
83 /* Peripherals on APB1 */
84 /**
85   * @brief  TIM2 Peripherals Debug mode
86   */
87 #define __HAL_DBGMCU_FREEZE_TIM2()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM2_STOP)
88 #define __HAL_DBGMCU_UNFREEZE_TIM2()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM2_STOP)
89 
90 /**
91   * @brief  TIM3 Peripherals Debug mode
92   */
93 #define __HAL_DBGMCU_FREEZE_TIM3()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM3_STOP)
94 #define __HAL_DBGMCU_UNFREEZE_TIM3()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM3_STOP)
95 
96 #if defined (DBGMCU_CR_DBG_TIM4_STOP)
97 /**
98   * @brief  TIM4 Peripherals Debug mode
99   */
100 #define __HAL_DBGMCU_FREEZE_TIM4()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM4_STOP)
101 #define __HAL_DBGMCU_UNFREEZE_TIM4()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM4_STOP)
102 #endif
103 
104 #if defined (DBGMCU_CR_DBG_TIM5_STOP)
105 /**
106   * @brief  TIM5 Peripherals Debug mode
107   */
108 #define __HAL_DBGMCU_FREEZE_TIM5()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM5_STOP)
109 #define __HAL_DBGMCU_UNFREEZE_TIM5()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM5_STOP)
110 #endif
111 
112 #if defined (DBGMCU_CR_DBG_TIM6_STOP)
113 /**
114   * @brief  TIM6 Peripherals Debug mode
115   */
116 #define __HAL_DBGMCU_FREEZE_TIM6()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM6_STOP)
117 #define __HAL_DBGMCU_UNFREEZE_TIM6()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM6_STOP)
118 #endif
119 
120 #if defined (DBGMCU_CR_DBG_TIM7_STOP)
121 /**
122   * @brief  TIM7 Peripherals Debug mode
123   */
124 #define __HAL_DBGMCU_FREEZE_TIM7()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM7_STOP)
125 #define __HAL_DBGMCU_UNFREEZE_TIM7()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM7_STOP)
126 #endif
127 
128 #if defined (DBGMCU_CR_DBG_TIM12_STOP)
129 /**
130   * @brief  TIM12 Peripherals Debug mode
131   */
132 #define __HAL_DBGMCU_FREEZE_TIM12()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM12_STOP)
133 #define __HAL_DBGMCU_UNFREEZE_TIM12()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM12_STOP)
134 #endif
135 
136 #if defined (DBGMCU_CR_DBG_TIM13_STOP)
137 /**
138   * @brief  TIM13 Peripherals Debug mode
139   */
140 #define __HAL_DBGMCU_FREEZE_TIM13()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM13_STOP)
141 #define __HAL_DBGMCU_UNFREEZE_TIM13()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM13_STOP)
142 #endif
143 
144 #if defined (DBGMCU_CR_DBG_TIM14_STOP)
145 /**
146   * @brief  TIM14 Peripherals Debug mode
147   */
148 #define __HAL_DBGMCU_FREEZE_TIM14()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM14_STOP)
149 #define __HAL_DBGMCU_UNFREEZE_TIM14()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM14_STOP)
150 #endif
151 
152 /**
153   * @brief  WWDG Peripherals Debug mode
154   */
155 #define __HAL_DBGMCU_FREEZE_WWDG()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_WWDG_STOP)
156 #define __HAL_DBGMCU_UNFREEZE_WWDG()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_WWDG_STOP)
157 
158 /**
159   * @brief  IWDG Peripherals Debug mode
160   */
161 #define __HAL_DBGMCU_FREEZE_IWDG()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_IWDG_STOP)
162 #define __HAL_DBGMCU_UNFREEZE_IWDG()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_IWDG_STOP)
163 
164 /**
165   * @brief  I2C1 Peripherals Debug mode
166   */
167 #define __HAL_DBGMCU_FREEZE_I2C1_TIMEOUT()    SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C1_SMBUS_TIMEOUT)
168 #define __HAL_DBGMCU_UNFREEZE_I2C1_TIMEOUT()  CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C1_SMBUS_TIMEOUT)
169 
170 #if defined (DBGMCU_CR_DBG_I2C2_SMBUS_TIMEOUT)
171 /**
172   * @brief  I2C2 Peripherals Debug mode
173   */
174 #define __HAL_DBGMCU_FREEZE_I2C2_TIMEOUT()    SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C2_SMBUS_TIMEOUT)
175 #define __HAL_DBGMCU_UNFREEZE_I2C2_TIMEOUT()  CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C2_SMBUS_TIMEOUT)
176 #endif
177 
178 #if defined (DBGMCU_CR_DBG_CAN1_STOP)
179 /**
180   * @brief  CAN1 Peripherals Debug mode
181   */
182 #define __HAL_DBGMCU_FREEZE_CAN1()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN1_STOP)
183 #define __HAL_DBGMCU_UNFREEZE_CAN1()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN1_STOP)
184 #endif
185 
186 #if defined (DBGMCU_CR_DBG_CAN2_STOP)
187 /**
188   * @brief  CAN2 Peripherals Debug mode
189   */
190 #define __HAL_DBGMCU_FREEZE_CAN2()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN2_STOP)
191 #define __HAL_DBGMCU_UNFREEZE_CAN2()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN2_STOP)
192 #endif
193 
194 /* Peripherals on APB2 */
195 #if defined (DBGMCU_CR_DBG_TIM1_STOP)
196 /**
197   * @brief  TIM1 Peripherals Debug mode
198   */
199 #define __HAL_DBGMCU_FREEZE_TIM1()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM1_STOP)
200 #define __HAL_DBGMCU_UNFREEZE_TIM1()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM1_STOP)
201 #endif
202 
203 #if defined (DBGMCU_CR_DBG_TIM8_STOP)
204 /**
205   * @brief  TIM8 Peripherals Debug mode
206   */
207 #define __HAL_DBGMCU_FREEZE_TIM8()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM8_STOP)
208 #define __HAL_DBGMCU_UNFREEZE_TIM8()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM8_STOP)
209 #endif
210 
211 #if defined (DBGMCU_CR_DBG_TIM9_STOP)
212 /**
213   * @brief  TIM9 Peripherals Debug mode
214   */
215 #define __HAL_DBGMCU_FREEZE_TIM9()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM9_STOP)
216 #define __HAL_DBGMCU_UNFREEZE_TIM9()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM9_STOP)
217 #endif
218 
219 #if defined (DBGMCU_CR_DBG_TIM10_STOP)
220 /**
221   * @brief  TIM10 Peripherals Debug mode
222   */
223 #define __HAL_DBGMCU_FREEZE_TIM10()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM10_STOP)
224 #define __HAL_DBGMCU_UNFREEZE_TIM10()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM10_STOP)
225 #endif
226 
227 #if defined (DBGMCU_CR_DBG_TIM11_STOP)
228 /**
229   * @brief  TIM11 Peripherals Debug mode
230   */
231 #define __HAL_DBGMCU_FREEZE_TIM11()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM11_STOP)
232 #define __HAL_DBGMCU_UNFREEZE_TIM11()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM11_STOP)
233 #endif
234 
235 
236 #if defined (DBGMCU_CR_DBG_TIM15_STOP)
237 /**
238   * @brief  TIM15 Peripherals Debug mode
239   */
240 #define __HAL_DBGMCU_FREEZE_TIM15()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM15_STOP)
241 #define __HAL_DBGMCU_UNFREEZE_TIM15()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM15_STOP)
242 #endif
243 
244 #if defined (DBGMCU_CR_DBG_TIM16_STOP)
245 /**
246   * @brief  TIM16 Peripherals Debug mode
247   */
248 #define __HAL_DBGMCU_FREEZE_TIM16()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM16_STOP)
249 #define __HAL_DBGMCU_UNFREEZE_TIM16()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM16_STOP)
250 #endif
251 
252 #if defined (DBGMCU_CR_DBG_TIM17_STOP)
253 /**
254   * @brief  TIM17 Peripherals Debug mode
255   */
256 #define __HAL_DBGMCU_FREEZE_TIM17()            SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM17_STOP)
257 #define __HAL_DBGMCU_UNFREEZE_TIM17()          CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM17_STOP)
258 #endif
259 
260 /**
261   * @}
262   */
263 
264 /** @defgroup HAL_Private_Macros HAL Private Macros
265   * @{
266   */
267 #define IS_TICKFREQ(FREQ) (((FREQ) == HAL_TICK_FREQ_10HZ)  || \
268                            ((FREQ) == HAL_TICK_FREQ_100HZ) || \
269                            ((FREQ) == HAL_TICK_FREQ_1KHZ))
270 /**
271   * @}
272   */
273 
274 /* Exported functions --------------------------------------------------------*/
275 /** @addtogroup HAL_Exported_Functions
276   * @{
277   */
278 /** @addtogroup HAL_Exported_Functions_Group1
279   * @{
280   */
281 /* Initialization and de-initialization functions  ******************************/
282 HAL_StatusTypeDef HAL_Init(void);
283 HAL_StatusTypeDef HAL_DeInit(void);
284 void HAL_MspInit(void);
285 void HAL_MspDeInit(void);
286 HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority);
287 /**
288   * @}
289   */
290 
291 /** @addtogroup HAL_Exported_Functions_Group2
292   * @{
293   */
294 /* Peripheral Control functions  ************************************************/
295 void HAL_IncTick(void);
296 void HAL_Delay(uint32_t Delay);
297 uint32_t HAL_GetTick(void);
298 uint32_t HAL_GetTickPrio(void);
299 HAL_StatusTypeDef HAL_SetTickFreq(HAL_TickFreqTypeDef Freq);
300 HAL_TickFreqTypeDef HAL_GetTickFreq(void);
301 void HAL_SuspendTick(void);
302 void HAL_ResumeTick(void);
303 uint32_t HAL_GetHalVersion(void);
304 uint32_t HAL_GetREVID(void);
305 uint32_t HAL_GetDEVID(void);
306 uint32_t HAL_GetUIDw0(void);
307 uint32_t HAL_GetUIDw1(void);
308 uint32_t HAL_GetUIDw2(void);
309 void HAL_DBGMCU_EnableDBGSleepMode(void);
310 void HAL_DBGMCU_DisableDBGSleepMode(void);
311 void HAL_DBGMCU_EnableDBGStopMode(void);
312 void HAL_DBGMCU_DisableDBGStopMode(void);
313 void HAL_DBGMCU_EnableDBGStandbyMode(void);
314 void HAL_DBGMCU_DisableDBGStandbyMode(void);
315 /**
316   * @}
317   */
318 
319 /**
320   * @}
321   */
322 
323 /**
324   * @}
325   */
326 /* Private types -------------------------------------------------------------*/
327 /* Private variables ---------------------------------------------------------*/
328 /** @defgroup HAL_Private_Variables HAL Private Variables
329   * @{
330   */
331 /**
332   * @}
333   */
334 /* Private constants ---------------------------------------------------------*/
335 /** @defgroup HAL_Private_Constants HAL Private Constants
336   * @{
337   */
338 /**
339   * @}
340   */
341 /* Private macros ------------------------------------------------------------*/
342 /* Private functions ---------------------------------------------------------*/
343 /**
344   * @}
345   */
346 
347 /**
348   * @}
349   */
350 
351 #ifdef __cplusplus
352 }
353 #endif
354 
355 #endif /* __STM32F1xx_HAL_H */
356 
357