STM32F4xx_HAL_Driver  1.8.3
stm32f4xx_hal_def.h
Go to the documentation of this file.
1 
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef __STM32F4xx_HAL_DEF
22 #define __STM32F4xx_HAL_DEF
23 
24 #ifdef __cplusplus
25  extern "C" {
26 #endif
27 
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32f4xx.h"
30 #include "Legacy/stm32_hal_legacy.h"
31 #include <stddef.h>
32 
33 /* Exported types ------------------------------------------------------------*/
34 
38 typedef enum
39 {
40  HAL_OK = 0x00U,
41  HAL_ERROR = 0x01U,
42  HAL_BUSY = 0x02U,
43  HAL_TIMEOUT = 0x03U
44 } HAL_StatusTypeDef;
45 
49 typedef enum
50 {
51  HAL_UNLOCKED = 0x00U,
52  HAL_LOCKED = 0x01U
54 
55 /* Exported macro ------------------------------------------------------------*/
56 
57 #if !defined(UNUSED)
58 #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */
59 #endif /* UNUSED */
60 
61 #define HAL_MAX_DELAY 0xFFFFFFFFU
62 
63 #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT))
64 #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U)
65 
66 #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \
67  do{ \
68  (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
69  (__DMA_HANDLE__).Parent = (__HANDLE__); \
70  } while(0U)
71 
87 #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U)
88 
89 #if (USE_RTOS == 1U)
90  /* Reserved for future use */
91  #error "USE_RTOS should be 0 in the current HAL release"
92 #else
93  #define __HAL_LOCK(__HANDLE__) \
94  do{ \
95  if((__HANDLE__)->Lock == HAL_LOCKED) \
96  { \
97  return HAL_BUSY; \
98  } \
99  else \
100  { \
101  (__HANDLE__)->Lock = HAL_LOCKED; \
102  } \
103  }while (0U)
104 
105  #define __HAL_UNLOCK(__HANDLE__) \
106  do{ \
107  (__HANDLE__)->Lock = HAL_UNLOCKED; \
108  }while (0U)
109 #endif /* USE_RTOS */
110 
111 #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */
112  #ifndef __weak
113  #define __weak __attribute__((weak))
114  #endif
115  #ifndef __packed
116  #define __packed __attribute__((packed))
117  #endif
118 #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
119  #ifndef __weak
120  #define __weak __attribute__((weak))
121  #endif /* __weak */
122  #ifndef __packed
123  #define __packed __attribute__((__packed__))
124  #endif /* __packed */
125 #endif /* __GNUC__ */
126 
127 
128 /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
129 #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */
130  #ifndef __ALIGN_BEGIN
131  #define __ALIGN_BEGIN
132  #endif
133  #ifndef __ALIGN_END
134  #define __ALIGN_END __attribute__ ((aligned (4)))
135  #endif
136 #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
137  #ifndef __ALIGN_END
138 #define __ALIGN_END __attribute__ ((aligned (4)))
139  #endif /* __ALIGN_END */
140  #ifndef __ALIGN_BEGIN
141  #define __ALIGN_BEGIN
142  #endif /* __ALIGN_BEGIN */
143 #else
144  #ifndef __ALIGN_END
145  #define __ALIGN_END
146  #endif /* __ALIGN_END */
147  #ifndef __ALIGN_BEGIN
148  #if defined (__CC_ARM) /* ARM Compiler V5*/
149 #define __ALIGN_BEGIN __align(4)
150  #elif defined (__ICCARM__) /* IAR Compiler */
151  #define __ALIGN_BEGIN
152  #endif /* __CC_ARM */
153  #endif /* __ALIGN_BEGIN */
154 #endif /* __GNUC__ */
155 
156 
160 #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
161 /* ARM Compiler V4/V5 and V6
162  --------------------------
163  RAM functions are defined using the toolchain options.
164  Functions that are executed in RAM should reside in a separate source module.
165  Using the 'Options for File' dialog you can simply change the 'Code / Const'
166  area of a module to a memory space in physical RAM.
167  Available memory areas are declared in the 'Target' tab of the 'Options for Target'
168  dialog.
169 */
170 #define __RAM_FUNC
171 
172 #elif defined ( __ICCARM__ )
173 /* ICCARM Compiler
174  ---------------
175  RAM functions are defined using a specific toolchain keyword "__ramfunc".
176 */
177 #define __RAM_FUNC __ramfunc
178 
179 #elif defined ( __GNUC__ )
180 /* GNU Compiler
181  ------------
182  RAM functions are defined using a specific toolchain attribute
183  "__attribute__((section(".RamFunc")))".
184 */
185 #define __RAM_FUNC __attribute__((section(".RamFunc")))
186 
187 #endif
188 
192 #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined ( __GNUC__ )
193 /* ARM V4/V5 and V6 & GNU Compiler
194  -------------------------------
195 */
196 #define __NOINLINE __attribute__ ( (noinline) )
197 
198 #elif defined ( __ICCARM__ )
199 /* ICCARM Compiler
200  ---------------
201 */
202 #define __NOINLINE _Pragma("optimize = no_inline")
203 
204 #endif
205 
206 #ifdef __cplusplus
207 }
208 #endif
209 
210 #endif /* ___STM32F4xx_HAL_DEF */
211 
212 
HAL_LockTypeDef
HAL Lock structures definition