Merge pull request #11270 from haslinghuis/rename_attr
[betaflight.git] / lib / main / STM32F1 / Drivers / STM32F1xx_HAL_Driver / Inc / stm32f1xx_hal_def.h
bloba904b4e3dba86df64d28cd322cd5ed530305c71c
1 /**
2 ******************************************************************************
3 * @file stm32f1xx_hal_def.h
4 * @author MCD Application Team
5 * @version V1.1.1
6 * @date 12-May-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 __STM32F1xx_HAL_DEF
41 #define __STM32F1xx_HAL_DEF
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
47 /* Includes ------------------------------------------------------------------*/
48 #include "stm32f1xx.h"
49 #if defined(USE_HAL_LEGACY)
50 #include "Legacy/stm32_hal_legacy.h"
51 #endif
52 #include <stdio.h>
54 /* Exported types ------------------------------------------------------------*/
56 /**
57 * @brief HAL Status structures definition
58 */
59 typedef enum
61 HAL_OK = 0x00U,
62 HAL_ERROR = 0x01U,
63 HAL_BUSY = 0x02U,
64 HAL_TIMEOUT = 0x03U
65 } HAL_StatusTypeDef;
67 /**
68 * @brief HAL Lock structures definition
70 typedef enum
72 HAL_UNLOCKED = 0x00U,
73 HAL_LOCKED = 0x01U
74 } HAL_LockTypeDef;
76 /* Exported macro ------------------------------------------------------------*/
77 #define HAL_MAX_DELAY 0xFFFFFFFFU
79 #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != RESET)
80 #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET)
82 #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \
83 do{ \
84 (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
85 (__DMA_HANDLE__).Parent = (__HANDLE__); \
86 } while(0U)
88 #if !defined(UNUSED)
89 #define UNUSED(x) ((void)(x))
90 #endif
92 /** @brief Reset the Handle's State field.
93 * @param __HANDLE__: specifies the Peripheral Handle.
94 * @note This macro can be used for the following purpose:
95 * - When the Handle is declared as local variable; before passing it as parameter
96 * to HAL_PPP_Init() for the first time, it is mandatory to use this macro
97 * to set to 0 the Handle's "State" field.
98 * Otherwise, "State" field may have any random value and the first time the function
99 * HAL_PPP_Init() is called, the low level hardware initialization will be missed
100 * (i.e. HAL_PPP_MspInit() will not be executed).
101 * - When there is a need to reconfigure the low level hardware: instead of calling
102 * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
103 * In this later function, when the Handle's "State" field is set to 0, it will execute the function
104 * HAL_PPP_MspInit() which will reconfigure the low level hardware.
105 * @retval None
107 #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U)
109 #if (USE_RTOS == 1U)
110 /* Reserved for future use */
111 #error "USE_RTOS should be 0 in the current HAL release"
112 #else
113 #define __HAL_LOCK(__HANDLE__) \
114 do{ \
115 if((__HANDLE__)->Lock == HAL_LOCKED) \
117 return HAL_BUSY; \
119 else \
121 (__HANDLE__)->Lock = HAL_LOCKED; \
123 }while (0U)
125 #define __HAL_UNLOCK(__HANDLE__) \
126 do{ \
127 (__HANDLE__)->Lock = HAL_UNLOCKED; \
128 }while (0U)
129 #endif /* USE_RTOS */
131 #if defined ( __GNUC__ )
132 #ifndef __weak
133 #define __weak __attribute__((weak))
134 #endif /* __weak */
135 #ifndef __packed
136 #define __packed __attribute__((__packed__))
137 #endif /* __packed */
138 #endif /* __GNUC__ */
141 /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
142 #if defined (__GNUC__) /* GNU Compiler */
143 #ifndef __ALIGN_END
144 #define __ALIGN_END __attribute__ ((aligned (4)))
145 #endif /* __ALIGN_END */
146 #ifndef __ALIGN_BEGIN
147 #define __ALIGN_BEGIN
148 #endif /* __ALIGN_BEGIN */
149 #else
150 #ifndef __ALIGN_END
151 #define __ALIGN_END
152 #endif /* __ALIGN_END */
153 #ifndef __ALIGN_BEGIN
154 #if defined (__CC_ARM) /* ARM Compiler */
155 #define __ALIGN_BEGIN __align(4)
156 #elif defined (__ICCARM__) /* IAR Compiler */
157 #define __ALIGN_BEGIN
158 #endif /* __CC_ARM */
159 #endif /* __ALIGN_BEGIN */
160 #endif /* __GNUC__ */
163 /**
164 * @brief __RAM_FUNC definition
166 #if defined ( __CC_ARM )
167 /* ARM Compiler
168 ------------
169 RAM functions are defined using the toolchain options.
170 Functions that are executed in RAM should reside in a separate source module.
171 Using the 'Options for File' dialog you can simply change the 'Code / Const'
172 area of a module to a memory space in physical RAM.
173 Available memory areas are declared in the 'Target' tab of the 'Options for Target'
174 dialog.
176 #define __RAM_FUNC HAL_StatusTypeDef
178 #elif defined ( __ICCARM__ )
179 /* ICCARM Compiler
180 ---------------
181 RAM functions are defined using a specific toolchain keyword "__ramfunc".
183 #define __RAM_FUNC __ramfunc HAL_StatusTypeDef
185 #elif defined ( __GNUC__ )
186 /* GNU Compiler
187 ------------
188 RAM functions are defined using a specific toolchain attribute
189 "__attribute__((section(".RamFunc")))".
191 #define __RAM_FUNC HAL_StatusTypeDef __attribute__((section(".RamFunc")))
193 #endif
195 /**
196 * @brief __NOINLINE definition
198 #if defined ( __CC_ARM ) || defined ( __GNUC__ )
199 /* ARM & GNUCompiler
200 ----------------
202 #define __NOINLINE __attribute__ ( (noinline) )
204 #elif defined ( __ICCARM__ )
205 /* ICCARM Compiler
206 ---------------
208 #define __NOINLINE _Pragma("optimize = no_inline")
210 #endif
212 #ifdef __cplusplus
214 #endif
216 #endif /* ___STM32F1xx_HAL_DEF */
218 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/