stm32f1xx_hal.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  11. *
  12. * Redistribution and use in source and binary forms, with or without modification,
  13. * are permitted provided that the following conditions are met:
  14. * 1. Redistributions of source code must retain the above copyright notice,
  15. * this list of conditions and the following disclaimer.
  16. * 2. Redistributions in binary form must reproduce the above copyright notice,
  17. * this list of conditions and the following disclaimer in the documentation
  18. * and/or other materials provided with the distribution.
  19. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  20. * may be used to endorse or promote products derived from this software
  21. * without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  27. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  29. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  30. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  31. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  32. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. ******************************************************************************
  35. */
  36. /* Define to prevent recursive inclusion -------------------------------------*/
  37. #ifndef __STM32F1xx_HAL_H
  38. #define __STM32F1xx_HAL_H
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. /* Includes ------------------------------------------------------------------*/
  43. #include "stm32f1xx_hal_conf.h"
  44. /** @addtogroup STM32F1xx_HAL_Driver
  45. * @{
  46. */
  47. /** @addtogroup HAL
  48. * @{
  49. */
  50. /* Exported constants --------------------------------------------------------*/
  51. /** @defgroup HAL_Exported_Constants HAL Exported Constants
  52. * @{
  53. */
  54. /** @defgroup HAL_TICK_FREQ Tick Frequency
  55. * @{
  56. */
  57. typedef enum
  58. {
  59. HAL_TICK_FREQ_10HZ = 100U,
  60. HAL_TICK_FREQ_100HZ = 10U,
  61. HAL_TICK_FREQ_1KHZ = 1U,
  62. HAL_TICK_FREQ_DEFAULT = HAL_TICK_FREQ_1KHZ
  63. } HAL_TickFreqTypeDef;
  64. /**
  65. * @}
  66. */
  67. /* Exported types ------------------------------------------------------------*/
  68. extern uint32_t uwTickPrio;
  69. extern HAL_TickFreqTypeDef uwTickFreq;
  70. /**
  71. * @}
  72. */
  73. /* Exported macro ------------------------------------------------------------*/
  74. /** @defgroup HAL_Exported_Macros HAL Exported Macros
  75. * @{
  76. */
  77. /** @defgroup DBGMCU_Freeze_Unfreeze Freeze Unfreeze Peripherals in Debug mode
  78. * @brief Freeze/Unfreeze Peripherals in Debug mode
  79. * Note: On devices STM32F10xx8 and STM32F10xxB,
  80. * STM32F101xC/D/E and STM32F103xC/D/E,
  81. * STM32F101xF/G and STM32F103xF/G
  82. * STM32F10xx4 and STM32F10xx6
  83. * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
  84. * debug mode (not accessible by the user software in normal mode).
  85. * Refer to errata sheet of these devices for more details.
  86. * @{
  87. */
  88. /* Peripherals on APB1 */
  89. /**
  90. * @brief TIM2 Peripherals Debug mode
  91. */
  92. #define __HAL_DBGMCU_FREEZE_TIM2() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM2_STOP)
  93. #define __HAL_DBGMCU_UNFREEZE_TIM2() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM2_STOP)
  94. /**
  95. * @brief TIM3 Peripherals Debug mode
  96. */
  97. #define __HAL_DBGMCU_FREEZE_TIM3() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM3_STOP)
  98. #define __HAL_DBGMCU_UNFREEZE_TIM3() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM3_STOP)
  99. #if defined (DBGMCU_CR_DBG_TIM4_STOP)
  100. /**
  101. * @brief TIM4 Peripherals Debug mode
  102. */
  103. #define __HAL_DBGMCU_FREEZE_TIM4() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM4_STOP)
  104. #define __HAL_DBGMCU_UNFREEZE_TIM4() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM4_STOP)
  105. #endif
  106. #if defined (DBGMCU_CR_DBG_TIM5_STOP)
  107. /**
  108. * @brief TIM5 Peripherals Debug mode
  109. */
  110. #define __HAL_DBGMCU_FREEZE_TIM5() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM5_STOP)
  111. #define __HAL_DBGMCU_UNFREEZE_TIM5() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM5_STOP)
  112. #endif
  113. #if defined (DBGMCU_CR_DBG_TIM6_STOP)
  114. /**
  115. * @brief TIM6 Peripherals Debug mode
  116. */
  117. #define __HAL_DBGMCU_FREEZE_TIM6() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM6_STOP)
  118. #define __HAL_DBGMCU_UNFREEZE_TIM6() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM6_STOP)
  119. #endif
  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. #if defined (DBGMCU_CR_DBG_TIM12_STOP)
  128. /**
  129. * @brief TIM12 Peripherals Debug mode
  130. */
  131. #define __HAL_DBGMCU_FREEZE_TIM12() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM12_STOP)
  132. #define __HAL_DBGMCU_UNFREEZE_TIM12() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM12_STOP)
  133. #endif
  134. #if defined (DBGMCU_CR_DBG_TIM13_STOP)
  135. /**
  136. * @brief TIM13 Peripherals Debug mode
  137. */
  138. #define __HAL_DBGMCU_FREEZE_TIM13() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM13_STOP)
  139. #define __HAL_DBGMCU_UNFREEZE_TIM13() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM13_STOP)
  140. #endif
  141. #if defined (DBGMCU_CR_DBG_TIM14_STOP)
  142. /**
  143. * @brief TIM14 Peripherals Debug mode
  144. */
  145. #define __HAL_DBGMCU_FREEZE_TIM14() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM14_STOP)
  146. #define __HAL_DBGMCU_UNFREEZE_TIM14() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM14_STOP)
  147. #endif
  148. /**
  149. * @brief WWDG Peripherals Debug mode
  150. */
  151. #define __HAL_DBGMCU_FREEZE_WWDG() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_WWDG_STOP)
  152. #define __HAL_DBGMCU_UNFREEZE_WWDG() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_WWDG_STOP)
  153. /**
  154. * @brief IWDG Peripherals Debug mode
  155. */
  156. #define __HAL_DBGMCU_FREEZE_IWDG() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_IWDG_STOP)
  157. #define __HAL_DBGMCU_UNFREEZE_IWDG() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_IWDG_STOP)
  158. /**
  159. * @brief I2C1 Peripherals Debug mode
  160. */
  161. #define __HAL_DBGMCU_FREEZE_I2C1_TIMEOUT() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C1_SMBUS_TIMEOUT)
  162. #define __HAL_DBGMCU_UNFREEZE_I2C1_TIMEOUT() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C1_SMBUS_TIMEOUT)
  163. #if defined (DBGMCU_CR_DBG_I2C2_SMBUS_TIMEOUT)
  164. /**
  165. * @brief I2C2 Peripherals Debug mode
  166. */
  167. #define __HAL_DBGMCU_FREEZE_I2C2_TIMEOUT() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C2_SMBUS_TIMEOUT)
  168. #define __HAL_DBGMCU_UNFREEZE_I2C2_TIMEOUT() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C2_SMBUS_TIMEOUT)
  169. #endif
  170. #if defined (DBGMCU_CR_DBG_CAN1_STOP)
  171. /**
  172. * @brief CAN1 Peripherals Debug mode
  173. */
  174. #define __HAL_DBGMCU_FREEZE_CAN1() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN1_STOP)
  175. #define __HAL_DBGMCU_UNFREEZE_CAN1() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN1_STOP)
  176. #endif
  177. #if defined (DBGMCU_CR_DBG_CAN2_STOP)
  178. /**
  179. * @brief CAN2 Peripherals Debug mode
  180. */
  181. #define __HAL_DBGMCU_FREEZE_CAN2() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN2_STOP)
  182. #define __HAL_DBGMCU_UNFREEZE_CAN2() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN2_STOP)
  183. #endif
  184. /* Peripherals on APB2 */
  185. #if defined (DBGMCU_CR_DBG_TIM1_STOP)
  186. /**
  187. * @brief TIM1 Peripherals Debug mode
  188. */
  189. #define __HAL_DBGMCU_FREEZE_TIM1() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM1_STOP)
  190. #define __HAL_DBGMCU_UNFREEZE_TIM1() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM1_STOP)
  191. #endif
  192. #if defined (DBGMCU_CR_DBG_TIM8_STOP)
  193. /**
  194. * @brief TIM8 Peripherals Debug mode
  195. */
  196. #define __HAL_DBGMCU_FREEZE_TIM8() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM8_STOP)
  197. #define __HAL_DBGMCU_UNFREEZE_TIM8() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM8_STOP)
  198. #endif
  199. #if defined (DBGMCU_CR_DBG_TIM9_STOP)
  200. /**
  201. * @brief TIM9 Peripherals Debug mode
  202. */
  203. #define __HAL_DBGMCU_FREEZE_TIM9() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM9_STOP)
  204. #define __HAL_DBGMCU_UNFREEZE_TIM9() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM9_STOP)
  205. #endif
  206. #if defined (DBGMCU_CR_DBG_TIM10_STOP)
  207. /**
  208. * @brief TIM10 Peripherals Debug mode
  209. */
  210. #define __HAL_DBGMCU_FREEZE_TIM10() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM10_STOP)
  211. #define __HAL_DBGMCU_UNFREEZE_TIM10() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM10_STOP)
  212. #endif
  213. #if defined (DBGMCU_CR_DBG_TIM11_STOP)
  214. /**
  215. * @brief TIM11 Peripherals Debug mode
  216. */
  217. #define __HAL_DBGMCU_FREEZE_TIM11() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM11_STOP)
  218. #define __HAL_DBGMCU_UNFREEZE_TIM11() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM11_STOP)
  219. #endif
  220. #if defined (DBGMCU_CR_DBG_TIM15_STOP)
  221. /**
  222. * @brief TIM15 Peripherals Debug mode
  223. */
  224. #define __HAL_DBGMCU_FREEZE_TIM15() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM15_STOP)
  225. #define __HAL_DBGMCU_UNFREEZE_TIM15() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM15_STOP)
  226. #endif
  227. #if defined (DBGMCU_CR_DBG_TIM16_STOP)
  228. /**
  229. * @brief TIM16 Peripherals Debug mode
  230. */
  231. #define __HAL_DBGMCU_FREEZE_TIM16() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM16_STOP)
  232. #define __HAL_DBGMCU_UNFREEZE_TIM16() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM16_STOP)
  233. #endif
  234. #if defined (DBGMCU_CR_DBG_TIM17_STOP)
  235. /**
  236. * @brief TIM17 Peripherals Debug mode
  237. */
  238. #define __HAL_DBGMCU_FREEZE_TIM17() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM17_STOP)
  239. #define __HAL_DBGMCU_UNFREEZE_TIM17() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM17_STOP)
  240. #endif
  241. /**
  242. * @}
  243. */
  244. /** @defgroup HAL_Private_Macros HAL Private Macros
  245. * @{
  246. */
  247. #define IS_TICKFREQ(FREQ) (((FREQ) == HAL_TICK_FREQ_10HZ) || \
  248. ((FREQ) == HAL_TICK_FREQ_100HZ) || \
  249. ((FREQ) == HAL_TICK_FREQ_1KHZ))
  250. /**
  251. * @}
  252. */
  253. /* Exported functions --------------------------------------------------------*/
  254. /** @addtogroup HAL_Exported_Functions
  255. * @{
  256. */
  257. /** @addtogroup HAL_Exported_Functions_Group1
  258. * @{
  259. */
  260. /* Initialization and de-initialization functions ******************************/
  261. HAL_StatusTypeDef HAL_Init(void);
  262. HAL_StatusTypeDef HAL_DeInit(void);
  263. void HAL_MspInit(void);
  264. void HAL_MspDeInit(void);
  265. HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority);
  266. /**
  267. * @}
  268. */
  269. /** @addtogroup HAL_Exported_Functions_Group2
  270. * @{
  271. */
  272. /* Peripheral Control functions ************************************************/
  273. void HAL_IncTick(void);
  274. void HAL_Delay(uint32_t Delay);
  275. uint32_t HAL_GetTick(void);
  276. uint32_t HAL_GetTickPrio(void);
  277. HAL_StatusTypeDef HAL_SetTickFreq(HAL_TickFreqTypeDef Freq);
  278. HAL_TickFreqTypeDef HAL_GetTickFreq(void);
  279. void HAL_SuspendTick(void);
  280. void HAL_ResumeTick(void);
  281. uint32_t HAL_GetHalVersion(void);
  282. uint32_t HAL_GetREVID(void);
  283. uint32_t HAL_GetDEVID(void);
  284. void HAL_DBGMCU_EnableDBGSleepMode(void);
  285. void HAL_DBGMCU_DisableDBGSleepMode(void);
  286. void HAL_DBGMCU_EnableDBGStopMode(void);
  287. void HAL_DBGMCU_DisableDBGStopMode(void);
  288. void HAL_DBGMCU_EnableDBGStandbyMode(void);
  289. void HAL_DBGMCU_DisableDBGStandbyMode(void);
  290. void HAL_GetUID(uint32_t *UID);
  291. /**
  292. * @}
  293. */
  294. /**
  295. * @}
  296. */
  297. /* Private types -------------------------------------------------------------*/
  298. /* Private variables ---------------------------------------------------------*/
  299. /** @defgroup HAL_Private_Variables HAL Private Variables
  300. * @{
  301. */
  302. /**
  303. * @}
  304. */
  305. /* Private constants ---------------------------------------------------------*/
  306. /** @defgroup HAL_Private_Constants HAL Private Constants
  307. * @{
  308. */
  309. /**
  310. * @}
  311. */
  312. /* Private macros ------------------------------------------------------------*/
  313. /* Private functions ---------------------------------------------------------*/
  314. /**
  315. * @}
  316. */
  317. /**
  318. * @}
  319. */
  320. #ifdef __cplusplus
  321. }
  322. #endif
  323. #endif /* __STM32F1xx_HAL_H */
  324. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/