rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
stm32f4xx_hal_def.h
Go to the documentation of this file.
1/**
2 ******************************************************************************
3 * @file stm32f4xx_hal_def.h
4 * @author MCD Application Team
5 * @version V1.4.0
6 * @date 14-August-2015
7 * @brief This file contains HAL common defines, enumeration, macros and
8 * structures definitions.
9 ******************************************************************************
10 * @attention
11 *
12 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
13 *
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.
24 *
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.
35 *
36 ******************************************************************************
37 */
38
39/* Define to prevent recursive inclusion -------------------------------------*/
40#ifndef __STM32F4xx_HAL_DEF
41#define __STM32F4xx_HAL_DEF
42
43#ifdef __cplusplus
44 extern "C" {
45#endif
46
47/* Includes ------------------------------------------------------------------*/
48#ifdef AT32F4XX
49 #include "at32f4xx.h"
50#else
51 #include "stm32f4xx.h"
52#endif
53//#include "Legacy/stm32_hal_legacy.h"
54#include <stdio.h>
55
56/* Exported types ------------------------------------------------------------*/
57
58/**
59 * @brief HAL Status structures definition
60 */
61typedef enum
62{
63 HAL_OK = 0x00,
64 HAL_ERROR = 0x01,
65 HAL_BUSY = 0x02,
66 HAL_TIMEOUT = 0x03
67} HAL_StatusTypeDef;
68
69/**
70 * @brief HAL Lock structures definition
71 */
72typedef enum
73{
75 HAL_LOCKED = 0x01
77
78/* Exported macro ------------------------------------------------------------*/
79#define HAL_MAX_DELAY 0xFFFFFFFF
80
81#define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != RESET)
82#define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET)
83
84#define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \
85 do{ \
86 (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
87 (__DMA_HANDLE__).Parent = (__HANDLE__); \
88 } while(0)
89
90//#define UNUSED(x) ((void)(x))
91
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
106 */
107#define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0)
108
109#ifndef USE_RTOS
110#define USE_RTOS 0
111#endif
112
113#if (USE_RTOS == 1)
114 /* Reserved for future use */
115 #error �USE_RTOS should be 0 in the current HAL release�
116#else
117 #define __HAL_LOCK(__HANDLE__) \
118 do{ \
119 if((__HANDLE__)->Lock == HAL_LOCKED) \
120 { \
121 return HAL_BUSY; \
122 } \
123 else \
124 { \
125 (__HANDLE__)->Lock = HAL_LOCKED; \
126 } \
127 }while (0)
128
129 #define __HAL_UNLOCK(__HANDLE__) \
130 do{ \
131 (__HANDLE__)->Lock = HAL_UNLOCKED; \
132 }while (0)
133#endif /* USE_RTOS */
134
135#if defined ( __GNUC__ )
136 #ifndef __weak
137 #define __weak __attribute__((weak))
138 #endif /* __weak */
139 #ifndef __packed
140 #define __packed __attribute__((__packed__))
141 #endif /* __packed */
142#endif /* __GNUC__ */
143
144
145/* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
146#if defined (__GNUC__) /* GNU Compiler */
147 #ifndef __ALIGN_END
148 #define __ALIGN_END __attribute__ ((aligned (4)))
149 #endif /* __ALIGN_END */
150 #ifndef __ALIGN_BEGIN
151 #define __ALIGN_BEGIN
152 #endif /* __ALIGN_BEGIN */
153#else
154 #ifndef __ALIGN_END
155 #define __ALIGN_END
156 #endif /* __ALIGN_END */
157 #ifndef __ALIGN_BEGIN
158 #if defined (__CC_ARM) /* ARM Compiler */
159 #define __ALIGN_BEGIN __align(4)
160 #elif defined (__ICCARM__) /* IAR Compiler */
161 #define __ALIGN_BEGIN
162 #endif /* __CC_ARM */
163 #endif /* __ALIGN_BEGIN */
164#endif /* __GNUC__ */
165
166
167/**
168 * @brief __RAM_FUNC definition
169 */
170#if defined ( __CC_ARM )
171/* ARM Compiler
172 ------------
173 RAM functions are defined using the toolchain options.
174 Functions that are executed in RAM should reside in a separate source module.
175 Using the 'Options for File' dialog you can simply change the 'Code / Const'
176 area of a module to a memory space in physical RAM.
177 Available memory areas are declared in the 'Target' tab of the 'Options for Target'
178 dialog.
179*/
180#define __RAM_FUNC HAL_StatusTypeDef
181
182#elif defined ( __ICCARM__ )
183/* ICCARM Compiler
184 ---------------
185 RAM functions are defined using a specific toolchain keyword "__ramfunc".
186*/
187#define __RAM_FUNC __ramfunc HAL_StatusTypeDef
188
189#elif defined ( __GNUC__ )
190/* GNU Compiler
191 ------------
192 RAM functions are defined using a specific toolchain attribute
193 "__attribute__((section(".RamFunc")))".
194*/
195#define __RAM_FUNC HAL_StatusTypeDef __attribute__((section(".RamFunc")))
196
197#endif
198
199/**
200 * @brief __NOINLINE definition
201 */
202#if defined ( __CC_ARM ) || defined ( __GNUC__ )
203/* ARM & GNUCompiler
204 ----------------
205*/
206#define __NOINLINE __attribute__ ( (noinline) )
207
208#elif defined ( __ICCARM__ )
209/* ICCARM Compiler
210 ---------------
211*/
212#define __NOINLINE _Pragma("optimize = no_inline")
213
214#endif
215
216#ifdef __cplusplus
217}
218#endif
219
220#endif /* ___STM32F4xx_HAL_DEF */
221
222/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
HAL_LockTypeDef
HAL Lock structures definition
@ HAL_LOCKED
@ HAL_UNLOCKED