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