You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

189 lines
6.8 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_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. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software component is licensed by ST under BSD 3-Clause license,
  14. * the "License"; You may not use this file except in compliance with the
  15. * License. You may obtain a copy of the License at:
  16. * opensource.org/licenses/BSD-3-Clause
  17. *
  18. ******************************************************************************
  19. */
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef STM32H7xx_HAL_DEF
  22. #define STM32H7xx_HAL_DEF
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "stm32h7xx.h"
  28. #include "Legacy/stm32_hal_legacy.h"
  29. #include <stddef.h>
  30. #include <math.h>
  31. /* Exported types ------------------------------------------------------------*/
  32. /**
  33. * @brief HAL Status structures definition
  34. */
  35. typedef enum
  36. {
  37. HAL_OK = 0x00,
  38. HAL_ERROR = 0x01,
  39. HAL_BUSY = 0x02,
  40. HAL_TIMEOUT = 0x03
  41. } HAL_StatusTypeDef;
  42. /**
  43. * @brief HAL Lock structures definition
  44. */
  45. typedef enum
  46. {
  47. HAL_UNLOCKED = 0x00,
  48. HAL_LOCKED = 0x01
  49. } HAL_LockTypeDef;
  50. /* Exported macro ------------------------------------------------------------*/
  51. #define HAL_MAX_DELAY 0xFFFFFFFFU
  52. #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT))
  53. #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U)
  54. #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \
  55. do{ \
  56. (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
  57. (__DMA_HANDLE__).Parent = (__HANDLE__); \
  58. } while(0)
  59. #define UNUSED(x) ((void)(x))
  60. /** @brief Reset the Handle's State field.
  61. * @param __HANDLE__: specifies the Peripheral Handle.
  62. * @note This macro can be used for the following purpose:
  63. * - When the Handle is declared as local variable; before passing it as parameter
  64. * to HAL_PPP_Init() for the first time, it is mandatory to use this macro
  65. * to set to 0 the Handle's "State" field.
  66. * Otherwise, "State" field may have any random value and the first time the function
  67. * HAL_PPP_Init() is called, the low level hardware initialization will be missed
  68. * (i.e. HAL_PPP_MspInit() will not be executed).
  69. * - When there is a need to reconfigure the low level hardware: instead of calling
  70. * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
  71. * In this later function, when the Handle's "State" field is set to 0, it will execute the function
  72. * HAL_PPP_MspInit() which will reconfigure the low level hardware.
  73. * @retval None
  74. */
  75. #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0)
  76. #if (USE_RTOS == 1)
  77. #error " USE_RTOS should be 0 in the current HAL release "
  78. #else
  79. #define __HAL_LOCK(__HANDLE__) \
  80. do{ \
  81. if((__HANDLE__)->Lock == HAL_LOCKED) \
  82. { \
  83. return HAL_BUSY; \
  84. } \
  85. else \
  86. { \
  87. (__HANDLE__)->Lock = HAL_LOCKED; \
  88. } \
  89. }while (0)
  90. #define __HAL_UNLOCK(__HANDLE__) \
  91. do{ \
  92. (__HANDLE__)->Lock = HAL_UNLOCKED; \
  93. }while (0)
  94. #endif /* USE_RTOS */
  95. #if defined ( __GNUC__ )
  96. #ifndef __weak
  97. #define __weak __attribute__((weak))
  98. #endif /* __weak */
  99. #ifndef __packed
  100. #define __packed __attribute__((__packed__))
  101. #endif /* __packed */
  102. #endif /* __GNUC__ */
  103. /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
  104. #if defined (__GNUC__) /* GNU Compiler */
  105. #ifndef __ALIGN_END
  106. #define __ALIGN_END __attribute__ ((aligned (4)))
  107. #endif /* __ALIGN_END */
  108. #ifndef __ALIGN_BEGIN
  109. #define __ALIGN_BEGIN
  110. #endif /* __ALIGN_BEGIN */
  111. #else
  112. #ifndef __ALIGN_END
  113. #define __ALIGN_END
  114. #endif /* __ALIGN_END */
  115. #ifndef __ALIGN_BEGIN
  116. #if defined (__CC_ARM) /* ARM Compiler */
  117. #define __ALIGN_BEGIN __align(4)
  118. #elif defined (__ICCARM__) /* IAR Compiler */
  119. #define __ALIGN_BEGIN
  120. #endif /* __CC_ARM */
  121. #endif /* __ALIGN_BEGIN */
  122. #endif /* __GNUC__ */
  123. /* Macro to get variable aligned on 32-bytes,needed for cache maintenance purpose */
  124. #if defined (__GNUC__) /* GNU Compiler */
  125. #define ALIGN_32BYTES(buf) buf __attribute__ ((aligned (32)))
  126. #elif defined (__ICCARM__) /* IAR Compiler */
  127. #define ALIGN_32BYTES(buf) _Pragma("data_alignment=32") buf
  128. #elif defined (__CC_ARM) /* ARM Compiler */
  129. #define ALIGN_32BYTES(buf) __align(32) buf
  130. #endif
  131. /**
  132. * @brief __RAM_FUNC definition
  133. */
  134. #if defined ( __CC_ARM )
  135. /* ARM Compiler
  136. ------------
  137. RAM functions are defined using the toolchain options.
  138. Functions that are executed in RAM should reside in a separate source module.
  139. Using the 'Options for File' dialog you can simply change the 'Code / Const'
  140. area of a module to a memory space in physical RAM.
  141. Available memory areas are declared in the 'Target' tab of the 'Options for Target'
  142. dialog.
  143. */
  144. #define __RAM_FUNC
  145. #elif defined ( __ICCARM__ )
  146. /* ICCARM Compiler
  147. ---------------
  148. RAM functions are defined using a specific toolchain keyword "__ramfunc".
  149. */
  150. #define __RAM_FUNC __ramfunc
  151. #elif defined ( __GNUC__ )
  152. /* GNU Compiler
  153. ------------
  154. RAM functions are defined using a specific toolchain attribute
  155. "__attribute__((section(".RamFunc")))".
  156. */
  157. #define __RAM_FUNC __attribute__((section(".RamFunc")))
  158. #endif
  159. #ifdef __cplusplus
  160. }
  161. #endif
  162. #endif /* STM32H7xx_HAL_DEF */
  163. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/