2 ******************************************************************************
3 * @file stm32l0xx_hal_def.h
4 * @author MCD Application Team
6 * @date 06-February-2015
7 * @brief This file contains HAL common defines, enumeration, macros and
8 * structures definitions.
9 ******************************************************************************
12 * <h2><center>© COPYRIGHT(c) 2015 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 __STM32L0xx_HAL_DEF
41 #define __STM32L0xx_HAL_DEF
47 /* Includes ------------------------------------------------------------------*/
48 #include "stm32l0xx.h"
49 #include "stm32_hal_legacy.h"
52 /* Exported types ------------------------------------------------------------*/
55 * @brief HAL Status structures definition
66 * @brief HAL Lock structures definition
74 /* Exported macro ------------------------------------------------------------*/
76 #define UNUSED(x) ((void)(x))
78 #define HAL_MAX_DELAY 0xFFFFFFFF
80 #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != RESET)
81 #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET)
83 #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \
85 (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
86 (__DMA_HANDLE__).Parent = (__HANDLE__); \
89 /** @brief Reset the Handle's State field.
90 * @param __HANDLE__: specifies the Peripheral Handle.
91 * @note This macro can be used for the following purpose:
92 * - When the Handle is declared as local variable; before passing it as parameter
93 * to HAL_PPP_Init() for the first time, it is mandatory to use this macro
94 * to set to 0 the Handle's "State" field.
95 * Otherwise, "State" field may have any random value and the first time the function
96 * HAL_PPP_Init() is called, the low level hardware initialization will be missed
97 * (i.e. HAL_PPP_MspInit() will not be executed).
98 * - When there is a need to reconfigure the low level hardware: instead of calling
99 * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
100 * In this later function, when the Handle's "State" field is set to 0, it will execute the function
101 * HAL_PPP_MspInit() which will reconfigure the low level hardware.
104 #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0)
108 /* Reserved for future use */
109 #error
\93USE_RTOS should be 0 in the current HAL release
\94
112 #define __HAL_LOCK(__HANDLE__) \
114 if((__HANDLE__)->Lock == HAL_LOCKED) \
120 (__HANDLE__)->Lock = HAL_LOCKED; \
124 #define __HAL_UNLOCK(__HANDLE__) \
126 (__HANDLE__)->Lock = HAL_UNLOCKED; \
128 #endif /* USE_RTOS */
130 #if defined ( __GNUC__ )
132 #define __weak __attribute__((weak))
135 #define __packed __attribute__((__packed__))
136 #endif /* __packed */
138 #define __NOINLINE __attribute__ ( (noinline) )
140 #endif /* __GNUC__ */
143 /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
144 #if defined (__GNUC__) /* GNU Compiler */
146 #define __ALIGN_END __attribute__ ((aligned (4)))
147 #endif /* __ALIGN_END */
148 #ifndef __ALIGN_BEGIN
149 #define __ALIGN_BEGIN
150 #endif /* __ALIGN_BEGIN */
154 #endif /* __ALIGN_END */
155 #ifndef __ALIGN_BEGIN
156 #if defined (__CC_ARM) /* ARM Compiler */
157 #define __ALIGN_BEGIN __align(4)
158 #elif defined (__ICCARM__) /* IAR Compiler */
159 #define __ALIGN_BEGIN
160 #endif /* __CC_ARM */
161 #endif /* __ALIGN_BEGIN */
162 #endif /* __GNUC__ */
165 * @brief __RAM_FUNC definition
167 #if defined ( __CC_ARM )
170 RAM functions are defined using the toolchain options.
171 Functions that are executed in RAM should reside in a separate source module.
172 Using the 'Options for File' dialog you can simply change the 'Code / Const'
173 area of a module to a memory space in physical RAM.
174 Available memory areas are declared in the 'Target' tab of the 'Options for Target'
177 #define __RAM_FUNC HAL_StatusTypeDef
179 #define __NOINLINE __attribute__ ( (noinline) )
182 #elif defined ( __ICCARM__ )
185 RAM functions are defined using a specific toolchain keyword "__ramfunc".
187 #define __RAM_FUNC __ramfunc HAL_StatusTypeDef
189 #define __NOINLINE _Pragma("optimize = no_inline")
191 #elif defined ( __GNUC__ )
194 RAM functions are defined using a specific toolchain attribute
195 "__attribute__((section(".RamFunc")))".
197 #define __RAM_FUNC HAL_StatusTypeDef __attribute__((section(".RamFunc")))
205 #endif /* ___STM32L0xx_HAL_DEF */
207 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/