Eya | de129f1 | 2020-01-29 12:19:47 +0100 | [diff] [blame] | 1 | /** |
| 2 | ****************************************************************************** |
| 3 | * @file stm32f1xx_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 | * |
Ali Labbene | f7a58ae | 2022-02-08 14:48:32 +0100 | [diff] [blame] | 10 | * Copyright (c) 2017 STMicroelectronics. |
| 11 | * All rights reserved. |
Eya | de129f1 | 2020-01-29 12:19:47 +0100 | [diff] [blame] | 12 | * |
Ali Labbene | f7a58ae | 2022-02-08 14:48:32 +0100 | [diff] [blame] | 13 | * This software is licensed under terms that can be found in the LICENSE file |
| 14 | * in the root directory of this software component. |
| 15 | * If no LICENSE file comes with this software, it is provided AS-IS. |
Eya | de129f1 | 2020-01-29 12:19:47 +0100 | [diff] [blame] | 16 | * |
| 17 | ****************************************************************************** |
| 18 | */ |
| 19 | |
| 20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
| 21 | #ifndef __STM32F1xx_HAL_DEF |
| 22 | #define __STM32F1xx_HAL_DEF |
| 23 | |
| 24 | #ifdef __cplusplus |
| 25 | extern "C" { |
| 26 | #endif |
| 27 | |
| 28 | /* Includes ------------------------------------------------------------------*/ |
| 29 | #include "stm32f1xx.h" |
Eya | de129f1 | 2020-01-29 12:19:47 +0100 | [diff] [blame] | 30 | #include "Legacy/stm32_hal_legacy.h" |
Eya | de129f1 | 2020-01-29 12:19:47 +0100 | [diff] [blame] | 31 | #include <stddef.h> |
| 32 | |
| 33 | /* Exported types ------------------------------------------------------------*/ |
| 34 | |
| 35 | /** |
| 36 | * @brief HAL Status structures definition |
| 37 | */ |
| 38 | typedef enum |
| 39 | { |
| 40 | HAL_OK = 0x00U, |
| 41 | HAL_ERROR = 0x01U, |
| 42 | HAL_BUSY = 0x02U, |
| 43 | HAL_TIMEOUT = 0x03U |
| 44 | } HAL_StatusTypeDef; |
| 45 | |
| 46 | /** |
| 47 | * @brief HAL Lock structures definition |
| 48 | */ |
| 49 | typedef enum |
| 50 | { |
| 51 | HAL_UNLOCKED = 0x00U, |
| 52 | HAL_LOCKED = 0x01U |
| 53 | } HAL_LockTypeDef; |
| 54 | |
| 55 | /* Exported macro ------------------------------------------------------------*/ |
| 56 | #define HAL_MAX_DELAY 0xFFFFFFFFU |
| 57 | |
| 58 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != 0U) |
| 59 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U) |
| 60 | |
| 61 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \ |
| 62 | do{ \ |
| 63 | (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \ |
| 64 | (__DMA_HANDLE__).Parent = (__HANDLE__); \ |
| 65 | } while(0U) |
| 66 | |
Rania JMAI | b2e72c8 | 2023-02-27 14:59:50 +0100 | [diff] [blame] | 67 | #if !defined(UNUSED) |
Eya | de129f1 | 2020-01-29 12:19:47 +0100 | [diff] [blame] | 68 | #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */ |
Rania JMAI | b2e72c8 | 2023-02-27 14:59:50 +0100 | [diff] [blame] | 69 | #endif /* UNUSED */ |
Eya | de129f1 | 2020-01-29 12:19:47 +0100 | [diff] [blame] | 70 | |
| 71 | /** @brief Reset the Handle's State field. |
| 72 | * @param __HANDLE__ specifies the Peripheral Handle. |
| 73 | * @note This macro can be used for the following purpose: |
| 74 | * - When the Handle is declared as local variable; before passing it as parameter |
| 75 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro |
| 76 | * to set to 0 the Handle's "State" field. |
| 77 | * Otherwise, "State" field may have any random value and the first time the function |
| 78 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed |
| 79 | * (i.e. HAL_PPP_MspInit() will not be executed). |
| 80 | * - When there is a need to reconfigure the low level hardware: instead of calling |
| 81 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). |
| 82 | * In this later function, when the Handle's "State" field is set to 0, it will execute the function |
| 83 | * HAL_PPP_MspInit() which will reconfigure the low level hardware. |
| 84 | * @retval None |
| 85 | */ |
| 86 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U) |
| 87 | |
| 88 | #if (USE_RTOS == 1U) |
| 89 | /* Reserved for future use */ |
| 90 | #error "USE_RTOS should be 0 in the current HAL release" |
| 91 | #else |
| 92 | #define __HAL_LOCK(__HANDLE__) \ |
| 93 | do{ \ |
| 94 | if((__HANDLE__)->Lock == HAL_LOCKED) \ |
| 95 | { \ |
| 96 | return HAL_BUSY; \ |
| 97 | } \ |
| 98 | else \ |
| 99 | { \ |
| 100 | (__HANDLE__)->Lock = HAL_LOCKED; \ |
| 101 | } \ |
| 102 | }while (0U) |
| 103 | |
| 104 | #define __HAL_UNLOCK(__HANDLE__) \ |
| 105 | do{ \ |
| 106 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ |
| 107 | }while (0U) |
| 108 | #endif /* USE_RTOS */ |
| 109 | |
rihab kouki | 1dd9d36 | 2020-10-05 09:08:15 +0100 | [diff] [blame] | 110 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ |
| 111 | #ifndef __weak |
| 112 | #define __weak __attribute__((weak)) |
| 113 | #endif |
| 114 | #ifndef __packed |
| 115 | #define __packed __attribute__((packed)) |
| 116 | #endif |
| 117 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ |
Eya | de129f1 | 2020-01-29 12:19:47 +0100 | [diff] [blame] | 118 | #ifndef __weak |
| 119 | #define __weak __attribute__((weak)) |
| 120 | #endif /* __weak */ |
| 121 | #ifndef __packed |
| 122 | #define __packed __attribute__((__packed__)) |
| 123 | #endif /* __packed */ |
| 124 | #endif /* __GNUC__ */ |
| 125 | |
| 126 | |
| 127 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ |
rihab kouki | 1dd9d36 | 2020-10-05 09:08:15 +0100 | [diff] [blame] | 128 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ |
| 129 | #ifndef __ALIGN_BEGIN |
| 130 | #define __ALIGN_BEGIN |
| 131 | #endif |
| 132 | #ifndef __ALIGN_END |
| 133 | #define __ALIGN_END __attribute__ ((aligned (4))) |
| 134 | #endif |
| 135 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ |
Eya | de129f1 | 2020-01-29 12:19:47 +0100 | [diff] [blame] | 136 | #ifndef __ALIGN_END |
| 137 | #define __ALIGN_END __attribute__ ((aligned (4))) |
| 138 | #endif /* __ALIGN_END */ |
| 139 | #ifndef __ALIGN_BEGIN |
| 140 | #define __ALIGN_BEGIN |
| 141 | #endif /* __ALIGN_BEGIN */ |
| 142 | #else |
| 143 | #ifndef __ALIGN_END |
| 144 | #define __ALIGN_END |
| 145 | #endif /* __ALIGN_END */ |
| 146 | #ifndef __ALIGN_BEGIN |
rihab kouki | 1dd9d36 | 2020-10-05 09:08:15 +0100 | [diff] [blame] | 147 | #if defined (__CC_ARM) /* ARM Compiler V5*/ |
Eya | de129f1 | 2020-01-29 12:19:47 +0100 | [diff] [blame] | 148 | #define __ALIGN_BEGIN __align(4) |
| 149 | #elif defined (__ICCARM__) /* IAR Compiler */ |
| 150 | #define __ALIGN_BEGIN |
| 151 | #endif /* __CC_ARM */ |
| 152 | #endif /* __ALIGN_BEGIN */ |
| 153 | #endif /* __GNUC__ */ |
| 154 | |
| 155 | |
| 156 | /** |
| 157 | * @brief __RAM_FUNC definition |
| 158 | */ |
rihab kouki | 1dd9d36 | 2020-10-05 09:08:15 +0100 | [diff] [blame] | 159 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) |
| 160 | /* ARM Compiler V4/V5 and V6 |
| 161 | -------------------------- |
Eya | de129f1 | 2020-01-29 12:19:47 +0100 | [diff] [blame] | 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 |
| 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 |
| 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 __attribute__((section(".RamFunc"))) |
| 185 | |
| 186 | #endif |
| 187 | |
| 188 | /** |
| 189 | * @brief __NOINLINE definition |
| 190 | */ |
rihab kouki | 1dd9d36 | 2020-10-05 09:08:15 +0100 | [diff] [blame] | 191 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined ( __GNUC__ ) |
| 192 | /* ARM V4/V5 and V6 & GNU Compiler |
| 193 | ------------------------------- |
Eya | de129f1 | 2020-01-29 12:19:47 +0100 | [diff] [blame] | 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 /* ___STM32F1xx_HAL_DEF */ |
Rania JMAI | 7bda310 | 2023-04-28 09:43:35 +0100 | [diff] [blame] | 210 | |
| 211 | |