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