stm32f4xx_hal.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal.h
  4. * @author MCD Application Team
  5. * @version V1.6.0
  6. * @date 04-November-2016
  7. * @brief This file contains all the functions prototypes for the HAL
  8. * module driver.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  13. *
  14. * Redistribution and use in source and binary forms, with or without modification,
  15. * are permitted provided that the following conditions are met:
  16. * 1. Redistributions of source code must retain the above copyright notice,
  17. * this list of conditions and the following disclaimer.
  18. * 2. Redistributions in binary form must reproduce the above copyright notice,
  19. * this list of conditions and the following disclaimer in the documentation
  20. * and/or other materials provided with the distribution.
  21. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  22. * may be used to endorse or promote products derived from this software
  23. * without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  26. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  28. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  29. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  30. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  31. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  32. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  33. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. ******************************************************************************
  37. */
  38. /* Define to prevent recursive inclusion -------------------------------------*/
  39. #ifndef __STM32F4xx_HAL_H
  40. #define __STM32F4xx_HAL_H
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif
  44. /* Includes ------------------------------------------------------------------*/
  45. #include "stm32f4xx_hal_conf.h"
  46. /** @addtogroup STM32F4xx_HAL_Driver
  47. * @{
  48. */
  49. /** @addtogroup HAL
  50. * @{
  51. */
  52. /* Exported types ------------------------------------------------------------*/
  53. /* Exported constants --------------------------------------------------------*/
  54. /* Exported macro ------------------------------------------------------------*/
  55. /** @defgroup HAL_Exported_Macros HAL Exported Macros
  56. * @{
  57. */
  58. /** @brief Freeze/Unfreeze Peripherals in Debug mode
  59. */
  60. #define __HAL_DBGMCU_FREEZE_TIM2() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM2_STOP))
  61. #define __HAL_DBGMCU_FREEZE_TIM3() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM3_STOP))
  62. #define __HAL_DBGMCU_FREEZE_TIM4() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM4_STOP))
  63. #define __HAL_DBGMCU_FREEZE_TIM5() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM5_STOP))
  64. #define __HAL_DBGMCU_FREEZE_TIM6() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM6_STOP))
  65. #define __HAL_DBGMCU_FREEZE_TIM7() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM7_STOP))
  66. #define __HAL_DBGMCU_FREEZE_TIM12() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM12_STOP))
  67. #define __HAL_DBGMCU_FREEZE_TIM13() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM13_STOP))
  68. #define __HAL_DBGMCU_FREEZE_TIM14() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_TIM14_STOP))
  69. #define __HAL_DBGMCU_FREEZE_RTC() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_RTC_STOP))
  70. #define __HAL_DBGMCU_FREEZE_WWDG() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_WWDG_STOP))
  71. #define __HAL_DBGMCU_FREEZE_IWDG() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_IWDG_STOP))
  72. #define __HAL_DBGMCU_FREEZE_I2C1_TIMEOUT() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_I2C1_SMBUS_TIMEOUT))
  73. #define __HAL_DBGMCU_FREEZE_I2C2_TIMEOUT() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_I2C2_SMBUS_TIMEOUT))
  74. #define __HAL_DBGMCU_FREEZE_I2C3_TIMEOUT() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_I2C3_SMBUS_TIMEOUT))
  75. #define __HAL_DBGMCU_FREEZE_CAN1() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_CAN1_STOP))
  76. #define __HAL_DBGMCU_FREEZE_CAN2() (DBGMCU->APB1FZ |= (DBGMCU_APB1_FZ_DBG_CAN2_STOP))
  77. #define __HAL_DBGMCU_FREEZE_TIM1() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM1_STOP))
  78. #define __HAL_DBGMCU_FREEZE_TIM8() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM8_STOP))
  79. #define __HAL_DBGMCU_FREEZE_TIM9() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM9_STOP))
  80. #define __HAL_DBGMCU_FREEZE_TIM10() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM10_STOP))
  81. #define __HAL_DBGMCU_FREEZE_TIM11() (DBGMCU->APB2FZ |= (DBGMCU_APB2_FZ_DBG_TIM11_STOP))
  82. #define __HAL_DBGMCU_UNFREEZE_TIM2() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM2_STOP))
  83. #define __HAL_DBGMCU_UNFREEZE_TIM3() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM3_STOP))
  84. #define __HAL_DBGMCU_UNFREEZE_TIM4() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM4_STOP))
  85. #define __HAL_DBGMCU_UNFREEZE_TIM5() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM5_STOP))
  86. #define __HAL_DBGMCU_UNFREEZE_TIM6() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM6_STOP))
  87. #define __HAL_DBGMCU_UNFREEZE_TIM7() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM7_STOP))
  88. #define __HAL_DBGMCU_UNFREEZE_TIM12() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM12_STOP))
  89. #define __HAL_DBGMCU_UNFREEZE_TIM13() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM13_STOP))
  90. #define __HAL_DBGMCU_UNFREEZE_TIM14() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_TIM14_STOP))
  91. #define __HAL_DBGMCU_UNFREEZE_RTC() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_RTC_STOP))
  92. #define __HAL_DBGMCU_UNFREEZE_WWDG() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_WWDG_STOP))
  93. #define __HAL_DBGMCU_UNFREEZE_IWDG() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_IWDG_STOP))
  94. #define __HAL_DBGMCU_UNFREEZE_I2C1_TIMEOUT() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_I2C1_SMBUS_TIMEOUT))
  95. #define __HAL_DBGMCU_UNFREEZE_I2C2_TIMEOUT() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_I2C2_SMBUS_TIMEOUT))
  96. #define __HAL_DBGMCU_UNFREEZE_I2C3_TIMEOUT() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_I2C3_SMBUS_TIMEOUT))
  97. #define __HAL_DBGMCU_UNFREEZE_CAN1() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_CAN1_STOP))
  98. #define __HAL_DBGMCU_UNFREEZE_CAN2() (DBGMCU->APB1FZ &= ~(DBGMCU_APB1_FZ_DBG_CAN2_STOP))
  99. #define __HAL_DBGMCU_UNFREEZE_TIM1() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM1_STOP))
  100. #define __HAL_DBGMCU_UNFREEZE_TIM8() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM8_STOP))
  101. #define __HAL_DBGMCU_UNFREEZE_TIM9() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM9_STOP))
  102. #define __HAL_DBGMCU_UNFREEZE_TIM10() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM10_STOP))
  103. #define __HAL_DBGMCU_UNFREEZE_TIM11() (DBGMCU->APB2FZ &= ~(DBGMCU_APB2_FZ_DBG_TIM11_STOP))
  104. /** @brief Main Flash memory mapped at 0x00000000
  105. */
  106. #define __HAL_SYSCFG_REMAPMEMORY_FLASH() (SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE))
  107. /** @brief System Flash memory mapped at 0x00000000
  108. */
  109. #define __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\
  110. SYSCFG->MEMRMP |= SYSCFG_MEMRMP_MEM_MODE_0;\
  111. }while(0);
  112. /** @brief Embedded SRAM mapped at 0x00000000
  113. */
  114. #define __HAL_SYSCFG_REMAPMEMORY_SRAM() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\
  115. SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_0 | SYSCFG_MEMRMP_MEM_MODE_1);\
  116. }while(0);
  117. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx)
  118. /** @brief FSMC Bank1 (NOR/PSRAM 1 and 2) mapped at 0x00000000
  119. */
  120. #define __HAL_SYSCFG_REMAPMEMORY_FSMC() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\
  121. SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_1);\
  122. }while(0);
  123. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
  124. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  125. defined(STM32F469xx) || defined(STM32F479xx)
  126. /** @brief FMC Bank1 (NOR/PSRAM 1 and 2) mapped at 0x00000000
  127. */
  128. #define __HAL_SYSCFG_REMAPMEMORY_FMC() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\
  129. SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_1);\
  130. }while(0);
  131. /** @brief FMC/SDRAM Bank 1 and 2 mapped at 0x00000000
  132. */
  133. #define __HAL_SYSCFG_REMAPMEMORY_FMC_SDRAM() do {SYSCFG->MEMRMP &= ~(SYSCFG_MEMRMP_MEM_MODE);\
  134. SYSCFG->MEMRMP |= (SYSCFG_MEMRMP_MEM_MODE_2);\
  135. }while(0);
  136. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  137. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  138. /** @defgroup Cortex_Lockup_Enable Cortex Lockup Enable
  139. * @{
  140. */
  141. /** @brief SYSCFG Break Lockup lock
  142. * Enables and locks the connection of Cortex-M4 LOCKUP (Hardfault) output to TIM1/8 input
  143. * @note The selected configuration is locked and can be unlocked by system reset
  144. */
  145. #define __HAL_SYSCFG_BREAK_PVD_LOCK() do {SYSCFG->CFGR2 &= ~(SYSCFG_CFGR2_PVD_LOCK); \
  146. SYSCFG->CFGR2 |= SYSCFG_CFGR2_PVD_LOCK; \
  147. }while(0)
  148. /**
  149. * @}
  150. */
  151. /** @defgroup PVD_Lock_Enable PVD Lock
  152. * @{
  153. */
  154. /** @brief SYSCFG Break PVD lock
  155. * Enables and locks the PVD connection with Timer1/8 Break Input, , as well as the PVDE and PLS[2:0] in the PWR_CR register
  156. * @note The selected configuration is locked and can be unlocked by system reset
  157. */
  158. #define __HAL_SYSCFG_BREAK_LOCKUP_LOCK() do {SYSCFG->CFGR2 &= ~(SYSCFG_CFGR2_LOCKUP_LOCK); \
  159. SYSCFG->CFGR2 |= SYSCFG_CFGR2_LOCKUP_LOCK; \
  160. }while(0)
  161. /**
  162. * @}
  163. */
  164. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx || STM32F413xx || STM32F423xx */
  165. /**
  166. * @}
  167. */
  168. /* Exported functions --------------------------------------------------------*/
  169. /** @addtogroup HAL_Exported_Functions
  170. * @{
  171. */
  172. /** @addtogroup HAL_Exported_Functions_Group1
  173. * @{
  174. */
  175. /* Initialization and de-initialization functions ******************************/
  176. HAL_StatusTypeDef HAL_Init(void);
  177. HAL_StatusTypeDef HAL_DeInit(void);
  178. void HAL_MspInit(void);
  179. void HAL_MspDeInit(void);
  180. HAL_StatusTypeDef HAL_InitTick (uint32_t TickPriority);
  181. /**
  182. * @}
  183. */
  184. /** @addtogroup HAL_Exported_Functions_Group2
  185. * @{
  186. */
  187. /* Peripheral Control functions ************************************************/
  188. void HAL_IncTick(void);
  189. void HAL_Delay(__IO uint32_t Delay);
  190. uint32_t HAL_GetTick(void);
  191. void HAL_SuspendTick(void);
  192. void HAL_ResumeTick(void);
  193. uint32_t HAL_GetHalVersion(void);
  194. uint32_t HAL_GetREVID(void);
  195. uint32_t HAL_GetDEVID(void);
  196. void HAL_DBGMCU_EnableDBGSleepMode(void);
  197. void HAL_DBGMCU_DisableDBGSleepMode(void);
  198. void HAL_DBGMCU_EnableDBGStopMode(void);
  199. void HAL_DBGMCU_DisableDBGStopMode(void);
  200. void HAL_DBGMCU_EnableDBGStandbyMode(void);
  201. void HAL_DBGMCU_DisableDBGStandbyMode(void);
  202. void HAL_EnableCompensationCell(void);
  203. void HAL_DisableCompensationCell(void);
  204. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
  205. defined(STM32F469xx) || defined(STM32F479xx)
  206. void HAL_EnableMemorySwappingBank(void);
  207. void HAL_DisableMemorySwappingBank(void);
  208. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
  209. /**
  210. * @}
  211. */
  212. /**
  213. * @}
  214. */
  215. /* Private types -------------------------------------------------------------*/
  216. /* Private variables ---------------------------------------------------------*/
  217. /** @defgroup HAL_Private_Variables HAL Private Variables
  218. * @{
  219. */
  220. /**
  221. * @}
  222. */
  223. /* Private constants ---------------------------------------------------------*/
  224. /** @defgroup HAL_Private_Constants HAL Private Constants
  225. * @{
  226. */
  227. /**
  228. * @}
  229. */
  230. /* Private macros ------------------------------------------------------------*/
  231. /* Private functions ---------------------------------------------------------*/
  232. /**
  233. * @}
  234. */
  235. /**
  236. * @}
  237. */
  238. #ifdef __cplusplus
  239. }
  240. #endif
  241. #endif /* __STM32F4xx_HAL_H */
  242. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/