1 /** 2 ****************************************************************************** 3 * @file stm32l5xx_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) 2019 STMicroelectronics. 11 * All rights reserved.</center></h2> 12 * 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 17 * 18 ****************************************************************************** 19 */ 20 21 /* Define to prevent recursive inclusion -------------------------------------*/ 22 #ifndef STM32L5xx_HAL_DEF_H 23 #define STM32L5xx_HAL_DEF_H 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 /* Includes ------------------------------------------------------------------*/ 30 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) 31 #include <arm_cmse.h> 32 #endif 33 34 #include "stm32l5xx.h" 35 #include "Legacy/stm32_hal_legacy.h" /* Aliases file for old names compatibility */ 36 #include <stddef.h> 37 38 /* Exported types ------------------------------------------------------------*/ 39 40 /** 41 * @brief HAL Status structures definition 42 */ 43 typedef enum 44 { 45 HAL_OK = 0x00, 46 HAL_ERROR = 0x01, 47 HAL_BUSY = 0x02, 48 HAL_TIMEOUT = 0x03 49 } HAL_StatusTypeDef; 50 51 /** 52 * @brief HAL Lock structures definition 53 */ 54 typedef enum 55 { 56 HAL_UNLOCKED = 0x00, 57 HAL_LOCKED = 0x01 58 } HAL_LockTypeDef; 59 60 /* Exported macros -----------------------------------------------------------*/ 61 62 #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */ 63 64 #define HAL_MAX_DELAY 0xFFFFFFFFU 65 66 #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT)) 67 #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U) 68 69 #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ 70 do{ \ 71 (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ 72 (__DMA_HANDLE__).Parent = (__HANDLE__); \ 73 } while(0) 74 75 /** @brief Reset the Handle's State field. 76 * @param __HANDLE__ specifies the Peripheral Handle. 77 * @note This macro can be used for the following purpose: 78 * - When the Handle is declared as local variable; before passing it as parameter 79 * to HAL_PPP_Init() for the first time, it is mandatory to use this macro 80 * to set to 0 the Handle's "State" field. 81 * Otherwise, "State" field may have any random value and the first time the function 82 * HAL_PPP_Init() is called, the low level hardware initialization will be missed 83 * (i.e. HAL_PPP_MspInit() will not be executed). 84 * - When there is a need to reconfigure the low level hardware: instead of calling 85 * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). 86 * In this later function, when the Handle's "State" field is set to 0, it will execute the function 87 * HAL_PPP_MspInit() which will reconfigure the low level hardware. 88 * @retval None 89 */ 90 #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0) 91 92 #if (USE_RTOS == 1) 93 /* Reserved for future use */ 94 #error " USE_RTOS should be 0 in the current HAL release " 95 #else 96 #define __HAL_LOCK(__HANDLE__) \ 97 do{ \ 98 if((__HANDLE__)->Lock == HAL_LOCKED) \ 99 { \ 100 return HAL_BUSY; \ 101 } \ 102 else \ 103 { \ 104 (__HANDLE__)->Lock = HAL_LOCKED; \ 105 } \ 106 }while (0) 107 108 #define __HAL_UNLOCK(__HANDLE__) \ 109 do{ \ 110 (__HANDLE__)->Lock = HAL_UNLOCKED; \ 111 }while (0) 112 #endif /* USE_RTOS */ 113 114 115 #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ 116 #ifndef __weak 117 #define __weak __attribute__((weak)) 118 #endif 119 #ifndef __packed 120 #define __packed __attribute__((packed)) 121 #endif 122 #elif defined (__GNUC__) /* GNU Compiler */ 123 #ifndef __weak 124 #define __weak __attribute__((weak)) 125 #endif /* __weak */ 126 #ifndef __packed 127 #define __packed __attribute__((__packed__)) 128 #endif /* __packed */ 129 #endif /* __GNUC__ */ 130 131 /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ 132 #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ 133 #ifndef __ALIGN_BEGIN 134 #define __ALIGN_BEGIN 135 #endif 136 #ifndef __ALIGN_END 137 #define __ALIGN_END __attribute__((aligned (4))) 138 #endif 139 #elif defined (__GNUC__) /* GNU Compiler */ 140 #ifndef __ALIGN_END 141 #define __ALIGN_END __attribute__((aligned (4))) 142 #endif /* __ALIGN_END */ 143 #ifndef __ALIGN_BEGIN 144 #define __ALIGN_BEGIN 145 #endif /* __ALIGN_BEGIN */ 146 #else 147 #ifndef __ALIGN_END 148 #define __ALIGN_END 149 #endif /* __ALIGN_END */ 150 #ifndef __ALIGN_BEGIN 151 #if defined (__ICCARM__) /* IAR Compiler */ 152 #define __ALIGN_BEGIN 153 #endif /* __ICCARM__ */ 154 #endif /* __ALIGN_BEGIN */ 155 #endif /* __GNUC__ */ 156 157 /** 158 * @brief __RAM_FUNC definition 159 */ 160 #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) 161 /* ARM Compiler V6 162 --------------- 163 RAM functions are defined using the toolchain options. 164 Functions that are executed in RAM should reside in a separate source module. 165 Using the 'Options for File' dialog you can simply change the 'Code / Const' 166 area of a module to a memory space in physical RAM. 167 Available memory areas are declared in the 'Target' tab of the 'Options for Target' 168 dialog. 169 */ 170 #define __RAM_FUNC 171 172 #elif defined (__ICCARM__) 173 /* ICCARM Compiler 174 --------------- 175 RAM functions are defined using a specific toolchain keyword "__ramfunc". 176 */ 177 #define __RAM_FUNC __ramfunc 178 179 #elif defined (__GNUC__) 180 /* GNU Compiler 181 ------------ 182 RAM functions are defined using a specific toolchain attribute 183 "__attribute__((section(".RamFunc")))". 184 */ 185 #define __RAM_FUNC __attribute__((section(".RamFunc"))) 186 187 #endif 188 189 /** 190 * @brief __NOINLINE definition 191 */ 192 #if (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined (__GNUC__) 193 /* ARM V6 & GNU Compiler 194 --------------------- 195 */ 196 #define __NOINLINE __attribute__((noinline)) 197 198 #elif defined (__ICCARM__) 199 /* ICCARM Compiler 200 --------------- 201 */ 202 #define __NOINLINE _Pragma("optimize = no_inline") 203 204 #endif 205 206 207 #ifdef __cplusplus 208 } 209 #endif 210 211 #endif /* STM32L5xx_HAL_DEF_H */ 212 213 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 214