Create release.yml
[betaflight.git] / lib / main / STM32F4 / Drivers / STM32F4xx_HAL_Driver / Inc / stm32f4xx_hal_def.h
blobca07775ba8d7993bacc9ab8e58a073591b8d6931
1 /**
2 ******************************************************************************
3 * @file stm32f4xx_hal_def.h
4 * @author MCD Application Team
5 * @version V1.7.1
6 * @date 14-April-2017
7 * @brief This file contains HAL common defines, enumeration, macros and
8 * structures definitions.
9 ******************************************************************************
10 * @attention
12 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
14 * Redistribution and use in source and binary forms, with or without modification,
15 * are permitted provided that the following conditions are met:
16 * 1. Redistributions of source code must retain the above copyright notice,
17 * this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright notice,
19 * this list of conditions and the following disclaimer in the documentation
20 * and/or other materials provided with the distribution.
21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 ******************************************************************************
39 /* Define to prevent recursive inclusion -------------------------------------*/
40 #ifndef __STM32F4xx_HAL_DEF
41 #define __STM32F4xx_HAL_DEF
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
47 /* Includes ------------------------------------------------------------------*/
48 #include "stm32f4xx.h"
49 #include "Legacy/stm32_hal_legacy.h"
50 #include <stdio.h>
52 /* Exported types ------------------------------------------------------------*/
54 /**
55 * @brief HAL Status structures definition
56 */
57 typedef enum
59 HAL_OK = 0x00U,
60 HAL_ERROR = 0x01U,
61 HAL_BUSY = 0x02U,
62 HAL_TIMEOUT = 0x03U
63 } HAL_StatusTypeDef;
65 /**
66 * @brief HAL Lock structures definition
68 typedef enum
70 HAL_UNLOCKED = 0x00U,
71 HAL_LOCKED = 0x01U
72 } HAL_LockTypeDef;
74 /* Exported macro ------------------------------------------------------------*/
75 #define HAL_MAX_DELAY 0xFFFFFFFFU
77 #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != RESET)
78 #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET)
80 #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \
81 do{ \
82 (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
83 (__DMA_HANDLE__).Parent = (__HANDLE__); \
84 } while(0)
86 #if !defined(UNUSED)
87 #define UNUSED(x) ((void)(x))
88 #endif
90 /** @brief Reset the Handle's State field.
91 * @param __HANDLE__: specifies the Peripheral Handle.
92 * @note This macro can be used for the following purpose:
93 * - When the Handle is declared as local variable; before passing it as parameter
94 * to HAL_PPP_Init() for the first time, it is mandatory to use this macro
95 * to set to 0 the Handle's "State" field.
96 * Otherwise, "State" field may have any random value and the first time the function
97 * HAL_PPP_Init() is called, the low level hardware initialization will be missed
98 * (i.e. HAL_PPP_MspInit() will not be executed).
99 * - When there is a need to reconfigure the low level hardware: instead of calling
100 * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
101 * In this later function, when the Handle's "State" field is set to 0, it will execute the function
102 * HAL_PPP_MspInit() which will reconfigure the low level hardware.
103 * @retval None
105 #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U)
107 #if (USE_RTOS == 1U)
108 /* Reserved for future use */
109 #error "USE_RTOS should be 0 in the current HAL release"
110 #else
111 #define __HAL_LOCK(__HANDLE__) \
112 do{ \
113 if((__HANDLE__)->Lock == HAL_LOCKED) \
115 return HAL_BUSY; \
117 else \
119 (__HANDLE__)->Lock = HAL_LOCKED; \
121 }while (0U)
123 #define __HAL_UNLOCK(__HANDLE__) \
124 do{ \
125 (__HANDLE__)->Lock = HAL_UNLOCKED; \
126 }while (0U)
127 #endif /* USE_RTOS */
129 #if defined ( __GNUC__ )
130 #ifndef __weak
131 #define __weak __attribute__((weak))
132 #endif /* __weak */
133 #ifndef __packed
134 #define __packed __attribute__((__packed__))
135 #endif /* __packed */
136 #endif /* __GNUC__ */
139 /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
140 #if defined (__GNUC__) /* GNU Compiler */
141 #ifndef __ALIGN_END
142 #define __ALIGN_END __attribute__ ((aligned (4)))
143 #endif /* __ALIGN_END */
144 #ifndef __ALIGN_BEGIN
145 #define __ALIGN_BEGIN
146 #endif /* __ALIGN_BEGIN */
147 #else
148 #ifndef __ALIGN_END
149 #define __ALIGN_END
150 #endif /* __ALIGN_END */
151 #ifndef __ALIGN_BEGIN
152 #if defined (__CC_ARM) /* ARM Compiler */
153 #define __ALIGN_BEGIN __align(4)
154 #elif defined (__ICCARM__) /* IAR Compiler */
155 #define __ALIGN_BEGIN
156 #endif /* __CC_ARM */
157 #endif /* __ALIGN_BEGIN */
158 #endif /* __GNUC__ */
161 /**
162 * @brief __RAM_FUNC definition
164 #if defined ( __CC_ARM )
165 /* ARM Compiler
166 ------------
167 RAM functions are defined using the toolchain options.
168 Functions that are executed in RAM should reside in a separate source module.
169 Using the 'Options for File' dialog you can simply change the 'Code / Const'
170 area of a module to a memory space in physical RAM.
171 Available memory areas are declared in the 'Target' tab of the 'Options for Target'
172 dialog.
174 #define __RAM_FUNC HAL_StatusTypeDef
176 #elif defined ( __ICCARM__ )
177 /* ICCARM Compiler
178 ---------------
179 RAM functions are defined using a specific toolchain keyword "__ramfunc".
181 #define __RAM_FUNC __ramfunc HAL_StatusTypeDef
183 #elif defined ( __GNUC__ )
184 /* GNU Compiler
185 ------------
186 RAM functions are defined using a specific toolchain attribute
187 "__attribute__((section(".RamFunc")))".
189 #define __RAM_FUNC HAL_StatusTypeDef __attribute__((section(".RamFunc")))
191 #endif
193 /**
194 * @brief __NOINLINE definition
196 #if defined ( __CC_ARM ) || defined ( __GNUC__ )
197 /* ARM & GNUCompiler
198 ----------------
200 #define __NOINLINE __attribute__ ( (noinline) )
202 #elif defined ( __ICCARM__ )
203 /* ICCARM Compiler
204 ---------------
206 #define __NOINLINE _Pragma("optimize = no_inline")
208 #endif
210 #ifdef __cplusplus
212 #endif
214 #endif /* ___STM32F4xx_HAL_DEF */
216 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/