Merge pull request #11189 from klutvott123/move-telemetry-displayport-init
[betaflight.git] / lib / main / STM32G4 / Drivers / STM32G4xx_HAL_Driver / Inc / stm32g4xx_hal_def.h
blob99e6696c710707e557f774fce7bb39fbc84db667
1 /**
2 ******************************************************************************
3 * @file stm32g4xx_hal_def.h
4 * @author MCD Application Team
5 * @brief This file contains HAL common defines, enumeration, macros and
6 * structures definitions.
7 ******************************************************************************
8 * @attention
10 * <h2><center>&copy; Copyright (c) 2018 STMicroelectronics.
11 * All rights reserved.</center></h2>
13 * This software component is licensed by ST under BSD 3-Clause license,
14 * the "License"; You may not use this file except in compliance with the
15 * License. You may obtain a copy of the License at:
16 * opensource.org/licenses/BSD-3-Clause
18 ******************************************************************************
21 /* Define to prevent recursive inclusion -------------------------------------*/
22 #ifndef __STM32G4xx_HAL_DEF
23 #define __STM32G4xx_HAL_DEF
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
29 /* Includes ------------------------------------------------------------------*/
30 #include "stm32g4xx.h"
31 #include "Legacy/stm32_hal_legacy.h" /* Aliases file for old names compatibility */
32 #include <stddef.h>
34 /* Exported types ------------------------------------------------------------*/
36 /**
37 * @brief HAL Status structures definition
39 typedef enum
41 HAL_OK = 0x00U,
42 HAL_ERROR = 0x01U,
43 HAL_BUSY = 0x02U,
44 HAL_TIMEOUT = 0x03U
45 } HAL_StatusTypeDef;
47 /**
48 * @brief HAL Lock structures definition
50 typedef enum
52 HAL_UNLOCKED = 0x00U,
53 HAL_LOCKED = 0x01U
54 } HAL_LockTypeDef;
56 /* Exported macros -----------------------------------------------------------*/
58 #define HAL_MAX_DELAY 0xFFFFFFFFU
60 #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT))
61 #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U)
63 #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \
64 do{ \
65 (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
66 (__DMA_HANDLE__).Parent = (__HANDLE__); \
67 } while(0)
69 #define UNUSED(X) (void)X
71 /** @brief Reset the Handle's State field.
72 * @param __HANDLE__: specifies the Peripheral Handle.
73 * @note This macro can be used for the following purpose:
74 * - When the Handle is declared as local variable; before passing it as parameter
75 * to HAL_PPP_Init() for the first time, it is mandatory to use this macro
76 * to set to 0 the Handle's "State" field.
77 * Otherwise, "State" field may have any random value and the first time the function
78 * HAL_PPP_Init() is called, the low level hardware initialization will be missed
79 * (i.e. HAL_PPP_MspInit() will not be executed).
80 * - When there is a need to reconfigure the low level hardware: instead of calling
81 * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
82 * In this later function, when the Handle's "State" field is set to 0, it will execute the function
83 * HAL_PPP_MspInit() which will reconfigure the low level hardware.
84 * @retval None
86 #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0)
88 #if (USE_RTOS == 1U)
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; \
102 }while (0U)
104 #define __HAL_UNLOCK(__HANDLE__) \
105 do{ \
106 (__HANDLE__)->Lock = HAL_UNLOCKED; \
107 }while (0U)
108 #endif /* USE_RTOS */
110 #if defined ( __GNUC__ )
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__ */
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__) /* GNU Compiler */
122 #ifndef __ALIGN_END
123 #define __ALIGN_END __attribute__ ((aligned (4U)))
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(4U)
135 #elif defined (__ICCARM__) /* IAR Compiler */
136 #define __ALIGN_BEGIN
137 #endif /* __CC_ARM */
138 #endif /* __ALIGN_BEGIN */
139 #endif /* __GNUC__ */
142 * @brief __RAM_FUNC definition
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.
154 #define __RAM_FUNC
156 #elif defined ( __ICCARM__ )
157 /* ICCARM Compiler
158 ---------------
159 RAM functions are defined using a specific toolchain keyword "__ramfunc".
161 #define __RAM_FUNC __ramfunc
163 #elif defined ( __GNUC__ )
164 /* GNU Compiler
165 ------------
166 RAM functions are defined using a specific toolchain attribute
167 "__attribute__((section(".RamFunc")))".
169 #define __RAM_FUNC __attribute__((section(".RamFunc")))
171 #endif /* __CC_ARM */
174 * @brief __NOINLINE definition
176 #if defined ( __CC_ARM ) || defined ( __GNUC__ )
177 /* ARM & GNUCompiler
178 ----------------
180 #define __NOINLINE __attribute__ ( (noinline) )
182 #elif defined ( __ICCARM__ )
183 /* ICCARM Compiler
184 ---------------
186 #define __NOINLINE _Pragma("optimize = no_inline")
188 #endif /* __CC_ARM || __GNUC__ */
191 #ifdef __cplusplus
193 #endif
195 #endif /* ___STM32G4xx_HAL_DEF */
197 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/