1 /** 2 ****************************************************************************** 3 * @file stm32l1xx_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 9 * 10 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> 11 * 12 * Redistribution and use in source and binary forms, with or without modification, 13 * are permitted provided that the following conditions are met: 14 * 1. Redistributions of source code must retain the above copyright notice, 15 * this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright notice, 17 * this list of conditions and the following disclaimer in the documentation 18 * and/or other materials provided with the distribution. 19 * 3. Neither the name of STMicroelectronics nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 ****************************************************************************** 35 */ 36 37 /* Define to prevent recursive inclusion -------------------------------------*/ 38 #ifndef __STM32L1xx_HAL_DEF 39 #define __STM32L1xx_HAL_DEF 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 45 /* Includes ------------------------------------------------------------------*/ 46 #include "stm32l1xx.h" 47 #include "Legacy/stm32_hal_legacy.h" 48 #include <stdio.h> 49 50 /* Exported types ------------------------------------------------------------*/ 51 52 /** 53 * @brief HAL Status structures definition 54 */ 55 typedef enum 56 { 57 HAL_OK = 0x00, 58 HAL_ERROR = 0x01, 59 HAL_BUSY = 0x02, 60 HAL_TIMEOUT = 0x03 61 } HAL_StatusTypeDef; 62 63 /** 64 * @brief HAL Lock structures definition 65 */ 66 typedef enum 67 { 68 HAL_UNLOCKED = 0x00, 69 HAL_LOCKED = 0x01 70 } HAL_LockTypeDef; 71 72 /* Exported macro ------------------------------------------------------------*/ 73 74 #define HAL_MAX_DELAY 0xFFFFFFFFU 75 76 #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != RESET) 77 #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET) 78 79 #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD_, __DMA_HANDLE_) \ 80 do{ \ 81 (__HANDLE__)->__PPP_DMA_FIELD_ = &(__DMA_HANDLE_); \ 82 (__DMA_HANDLE_).Parent = (__HANDLE__); \ 83 } while(0) 84 85 #define UNUSED(x) ((void)(x)) 86 87 /** @brief Reset the Handle's State field. 88 * @param __HANDLE__: specifies the Peripheral Handle. 89 * @note This macro can be used for the following purpose: 90 * - When the Handle is declared as local variable; before passing it as parameter 91 * to HAL_PPP_Init() for the first time, it is mandatory to use this macro 92 * to set to 0 the Handle's "State" field. 93 * Otherwise, "State" field may have any random value and the first time the function 94 * HAL_PPP_Init() is called, the low level hardware initialization will be missed 95 * (i.e. HAL_PPP_MspInit() will not be executed). 96 * - When there is a need to reconfigure the low level hardware: instead of calling 97 * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). 98 * In this later function, when the Handle's "State" field is set to 0, it will execute the function 99 * HAL_PPP_MspInit() which will reconfigure the low level hardware. 100 * @retval None 101 */ 102 #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0) 103 104 #if (USE_RTOS == 1) 105 #error " USE_RTOS should be 0 in the current HAL release " 106 #else 107 #define __HAL_LOCK(__HANDLE__) \ 108 do{ \ 109 if((__HANDLE__)->Lock == HAL_LOCKED) \ 110 { \ 111 return HAL_BUSY; \ 112 } \ 113 else \ 114 { \ 115 (__HANDLE__)->Lock = HAL_LOCKED; \ 116 } \ 117 }while (0) 118 119 #define __HAL_UNLOCK(__HANDLE__) \ 120 do{ \ 121 (__HANDLE__)->Lock = HAL_UNLOCKED; \ 122 }while (0) 123 #endif /* USE_RTOS */ 124 125 #if defined ( __GNUC__ ) 126 #ifndef __weak 127 #define __weak __attribute__((weak)) 128 #endif /* __weak */ 129 #ifndef __packed 130 #define __packed __attribute__((__packed__)) 131 #endif /* __packed */ 132 #endif /* __GNUC__ */ 133 134 135 /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ 136 #if defined (__GNUC__) /* GNU Compiler */ 137 #ifndef __ALIGN_END 138 #define __ALIGN_END __attribute__ ((aligned (4))) 139 #endif /* __ALIGN_END */ 140 #ifndef __ALIGN_BEGIN 141 #define __ALIGN_BEGIN 142 #endif /* __ALIGN_BEGIN */ 143 #else 144 #ifndef __ALIGN_END 145 #define __ALIGN_END 146 #endif /* __ALIGN_END */ 147 #ifndef __ALIGN_BEGIN 148 #if defined (__CC_ARM) /* ARM Compiler */ 149 #define __ALIGN_BEGIN __align(4) 150 #elif defined (__ICCARM__) /* IAR Compiler */ 151 #define __ALIGN_BEGIN 152 #endif /* __CC_ARM */ 153 #endif /* __ALIGN_BEGIN */ 154 #endif /* __GNUC__ */ 155 156 /** 157 * @brief __RAM_FUNC definition 158 */ 159 #if defined ( __CC_ARM ) 160 /* ARM Compiler 161 ------------ 162 RAM functions are defined using the toolchain options. 163 Functions that are executed in RAM should reside in a separate source module. 164 Using the 'Options for File' dialog you can simply change the 'Code / Const' 165 area of a module to a memory space in physical RAM. 166 Available memory areas are declared in the 'Target' tab of the 'Options for Target' 167 dialog. 168 */ 169 #define __RAM_FUNC HAL_StatusTypeDef 170 171 #elif defined ( __ICCARM__ ) 172 /* ICCARM Compiler 173 --------------- 174 RAM functions are defined using a specific toolchain keyword "__ramfunc". 175 */ 176 #define __RAM_FUNC __ramfunc HAL_StatusTypeDef 177 178 #elif defined ( __GNUC__ ) 179 /* GNU Compiler 180 ------------ 181 RAM functions are defined using a specific toolchain attribute 182 "__attribute__((section(".RamFunc")))". 183 */ 184 #define __RAM_FUNC HAL_StatusTypeDef __attribute__((section(".RamFunc"))) 185 186 #endif 187 188 /** 189 * @brief __NOINLINE definition 190 */ 191 #if defined ( __CC_ARM ) || defined ( __GNUC__ ) 192 /* ARM & GNUCompiler 193 ---------------- 194 */ 195 #define __NOINLINE __attribute__ ( (noinline) ) 196 197 #elif defined ( __ICCARM__ ) 198 /* ICCARM Compiler 199 --------------- 200 */ 201 #define __NOINLINE _Pragma("optimize = no_inline") 202 203 #endif 204 205 #ifdef __cplusplus 206 } 207 #endif 208 209 #endif /* ___STM32L1xx_HAL_DEF */ 210 211 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 212