stm32f3xx_hal_def.h 8.3 KB

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