stm32f7xx_hal_def.h 8.5 KB

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