stm32h7xx_hal_def.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_hal_def.h
  4. * @author MCD Application Team
  5. * @version V1.0.0
  6. * @date 21-April-2017
  7. * @brief This file contains HAL common defines, enumeration, macros and
  8. * structures definitions.
  9. * modified by ARM
  10. ******************************************************************************
  11. * @attention
  12. *
  13. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  14. *
  15. * Redistribution and use in source and binary forms, with or without modification,
  16. * are permitted provided that the following conditions are met:
  17. * 1. Redistributions of source code must retain the above copyright notice,
  18. * this list of conditions and the following disclaimer.
  19. * 2. Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  23. * may be used to endorse or promote products derived from this software
  24. * without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  29. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  30. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  32. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  33. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  34. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  35. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  36. *
  37. ******************************************************************************
  38. */
  39. /* Define to prevent recursive inclusion -------------------------------------*/
  40. #ifndef __STM32H7xx_HAL_DEF
  41. #define __STM32H7xx_HAL_DEF
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45. /* Includes ------------------------------------------------------------------*/
  46. #include "stm32h7xx.h"
  47. #include "Legacy/stm32_hal_legacy.h"
  48. #include <stdio.h>
  49. /* Exported types ------------------------------------------------------------*/
  50. /**
  51. * @brief HAL Status structures definition
  52. */
  53. typedef enum
  54. {
  55. HAL_OK = 0x00,
  56. HAL_ERROR = 0x01,
  57. HAL_BUSY = 0x02,
  58. HAL_TIMEOUT = 0x03
  59. } HAL_StatusTypeDef;
  60. /**
  61. * @brief HAL Lock structures definition
  62. */
  63. typedef enum
  64. {
  65. HAL_UNLOCKED = 0x00,
  66. HAL_LOCKED = 0x01
  67. } HAL_LockTypeDef;
  68. /* Exported macro ------------------------------------------------------------*/
  69. #ifndef NULL
  70. #define NULL (void *) 0
  71. #endif
  72. #define HAL_MAX_DELAY 0xFFFFFFFF
  73. #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != RESET)
  74. #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET)
  75. #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \
  76. do{ \
  77. (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
  78. (__DMA_HANDLE__).Parent = (__HANDLE__); \
  79. } while(0)
  80. #define UNUSED(x) ((void)(x))
  81. /** @brief Reset the Handle's State field.
  82. * @param __HANDLE__: specifies the Peripheral Handle.
  83. * @note This macro can be used for the following purpose:
  84. * - When the Handle is declared as local variable; before passing it as parameter
  85. * to HAL_PPP_Init() for the first time, it is mandatory to use this macro
  86. * to set to 0 the Handle's "State" field.
  87. * Otherwise, "State" field may have any random value and the first time the function
  88. * HAL_PPP_Init() is called, the low level hardware initialization will be missed
  89. * (i.e. HAL_PPP_MspInit() will not be executed).
  90. * - When there is a need to reconfigure the low level hardware: instead of calling
  91. * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
  92. * In this later function, when the Handle's "State" field is set to 0, it will execute the function
  93. * HAL_PPP_MspInit() which will reconfigure the low level hardware.
  94. * @retval None
  95. */
  96. #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0)
  97. #if (USE_RTOS == 1)
  98. #error " USE_RTOS should be 0 in the current HAL release "
  99. #else
  100. #define __HAL_LOCK(__HANDLE__) \
  101. do{ \
  102. if((__HANDLE__)->Lock == HAL_LOCKED) \
  103. { \
  104. return HAL_BUSY; \
  105. } \
  106. else \
  107. { \
  108. (__HANDLE__)->Lock = HAL_LOCKED; \
  109. } \
  110. }while (0)
  111. #define __HAL_UNLOCK(__HANDLE__) \
  112. do{ \
  113. (__HANDLE__)->Lock = HAL_UNLOCKED; \
  114. }while (0)
  115. #endif /* USE_RTOS */
  116. /**
  117. * __weak / __packed definition
  118. */
  119. /*
  120. * ARM Compiler 4/5
  121. */
  122. #if defined ( __CC_ARM )
  123. /* already defined by compiler */
  124. /*
  125. * ARM Compiler 6 (armclang)
  126. */
  127. #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
  128. #ifndef __weak
  129. #define __weak __attribute__((weak))
  130. #endif /* __weak */
  131. #ifndef __packed
  132. #define __packed __attribute__((__packed__))
  133. #endif /* __packed */
  134. /*
  135. * GNU Compiler
  136. */
  137. #elif defined ( __GNUC__ )
  138. #ifndef __weak
  139. #define __weak __attribute__((weak))
  140. #endif /* __weak */
  141. #ifndef __packed
  142. #define __packed __attribute__((__packed__))
  143. #endif /* __packed */
  144. /*
  145. * IAR Compiler
  146. */
  147. #elif defined ( __ICCARM__ )
  148. /* already defined by compiler */
  149. #endif
  150. /**
  151. * macro to get variable aligned on 4-bytes
  152. */
  153. /*
  154. * ARM Compiler 4/5
  155. */
  156. #if defined ( __CC_ARM )
  157. #ifndef __ALIGN_END
  158. #define __ALIGN_END
  159. #endif /* __ALIGN_END */
  160. #ifndef __ALIGN_BEGIN
  161. #define __ALIGN_BEGIN __align(4)
  162. #endif /* __ALIGN_BEGIN */
  163. /*
  164. * ARM Compiler 6 (armclang)
  165. */
  166. #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
  167. #ifndef __ALIGN_END
  168. #define __ALIGN_END __attribute__ ((aligned (4)))
  169. #endif /* __ALIGN_END */
  170. #ifndef __ALIGN_BEGIN
  171. #define __ALIGN_BEGIN
  172. #endif /* __ALIGN_BEGIN */
  173. /*
  174. * GNU Compiler
  175. */
  176. #elif defined ( __GNUC__ )
  177. #ifndef __ALIGN_END
  178. #define __ALIGN_END __attribute__ ((aligned (4)))
  179. #endif /* __ALIGN_END */
  180. #ifndef __ALIGN_BEGIN
  181. #define __ALIGN_BEGIN
  182. #endif /* __ALIGN_BEGIN */
  183. /*
  184. * IAR Compiler
  185. */
  186. #elif defined ( __ICCARM__ )
  187. /* the directive "#pragma data_alignment=4" must be used instead */
  188. #ifndef __ALIGN_END
  189. #define __ALIGN_END
  190. #endif /* __ALIGN_END */
  191. #ifndef __ALIGN_BEGIN
  192. #define __ALIGN_BEGIN
  193. #endif /* __ALIGN_BEGIN */
  194. #endif
  195. /**
  196. * @brief __RAM_FUNC definition
  197. */
  198. /*
  199. * ARM Compiler 4/5
  200. */
  201. #if defined ( __CC_ARM )
  202. /*
  203. RAM functions are defined using the toolchain options.
  204. Functions that are executed in RAM should reside in a separate source module.
  205. Using the 'Options for File' dialog you can simply change the 'Code / Const'
  206. area of a module to a memory space in physical RAM.
  207. Available memory areas are declared in the 'Target' tab of the 'Options for Target'
  208. dialog.
  209. */
  210. #define __RAM_FUNC HAL_StatusTypeDef
  211. /*
  212. * ARM Compiler 6 (armclang)
  213. */
  214. #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
  215. /*
  216. RAM functions are defined using the toolchain options.
  217. Functions that are executed in RAM should reside in a separate source module.
  218. Using the 'Options for File' dialog you can simply change the 'Code / Const'
  219. area of a module to a memory space in physical RAM.
  220. Available memory areas are declared in the 'Target' tab of the 'Options for Target'
  221. dialog.
  222. */
  223. #define __RAM_FUNC HAL_StatusTypeDef
  224. /*
  225. * GNU Compiler
  226. */
  227. #elif defined ( __GNUC__ )
  228. /*
  229. RAM functions are defined using a specific toolchain attribute
  230. "__attribute__((section(".RamFunc")))".
  231. */
  232. #define __RAM_FUNC HAL_StatusTypeDef __attribute__((section(".RamFunc")))
  233. /*
  234. * IAR Compiler
  235. */
  236. #elif defined ( __ICCARM__ )
  237. /*
  238. RAM functions are defined using a specific toolchain keyword "__ramfunc".
  239. */
  240. #define __RAM_FUNC __ramfunc HAL_StatusTypeDef
  241. #endif
  242. /**
  243. * @brief __NOINLINE definition
  244. */
  245. /*
  246. * ARM Compiler 4/5
  247. */
  248. #if defined ( __CC_ARM )
  249. #define __NOINLINE __attribute__ ((noinline) )
  250. /*
  251. * ARM Compiler 6 (armclang)
  252. */
  253. #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
  254. #define __NOINLINE __attribute__ ((noinline) )
  255. /*
  256. * GNU Compiler
  257. */
  258. #elif defined ( __GNUC__ )
  259. #define __NOINLINE __attribute__ ((noinline) )
  260. /*
  261. * IAR Compiler
  262. */
  263. #elif defined ( __ICCARM__ )
  264. #define __NOINLINE _Pragma("optimize = no_inline")
  265. #endif
  266. #ifdef __cplusplus
  267. }
  268. #endif
  269. #endif /* ___STM32H7xx_HAL_DEF */
  270. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/