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