stm32f1xx_hal.h 11 KB

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