Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
stm32l4xx_hal_def.h
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_hal_def.h 00004 * @author MCD Application Team 00005 * @version V1.5.1 00006 * @date 31-May-2016 00007 * @brief This file contains HAL common defines, enumeration, macros and 00008 * structures definitions. 00009 ****************************************************************************** 00010 * @attention 00011 * 00012 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> 00013 * 00014 * Redistribution and use in source and binary forms, with or without modification, 00015 * are permitted provided that the following conditions are met: 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 2. Redistributions in binary form must reproduce the above copyright notice, 00019 * this list of conditions and the following disclaimer in the documentation 00020 * and/or other materials provided with the distribution. 00021 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00022 * may be used to endorse or promote products derived from this software 00023 * without specific prior written permission. 00024 * 00025 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00026 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00028 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00029 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00030 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00031 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00032 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00033 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00034 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 ****************************************************************************** 00037 */ 00038 00039 /* Define to prevent recursive inclusion -------------------------------------*/ 00040 #ifndef __STM32L4xx_HAL_DEF 00041 #define __STM32L4xx_HAL_DEF 00042 00043 #ifdef __cplusplus 00044 extern "C" { 00045 #endif 00046 00047 /* Includes ------------------------------------------------------------------*/ 00048 #include "stm32l4xx.h" 00049 #include "stm32_hal_legacy.h" /* Aliases file for old names compatibility */ 00050 #include <stdio.h> 00051 00052 /* Exported types ------------------------------------------------------------*/ 00053 00054 /** 00055 * @brief HAL Status structures definition 00056 */ 00057 typedef enum 00058 { 00059 HAL_OK = 0x00, 00060 HAL_ERROR = 0x01, 00061 HAL_BUSY = 0x02, 00062 HAL_TIMEOUT = 0x03 00063 } HAL_StatusTypeDef; 00064 00065 /** 00066 * @brief HAL Lock structures definition 00067 */ 00068 typedef enum 00069 { 00070 HAL_UNLOCKED = 0x00, 00071 HAL_LOCKED = 0x01 00072 } HAL_LockTypeDef; 00073 00074 /* Exported macros -----------------------------------------------------------*/ 00075 00076 #define HAL_MAX_DELAY 0xFFFFFFFFU 00077 00078 #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT)) 00079 #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET) 00080 00081 #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ 00082 do{ \ 00083 (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ 00084 (__DMA_HANDLE__).Parent = (__HANDLE__); \ 00085 } while(0) 00086 00087 #define UNUSED(x) ((void)(x)) 00088 00089 /** @brief Reset the Handle's State field. 00090 * @param __HANDLE__: specifies the Peripheral Handle. 00091 * @note This macro can be used for the following purpose: 00092 * - When the Handle is declared as local variable; before passing it as parameter 00093 * to HAL_PPP_Init() for the first time, it is mandatory to use this macro 00094 * to set to 0 the Handle's "State" field. 00095 * Otherwise, "State" field may have any random value and the first time the function 00096 * HAL_PPP_Init() is called, the low level hardware initialization will be missed 00097 * (i.e. HAL_PPP_MspInit() will not be executed). 00098 * - When there is a need to reconfigure the low level hardware: instead of calling 00099 * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). 00100 * In this later function, when the Handle's "State" field is set to 0, it will execute the function 00101 * HAL_PPP_MspInit() which will reconfigure the low level hardware. 00102 * @retval None 00103 */ 00104 #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0) 00105 00106 #if (USE_RTOS == 1) 00107 /* Reserved for future use */ 00108 #error " USE_RTOS should be 0 in the current HAL release " 00109 #else 00110 #define __HAL_LOCK(__HANDLE__) \ 00111 do{ \ 00112 if((__HANDLE__)->Lock == HAL_LOCKED) \ 00113 { \ 00114 return HAL_BUSY; \ 00115 } \ 00116 else \ 00117 { \ 00118 (__HANDLE__)->Lock = HAL_LOCKED; \ 00119 } \ 00120 }while (0) 00121 00122 #define __HAL_UNLOCK(__HANDLE__) \ 00123 do{ \ 00124 (__HANDLE__)->Lock = HAL_UNLOCKED; \ 00125 }while (0) 00126 #endif /* USE_RTOS */ 00127 #if defined (__CC_ARM) 00128 #pragma diag_suppress 3731 00129 #endif 00130 00131 static inline void atomic_set_u32(volatile uint32_t *ptr, uint32_t mask) 00132 { 00133 uint32_t newValue; 00134 do { 00135 newValue = (uint32_t)__LDREXW((volatile unsigned long *)ptr) | mask; 00136 00137 } while (__STREXW(newValue,(volatile unsigned long*) ptr)); 00138 } 00139 00140 00141 static inline void atomic_clr_u32(volatile uint32_t *ptr, uint32_t mask) 00142 { 00143 uint32_t newValue; 00144 do { 00145 newValue = (uint32_t)__LDREXW((volatile unsigned long *)ptr) &~mask; 00146 00147 } while (__STREXW(newValue,(volatile unsigned long*) ptr)); 00148 } 00149 00150 #if defined ( __GNUC__ ) 00151 #ifndef __weak 00152 #define __weak __attribute__((weak)) 00153 #endif /* __weak */ 00154 #ifndef __packed 00155 #define __packed __attribute__((__packed__)) 00156 #endif /* __packed */ 00157 #endif /* __GNUC__ */ 00158 00159 00160 /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ 00161 #if defined (__GNUC__) /* GNU Compiler */ 00162 #ifndef __ALIGN_END 00163 #define __ALIGN_END __attribute__ ((aligned (4))) 00164 #endif /* __ALIGN_END */ 00165 #ifndef __ALIGN_BEGIN 00166 #define __ALIGN_BEGIN 00167 #endif /* __ALIGN_BEGIN */ 00168 #else 00169 #ifndef __ALIGN_END 00170 #define __ALIGN_END 00171 #endif /* __ALIGN_END */ 00172 #ifndef __ALIGN_BEGIN 00173 #if defined (__CC_ARM) /* ARM Compiler */ 00174 #define __ALIGN_BEGIN __align(4) 00175 #elif defined (__ICCARM__) /* IAR Compiler */ 00176 #define __ALIGN_BEGIN 00177 #endif /* __CC_ARM */ 00178 #endif /* __ALIGN_BEGIN */ 00179 #endif /* __GNUC__ */ 00180 00181 /** 00182 * @brief __RAM_FUNC definition 00183 */ 00184 #if defined ( __CC_ARM ) 00185 /* ARM Compiler 00186 ------------ 00187 RAM functions are defined using the toolchain options. 00188 Functions that are executed in RAM should reside in a separate source module. 00189 Using the 'Options for File' dialog you can simply change the 'Code / Const' 00190 area of a module to a memory space in physical RAM. 00191 Available memory areas are declared in the 'Target' tab of the 'Options for Target' 00192 dialog. 00193 */ 00194 #define __RAM_FUNC HAL_StatusTypeDef 00195 00196 #elif defined ( __ICCARM__ ) 00197 /* ICCARM Compiler 00198 --------------- 00199 RAM functions are defined using a specific toolchain keyword "__ramfunc". 00200 */ 00201 #define __RAM_FUNC __ramfunc HAL_StatusTypeDef 00202 00203 #elif defined ( __GNUC__ ) 00204 /* GNU Compiler 00205 ------------ 00206 RAM functions are defined using a specific toolchain attribute 00207 "__attribute__((section(".RamFunc")))". 00208 */ 00209 #define __RAM_FUNC HAL_StatusTypeDef __attribute__((section(".RamFunc"))) 00210 00211 #endif 00212 00213 /** 00214 * @brief __NOINLINE definition 00215 */ 00216 #if defined ( __CC_ARM ) || defined ( __GNUC__ ) 00217 /* ARM & GNUCompiler 00218 ---------------- 00219 */ 00220 #define __NOINLINE __attribute__ ( (noinline) ) 00221 00222 #elif defined ( __ICCARM__ ) 00223 /* ICCARM Compiler 00224 --------------- 00225 */ 00226 #define __NOINLINE _Pragma("optimize = no_inline") 00227 00228 #endif 00229 00230 00231 #ifdef __cplusplus 00232 } 00233 #endif 00234 00235 #endif /* ___STM32L4xx_HAL_DEF */ 00236 00237 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 10:59:57 by
