Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 28 | ||
---|---|---|---|
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 | * @version V1.2.0 |
- | |
6 | * @date 01-July-2016 |
- | |
7 | * @brief This file contains HAL common defines, enumeration, macros and |
5 | * @brief This file contains HAL common defines, enumeration, macros and |
8 | * structures definitions. |
6 | * structures definitions. |
9 | ****************************************************************************** |
7 | ****************************************************************************** |
10 | * @attention |
8 | * @attention |
11 | * |
9 | * |
12 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
10 | * <h2><center>© Copyright (c) 2017 STMicroelectronics. |
- | 11 | * All rights reserved.</center></h2> |
|
13 | * |
12 | * |
14 | * Redistribution and use in source and binary forms, with or without modification, |
13 | * This software component is licensed by ST under BSD 3-Clause license, |
15 | * are permitted provided that the following conditions are met: |
14 | * the "License"; You may not use this file except in compliance with the |
16 | * 1. Redistributions of source code must retain the above copyright notice, |
- | |
17 | * this list of conditions and the following disclaimer. |
- | |
18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
- | |
19 | * this list of conditions and the following disclaimer in the documentation |
- | |
20 | * and/or other materials provided with the distribution. |
15 | * License. You may obtain a copy of the License at: |
21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
- | |
22 | * may be used to endorse or promote products derived from this software |
16 | * opensource.org/licenses/BSD-3-Clause |
23 | * without specific prior written permission. |
- | |
24 | * |
- | |
25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
- | |
26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
- | |
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
- | |
28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
- | |
29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
- | |
30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
- | |
31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
- | |
32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
- | |
33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
- | |
34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
- | |
35 | * |
17 | * |
36 | ****************************************************************************** |
18 | ****************************************************************************** |
37 | */ |
19 | */ |
38 | 20 | ||
39 | /* Define to prevent recursive inclusion -------------------------------------*/ |
21 | /* Define to prevent recursive inclusion -------------------------------------*/ |
Line 45... | Line 27... | ||
45 | #endif |
27 | #endif |
46 | 28 | ||
47 | /* Includes ------------------------------------------------------------------*/ |
29 | /* Includes ------------------------------------------------------------------*/ |
48 | #include "stm32l1xx.h" |
30 | #include "stm32l1xx.h" |
49 | #include "Legacy/stm32_hal_legacy.h" |
31 | #include "Legacy/stm32_hal_legacy.h" |
50 | #include <stdio.h> |
32 | #include <stddef.h> |
51 | 33 | ||
52 | /* Exported types ------------------------------------------------------------*/ |
34 | /* Exported types ------------------------------------------------------------*/ |
53 | 35 | ||
54 | /** |
36 | /** |
55 | * @brief HAL Status structures definition |
37 | * @brief HAL Status structures definition |
56 | */ |
38 | */ |
57 | typedef enum |
39 | typedef enum |
58 | { |
40 | { |
59 | HAL_OK = 0x00, |
41 | HAL_OK = 0x00U, |
60 | HAL_ERROR = 0x01, |
42 | HAL_ERROR = 0x01U, |
61 | HAL_BUSY = 0x02, |
43 | HAL_BUSY = 0x02U, |
62 | HAL_TIMEOUT = 0x03 |
44 | HAL_TIMEOUT = 0x03U |
63 | } HAL_StatusTypeDef; |
45 | } HAL_StatusTypeDef; |
64 | 46 | ||
65 | /** |
47 | /** |
66 | * @brief HAL Lock structures definition |
48 | * @brief HAL Lock structures definition |
67 | */ |
49 | */ |
68 | typedef enum |
50 | typedef enum |
69 | { |
51 | { |
70 | HAL_UNLOCKED = 0x00, |
52 | HAL_UNLOCKED = 0x00U, |
71 | HAL_LOCKED = 0x01 |
53 | HAL_LOCKED = 0x01U |
72 | } HAL_LockTypeDef; |
54 | } HAL_LockTypeDef; |
73 | 55 | ||
74 | /* Exported macro ------------------------------------------------------------*/ |
56 | /* Exported macro ------------------------------------------------------------*/ |
75 | 57 | ||
- | 58 | #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */ |
|
- | 59 | ||
76 | #define HAL_MAX_DELAY 0xFFFFFFFFU |
60 | #define HAL_MAX_DELAY 0xFFFFFFFFU |
77 | 61 | ||
78 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != RESET) |
62 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT)) |
79 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET) |
63 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U) |
80 | 64 | ||
81 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD_, __DMA_HANDLE_) \ |
65 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD_, __DMA_HANDLE_) \ |
82 | do{ \ |
66 | do{ \ |
83 | (__HANDLE__)->__PPP_DMA_FIELD_ = &(__DMA_HANDLE_); \ |
67 | (__HANDLE__)->__PPP_DMA_FIELD_ = &(__DMA_HANDLE_); \ |
84 | (__DMA_HANDLE_).Parent = (__HANDLE__); \ |
68 | (__DMA_HANDLE_).Parent = (__HANDLE__); \ |
85 | } while(0) |
69 | } while(0) |
86 | 70 | ||
87 | #define UNUSED(x) ((void)(x)) |
- | |
88 | - | ||
89 | /** @brief Reset the Handle's State field. |
71 | /** @brief Reset the Handle's State field. |
90 | * @param __HANDLE__: specifies the Peripheral Handle. |
72 | * @param __HANDLE__: specifies the Peripheral Handle. |
91 | * @note This macro can be used for the following purpose: |
73 | * @note This macro can be used for the following purpose: |
92 | * - When the Handle is declared as local variable; before passing it as parameter |
74 | * - When the Handle is declared as local variable; before passing it as parameter |
93 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro |
75 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro |
94 | * to set to 0 the Handle's "State" field. |
76 | * to set to 0 the Handle's "State" field. |
95 | * Otherwise, "State" field may have any random value and the first time the function |
77 | * Otherwise, "State" field may have any random value and the first time the function |
96 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed |
78 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed |
97 | * (i.e. HAL_PPP_MspInit() will not be executed). |
79 | * (i.e. HAL_PPP_MspInit() will not be executed). |
98 | * - When there is a need to reconfigure the low level hardware: instead of calling |
80 | * - When there is a need to reconfigure the low level hardware: instead of calling |
99 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). |
81 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init(). |
100 | * In this later function, when the Handle's "State" field is set to 0, it will execute the function |
82 | * In this later function, when the Handle's "State" field is set to 0, it will execute the function |
101 | * HAL_PPP_MspInit() which will reconfigure the low level hardware. |
83 | * HAL_PPP_MspInit() which will reconfigure the low level hardware. |
102 | * @retval None |
84 | * @retval None |
103 | */ |
85 | */ |
104 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0) |
86 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U) |
105 | 87 | ||
106 | #if (USE_RTOS == 1) |
88 | #if (USE_RTOS == 1) |
- | 89 | ||
- | 90 | /* Reserved for future use */ |
|
107 | #error " USE_RTOS should be 0 in the current HAL release " |
91 | #error "USE_RTOS should be 0 in the current HAL release" |
- | 92 | ||
108 | #else |
93 | #else |
109 | #define __HAL_LOCK(__HANDLE__) \ |
94 | #define __HAL_LOCK(__HANDLE__) \ |
110 | do{ \ |
95 | do{ \ |
111 | if((__HANDLE__)->Lock == HAL_LOCKED) \ |
96 | if((__HANDLE__)->Lock == HAL_LOCKED) \ |
112 | { \ |
97 | { \ |
113 | return HAL_BUSY; \ |
98 | return HAL_BUSY; \ |
114 | } \ |
99 | } \ |
115 | else \ |
100 | else \ |
116 | { \ |
101 | { \ |
117 | (__HANDLE__)->Lock = HAL_LOCKED; \ |
102 | (__HANDLE__)->Lock = HAL_LOCKED; \ |
118 | } \ |
103 | } \ |
119 | }while (0) |
104 | }while (0) |
120 | 105 | ||
121 | #define __HAL_UNLOCK(__HANDLE__) \ |
106 | #define __HAL_UNLOCK(__HANDLE__) \ |
122 | do{ \ |
107 | do{ \ |
123 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ |
108 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ |
124 | }while (0) |
109 | }while (0) |
125 | #endif /* USE_RTOS */ |
110 | #endif /* USE_RTOS */ |
126 | 111 | ||
127 | #if defined ( __GNUC__ ) |
112 | #if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ |
128 | #ifndef __weak |
113 | #ifndef __weak |
129 | #define __weak __attribute__((weak)) |
114 | #define __weak __attribute__((weak)) |
130 | #endif /* __weak */ |
115 | #endif /* __weak */ |
131 | #ifndef __packed |
116 | #ifndef __packed |
132 | #define __packed __attribute__((__packed__)) |
117 | #define __packed __attribute__((__packed__)) |
133 | #endif /* __packed */ |
118 | #endif /* __packed */ |
134 | #endif /* __GNUC__ */ |
119 | #endif /* __GNUC__ */ |
135 | 120 | ||
136 | 121 | ||
137 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ |
122 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ |
138 | #if defined (__GNUC__) /* GNU Compiler */ |
123 | #if defined (__GNUC__) && !defined (__CC_ARM) /* GNU Compiler */ |
139 | #ifndef __ALIGN_END |
124 | #ifndef __ALIGN_END |
140 | #define __ALIGN_END __attribute__ ((aligned (4))) |
125 | #define __ALIGN_END __attribute__ ((aligned (4))) |
141 | #endif /* __ALIGN_END */ |
126 | #endif /* __ALIGN_END */ |
142 | #ifndef __ALIGN_BEGIN |
127 | #ifndef __ALIGN_BEGIN |
143 | #define __ALIGN_BEGIN |
128 | #define __ALIGN_BEGIN |
144 | #endif /* __ALIGN_BEGIN */ |
129 | #endif /* __ALIGN_BEGIN */ |
145 | #else |
130 | #else |
146 | #ifndef __ALIGN_END |
131 | #ifndef __ALIGN_END |
147 | #define __ALIGN_END |
132 | #define __ALIGN_END |
148 | #endif /* __ALIGN_END */ |
133 | #endif /* __ALIGN_END */ |
149 | #ifndef __ALIGN_BEGIN |
134 | #ifndef __ALIGN_BEGIN |
150 | #if defined (__CC_ARM) /* ARM Compiler */ |
135 | #if defined (__CC_ARM) /* ARM Compiler */ |
151 | #define __ALIGN_BEGIN __align(4) |
136 | #define __ALIGN_BEGIN __align(4) |
152 | #elif defined (__ICCARM__) /* IAR Compiler */ |
137 | #elif defined (__ICCARM__) /* IAR Compiler */ |
153 | #define __ALIGN_BEGIN |
138 | #define __ALIGN_BEGIN |
154 | #endif /* __CC_ARM */ |
139 | #endif /* __CC_ARM */ |
155 | #endif /* __ALIGN_BEGIN */ |
140 | #endif /* __ALIGN_BEGIN */ |
156 | #endif /* __GNUC__ */ |
141 | #endif /* __GNUC__ */ |
157 | 142 | ||
158 | /** |
143 | /** |
159 | * @brief __RAM_FUNC definition |
144 | * @brief __RAM_FUNC definition |
160 | */ |
145 | */ |
161 | #if defined ( __CC_ARM ) |
146 | #if defined ( __CC_ARM ) |
162 | /* ARM Compiler |
147 | /* ARM Compiler |
163 | ------------ |
148 | ------------ |
164 | RAM functions are defined using the toolchain options. |
149 | RAM functions are defined using the toolchain options. |
165 | Functions that are executed in RAM should reside in a separate source module. |
150 | Functions that are executed in RAM should reside in a separate source module. |
166 | Using the 'Options for File' dialog you can simply change the 'Code / Const' |
151 | Using the 'Options for File' dialog you can simply change the 'Code / Const' |
167 | area of a module to a memory space in physical RAM. |
152 | area of a module to a memory space in physical RAM. |
168 | Available memory areas are declared in the 'Target' tab of the 'Options for Target' |
153 | Available memory areas are declared in the 'Target' tab of the 'Options for Target' |
169 | dialog. |
154 | dialog. |
170 | */ |
155 | */ |
171 | #define __RAM_FUNC HAL_StatusTypeDef |
156 | #define __RAM_FUNC |
172 | 157 | ||
173 | #elif defined ( __ICCARM__ ) |
158 | #elif defined ( __ICCARM__ ) |
174 | /* ICCARM Compiler |
159 | /* ICCARM Compiler |
175 | --------------- |
160 | --------------- |
176 | RAM functions are defined using a specific toolchain keyword "__ramfunc". |
161 | RAM functions are defined using a specific toolchain keyword "__ramfunc". |
177 | */ |
162 | */ |
178 | #define __RAM_FUNC __ramfunc HAL_StatusTypeDef |
163 | #define __RAM_FUNC __ramfunc |
179 | 164 | ||
180 | #elif defined ( __GNUC__ ) |
165 | #elif defined ( __GNUC__ ) |
181 | /* GNU Compiler |
166 | /* GNU Compiler |
182 | ------------ |
167 | ------------ |
183 | RAM functions are defined using a specific toolchain attribute |
168 | RAM functions are defined using a specific toolchain attribute |
184 | "__attribute__((section(".RamFunc")))". |
169 | "__attribute__((section(".RamFunc")))". |
185 | */ |
170 | */ |
186 | #define __RAM_FUNC HAL_StatusTypeDef __attribute__((section(".RamFunc"))) |
171 | #define __RAM_FUNC __attribute__((section(".RamFunc"))) |
187 | 172 | ||
188 | #endif |
173 | #endif |
189 | 174 | ||
190 | /** |
175 | /** |
191 | * @brief __NOINLINE definition |
176 | * @brief __NOINLINE definition |
192 | */ |
177 | */ |
193 | #if defined ( __CC_ARM ) || defined ( __GNUC__ ) |
178 | #if defined ( __CC_ARM ) || defined ( __GNUC__ ) |
194 | /* ARM & GNUCompiler |
179 | /* ARM & GNUCompiler |
195 | ---------------- |
180 | ---------------- |
196 | */ |
181 | */ |
197 | #define __NOINLINE __attribute__ ( (noinline) ) |
182 | #define __NOINLINE __attribute__ ( (noinline) ) |
198 | 183 | ||
199 | #elif defined ( __ICCARM__ ) |
184 | #elif defined ( __ICCARM__ ) |
200 | /* ICCARM Compiler |
185 | /* ICCARM Compiler |
201 | --------------- |
186 | --------------- |
202 | */ |
187 | */ |