stm32f1xx_hal.h 12 KB

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