2 ******************************************************************************
\r
3 * @file stm32l4xx_hal_def.h
\r
4 * @author MCD Application Team
\r
5 * @brief This file contains HAL common defines, enumeration, macros and
\r
6 * structures definitions.
\r
7 ******************************************************************************
\r
10 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
\r
11 * All rights reserved.</center></h2>
\r
13 * This software component is licensed by ST under BSD 3-Clause license,
\r
14 * the "License"; You may not use this file except in compliance with the
\r
15 * License. You may obtain a copy of the License at:
\r
16 * opensource.org/licenses/BSD-3-Clause
\r
18 ******************************************************************************
\r
21 /* Define to prevent recursive inclusion -------------------------------------*/
\r
22 #ifndef STM32L4xx_HAL_DEF_H
\r
23 #define STM32L4xx_HAL_DEF_H
\r
29 /* Includes ------------------------------------------------------------------*/
\r
30 #include "stm32l4xx.h"
\r
31 #include "Legacy/stm32_hal_legacy.h" /* Aliases file for old names compatibility */
\r
34 /* Exported types ------------------------------------------------------------*/
\r
37 * @brief HAL Status structures definition
\r
45 } HAL_StatusTypeDef;
\r
48 * @brief HAL Lock structures definition
\r
52 HAL_UNLOCKED = 0x00,
\r
56 /* Exported macros -----------------------------------------------------------*/
\r
58 #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */
\r
60 #define HAL_MAX_DELAY 0xFFFFFFFFU
\r
62 #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT))
\r
63 #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U)
\r
65 #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \
\r
67 (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
\r
68 (__DMA_HANDLE__).Parent = (__HANDLE__); \
\r
71 /** @brief Reset the Handle's State field.
\r
72 * @param __HANDLE__: specifies the Peripheral Handle.
\r
73 * @note This macro can be used for the following purpose:
\r
74 * - When the Handle is declared as local variable; before passing it as parameter
\r
75 * to HAL_PPP_Init() for the first time, it is mandatory to use this macro
\r
76 * to set to 0 the Handle's "State" field.
\r
77 * Otherwise, "State" field may have any random value and the first time the function
\r
78 * HAL_PPP_Init() is called, the low level hardware initialization will be missed
\r
79 * (i.e. HAL_PPP_MspInit() will not be executed).
\r
80 * - When there is a need to reconfigure the low level hardware: instead of calling
\r
81 * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
\r
82 * In this later function, when the Handle's "State" field is set to 0, it will execute the function
\r
83 * HAL_PPP_MspInit() which will reconfigure the low level hardware.
\r
86 #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0)
\r
89 /* Reserved for future use */
\r
90 #error " USE_RTOS should be 0 in the current HAL release "
\r
92 #define __HAL_LOCK(__HANDLE__) \
\r
94 if((__HANDLE__)->Lock == HAL_LOCKED) \
\r
100 (__HANDLE__)->Lock = HAL_LOCKED; \
\r
104 #define __HAL_UNLOCK(__HANDLE__) \
\r
106 (__HANDLE__)->Lock = HAL_UNLOCKED; \
\r
108 #endif /* USE_RTOS */
\r
110 #if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
\r
112 #define __weak __attribute__((weak))
\r
113 #endif /* __weak */
\r
115 #define __packed __attribute__((__packed__))
\r
116 #endif /* __packed */
\r
117 #endif /* __GNUC__ */
\r
120 /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
\r
121 #if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
\r
122 #ifndef __ALIGN_END
\r
123 #define __ALIGN_END __attribute__ ((aligned (4)))
\r
124 #endif /* __ALIGN_END */
\r
125 #ifndef __ALIGN_BEGIN
\r
126 #define __ALIGN_BEGIN
\r
127 #endif /* __ALIGN_BEGIN */
\r
129 #ifndef __ALIGN_END
\r
130 #define __ALIGN_END
\r
131 #endif /* __ALIGN_END */
\r
132 #ifndef __ALIGN_BEGIN
\r
133 #if defined (__CC_ARM) /* ARM Compiler */
\r
134 #define __ALIGN_BEGIN __align(4)
\r
135 #elif defined (__ICCARM__) /* IAR Compiler */
\r
136 #define __ALIGN_BEGIN
\r
137 #endif /* __CC_ARM */
\r
138 #endif /* __ALIGN_BEGIN */
\r
139 #endif /* __GNUC__ */
\r
142 * @brief __RAM_FUNC definition
\r
144 #if defined ( __CC_ARM )
\r
147 RAM functions are defined using the toolchain options.
\r
148 Functions that are executed in RAM should reside in a separate source module.
\r
149 Using the 'Options for File' dialog you can simply change the 'Code / Const'
\r
150 area of a module to a memory space in physical RAM.
\r
151 Available memory areas are declared in the 'Target' tab of the 'Options for Target'
\r
154 #define __RAM_FUNC HAL_StatusTypeDef
\r
156 #elif defined ( __ICCARM__ )
\r
159 RAM functions are defined using a specific toolchain keyword "__ramfunc".
\r
161 #define __RAM_FUNC __ramfunc HAL_StatusTypeDef
\r
163 #elif defined ( __GNUC__ )
\r
166 RAM functions are defined using a specific toolchain attribute
\r
167 "__attribute__((section(".RamFunc")))".
\r
169 #define __RAM_FUNC HAL_StatusTypeDef __attribute__((section(".RamFunc")))
\r
174 * @brief __NOINLINE definition
\r
176 #if defined ( __CC_ARM ) || defined ( __GNUC__ )
\r
177 /* ARM & GNUCompiler
\r
180 #define __NOINLINE __attribute__ ( (noinline) )
\r
182 #elif defined ( __ICCARM__ )
\r
186 #define __NOINLINE _Pragma("optimize = no_inline")
\r
195 #endif /* STM32L4xx_HAL_DEF_H */
\r
197 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r