stm32h5xx_hal_def.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /**
  2. **********************************************************************************************************************
  3. * @file stm32h5xx_hal_def.h
  4. * @author MCD Application Team
  5. * @brief This file contains HAL common defines, enumeration, macros and
  6. * structures definitions.
  7. **********************************************************************************************************************
  8. * @attention
  9. *
  10. * Copyright (c) 2023 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 __STM32H5xx_HAL_DEF
  21. #define __STM32H5xx_HAL_DEF
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif /* __cplusplus */
  25. /* Includes ----------------------------------------------------------------------------------------------------------*/
  26. #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
  27. #include <arm_cmse.h>
  28. #endif /* __ARM_FEATURE_CMSE */
  29. #include "stm32h5xx.h"
  30. #include "Legacy/stm32_hal_legacy.h" /* Aliases file for old names compatibility */
  31. #include <stddef.h>
  32. #include <math.h>
  33. /* Exported types ----------------------------------------------------------------------------------------------------*/
  34. /**
  35. * @brief HAL Status structures definition
  36. */
  37. typedef enum
  38. {
  39. HAL_OK = 0x00,
  40. HAL_ERROR = 0x01,
  41. HAL_BUSY = 0x02,
  42. HAL_TIMEOUT = 0x03
  43. } HAL_StatusTypeDef;
  44. /**
  45. * @brief HAL Lock structures definition
  46. */
  47. typedef enum
  48. {
  49. HAL_UNLOCKED = 0x00,
  50. HAL_LOCKED = 0x01
  51. } HAL_LockTypeDef;
  52. /* Exported macros ---------------------------------------------------------------------------------------------------*/
  53. #define HAL_MAX_DELAY 0xFFFFFFFFU
  54. #define ARMCC_MIN_VERSION 6010050
  55. #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT))
  56. #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U)
  57. #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \
  58. do{ \
  59. (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
  60. (__DMA_HANDLE__).Parent = (__HANDLE__); \
  61. } while(0)
  62. #if !defined(UNUSED)
  63. #define UNUSED(x) ((void)(x))
  64. #endif /* UNUSED */
  65. /** @brief Reset the Handle's State field.
  66. * @param __HANDLE__: specifies the Peripheral Handle.
  67. * @note This macro can be used for the following purpose:
  68. * - When the Handle is declared as local variable; before passing it as parameter
  69. * to HAL_PPP_Init() for the first time, it is mandatory to use this macro
  70. * to set to 0 the Handle's "State" field.
  71. * Otherwise, "State" field may have any random value and the first time the function
  72. * HAL_PPP_Init() is called, the low level hardware initialization will be missed
  73. * (i.e. HAL_PPP_MspInit() will not be executed).
  74. * - When there is a need to reconfigure the low level hardware: instead of calling
  75. * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
  76. * In this later function, when the Handle's "State" field is set to 0, it will execute the function
  77. * HAL_PPP_MspInit() which will reconfigure the low level hardware.
  78. * @retval None
  79. */
  80. #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0)
  81. #if (USE_RTOS == 1)
  82. /* Reserved for future use */
  83. #error " USE_RTOS should be 0 in the current HAL release "
  84. #else
  85. #define __HAL_LOCK(__HANDLE__) \
  86. do{ \
  87. if((__HANDLE__)->Lock == HAL_LOCKED) \
  88. { \
  89. return HAL_BUSY; \
  90. } \
  91. else \
  92. { \
  93. (__HANDLE__)->Lock = HAL_LOCKED; \
  94. } \
  95. }while (0)
  96. #define __HAL_UNLOCK(__HANDLE__) \
  97. do{ \
  98. (__HANDLE__)->Lock = HAL_UNLOCKED; \
  99. }while (0)
  100. #endif /* USE_RTOS */
  101. #if defined ( __GNUC__ )
  102. #ifndef __weak
  103. #define __weak __attribute__((weak))
  104. #endif /* __weak */
  105. #ifndef __packed
  106. #define __packed __attribute__((__packed__))
  107. #endif /* __packed */
  108. #endif /* __GNUC__ */
  109. #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= ARMCC_MIN_VERSION)
  110. #ifndef __weak
  111. #define __weak __WEAK
  112. #endif /* __weak */
  113. #ifndef __packed
  114. #define __packed __PACKED
  115. #endif /* __packed */
  116. #endif
  117. /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4"
  118. must be used instead */
  119. #if defined (__GNUC__) /* GNU Compiler */
  120. #ifndef __ALIGN_END
  121. #define __ALIGN_END __attribute__ ((aligned (4)))
  122. #endif /* __ALIGN_END */
  123. #ifndef __ALIGN_BEGIN
  124. #define __ALIGN_BEGIN
  125. #endif /* __ALIGN_BEGIN */
  126. #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= ARMCC_MIN_VERSION)
  127. #ifndef __ALIGN_END
  128. #define __ALIGN_END __ALIGNED(4)
  129. #endif /* __ALIGN_END */
  130. #ifndef __ALIGN_BEGIN
  131. #define __ALIGN_BEGIN
  132. #endif /* __ALIGN_BEGIN */
  133. #else
  134. #ifndef __ALIGN_END
  135. #define __ALIGN_END
  136. #endif /* __ALIGN_END */
  137. #ifndef __ALIGN_BEGIN
  138. #if defined (__CC_ARM) /* ARM Compiler */
  139. #define __ALIGN_BEGIN __align(4)
  140. #elif defined (__ICCARM__) /* IAR Compiler */
  141. #define __ALIGN_BEGIN
  142. #endif /* __CC_ARM */
  143. #endif /* __ALIGN_BEGIN */
  144. #endif /* __GNUC__ */
  145. /* Macro to get variable aligned on 32-bytes,needed for cache maintenance purpose */
  146. #if defined (__GNUC__) /* GNU Compiler */
  147. #define ALIGN_32BYTES(buf) buf __attribute__ ((aligned (32)))
  148. #elif defined (__ICCARM__) /* IAR Compiler */
  149. #define ALIGN_32BYTES(buf) _Pragma("data_alignment=32") buf
  150. #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= ARMCC_MIN_VERSION)
  151. #define ALIGN_32BYTES(buf) __ALIGNED(32) buf
  152. #elif defined (__CC_ARM) /* ARM Compiler */
  153. #define ALIGN_32BYTES(buf) __align(32) buf
  154. #endif /* __GNUC__ */
  155. /**
  156. * @brief __RAM_FUNC definition
  157. */
  158. #if defined ( __CC_ARM ) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= ARMCC_MIN_VERSION))
  159. /* ARM Compiler
  160. RAM functions are defined using the toolchain options.
  161. Functions that are executed in RAM should reside in a separate source module.
  162. Using the 'Options for File' dialog you can simply change the 'Code / Const'
  163. area of a module to a memory space in physical RAM.
  164. Available memory areas are declared in the 'Target' tab of the 'Options for Target'
  165. dialog.
  166. */
  167. #define __RAM_FUNC HAL_StatusTypeDef
  168. #elif defined ( __ICCARM__ )
  169. /* ICCARM Compiler
  170. RAM functions are defined using a specific toolchain keyword "__ramfunc".
  171. */
  172. #define __RAM_FUNC __ramfunc HAL_StatusTypeDef
  173. #elif defined ( __GNUC__ )
  174. /* GNU Compiler
  175. RAM functions are defined using a specific toolchain attribute
  176. "__attribute__((section(".RamFunc")))".
  177. */
  178. #define __RAM_FUNC HAL_StatusTypeDef __attribute__((section(".RamFunc")))
  179. #endif /* defined ( __CC_ARM ) || ((__ARMCC_VERSION) && (__ARMCC_VERSION >= ARMCC_MIN_VERSION)) */
  180. /**
  181. * @brief __NOINLINE definition
  182. */
  183. #if defined ( __CC_ARM ) || (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= ARMCC_MIN_VERSION)) || defined ( __GNUC__ )
  184. /* ARM & GNUCompiler
  185. */
  186. #define __NOINLINE __attribute__ ( (noinline) )
  187. #elif defined ( __ICCARM__ )
  188. /* ICCARM Compiler
  189. */
  190. #define __NOINLINE _Pragma("optimize = no_inline")
  191. #endif /* ( __CC_ARM ) || ((__ARMCC_VERSION) && (__ARMCC_VERSION >= ARMCC_MIN_VERSION)) || defined ( __GNUC__ ) */
  192. #ifdef __cplusplus
  193. }
  194. #endif /* __cplusplus */
  195. #endif /* ___STM32H5xx_HAL_DEF */