Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2 | Rev 9 | ||
|---|---|---|---|
| Line 5... | Line 5... | ||
| 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</center></h2> |
10 | * <h2><center>© Copyright (c) 2017 STMicroelectronics. |
| - | 11 | * All rights reserved.</center></h2> |
|
| 11 | * |
12 | * |
| 12 | * 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, |
| 13 | * are permitted provided that the following conditions are met: |
14 | * the "License"; You may not use this file except in compliance with the |
| 14 | * 1. Redistributions of source code must retain the above copyright notice, |
- | |
| 15 | * this list of conditions and the following disclaimer. |
- | |
| 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
- | |
| 17 | * this list of conditions and the following disclaimer in the documentation |
- | |
| 18 | * and/or other materials provided with the distribution. |
15 | * License. You may obtain a copy of the License at: |
| 19 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
- | |
| 20 | * may be used to endorse or promote products derived from this software |
16 | * opensource.org/licenses/BSD-3-Clause |
| 21 | * without specific prior written permission. |
- | |
| 22 | * |
- | |
| 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
- | |
| 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
- | |
| 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
- | |
| 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
- | |
| 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
- | |
| 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
- | |
| 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
- | |
| 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
- | |
| 31 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
- | |
| 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
- | |
| 33 | * |
17 | * |
| 34 | ****************************************************************************** |
18 | ****************************************************************************** |
| 35 | */ |
19 | */ |
| 36 | 20 | ||
| 37 | /* Define to prevent recursive inclusion -------------------------------------*/ |
21 | /* Define to prevent recursive inclusion -------------------------------------*/ |
| Line 42... | Line 26... | ||
| 42 | extern "C" { |
26 | extern "C" { |
| 43 | #endif |
27 | #endif |
| 44 | 28 | ||
| 45 | /* Includes ------------------------------------------------------------------*/ |
29 | /* Includes ------------------------------------------------------------------*/ |
| 46 | #include "stm32f1xx.h" |
30 | #include "stm32f1xx.h" |
| 47 | #if defined(USE_HAL_LEGACY) |
- | |
| 48 | #include "Legacy/stm32_hal_legacy.h" |
31 | #include "Legacy/stm32_hal_legacy.h" |
| 49 | #endif |
- | |
| 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 |
| Line 84... | Line 66... | ||
| 84 | } while(0U) |
66 | } while(0U) |
| 85 | 67 | ||
| 86 | #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */ |
68 | #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */ |
| 87 | 69 | ||
| 88 | /** @brief Reset the Handle's State field. |
70 | /** @brief Reset the Handle's State field. |
| 89 | * @param __HANDLE__: specifies the Peripheral Handle. |
71 | * @param __HANDLE__ specifies the Peripheral Handle. |
| 90 | * @note This macro can be used for the following purpose: |
72 | * @note This macro can be used for the following purpose: |
| 91 | * - When the Handle is declared as local variable; before passing it as parameter |
73 | * - When the Handle is declared as local variable; before passing it as parameter |
| 92 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro |
74 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro |
| 93 | * to set to 0 the Handle's "State" field. |
75 | * to set to 0 the Handle's "State" field. |
| 94 | * Otherwise, "State" field may have any random value and the first time the function |
76 | * Otherwise, "State" field may have any random value and the first time the function |
| Line 122... | Line 104... | ||
| 122 | do{ \ |
104 | do{ \ |
| 123 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ |
105 | (__HANDLE__)->Lock = HAL_UNLOCKED; \ |
| 124 | }while (0U) |
106 | }while (0U) |
| 125 | #endif /* USE_RTOS */ |
107 | #endif /* USE_RTOS */ |
| 126 | 108 | ||
| - | 109 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ |
|
| - | 110 | #ifndef __weak |
|
| - | 111 | #define __weak __attribute__((weak)) |
|
| - | 112 | #endif |
|
| - | 113 | #ifndef __packed |
|
| - | 114 | #define __packed __attribute__((packed)) |
|
| - | 115 | #endif |
|
| 127 | #if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ |
116 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ |
| 128 | #ifndef __weak |
117 | #ifndef __weak |
| 129 | #define __weak __attribute__((weak)) |
118 | #define __weak __attribute__((weak)) |
| 130 | #endif /* __weak */ |
119 | #endif /* __weak */ |
| 131 | #ifndef __packed |
120 | #ifndef __packed |
| 132 | #define __packed __attribute__((__packed__)) |
121 | #define __packed __attribute__((__packed__)) |
| 133 | #endif /* __packed */ |
122 | #endif /* __packed */ |
| 134 | #endif /* __GNUC__ */ |
123 | #endif /* __GNUC__ */ |
| 135 | 124 | ||
| 136 | 125 | ||
| 137 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ |
126 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ |
| - | 127 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */ |
|
| - | 128 | #ifndef __ALIGN_BEGIN |
|
| - | 129 | #define __ALIGN_BEGIN |
|
| - | 130 | #endif |
|
| - | 131 | #ifndef __ALIGN_END |
|
| - | 132 | #define __ALIGN_END __attribute__ ((aligned (4))) |
|
| - | 133 | #endif |
|
| 138 | #if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ |
134 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ |
| 139 | #ifndef __ALIGN_END |
135 | #ifndef __ALIGN_END |
| 140 | #define __ALIGN_END __attribute__ ((aligned (4))) |
136 | #define __ALIGN_END __attribute__ ((aligned (4))) |
| 141 | #endif /* __ALIGN_END */ |
137 | #endif /* __ALIGN_END */ |
| 142 | #ifndef __ALIGN_BEGIN |
138 | #ifndef __ALIGN_BEGIN |
| 143 | #define __ALIGN_BEGIN |
139 | #define __ALIGN_BEGIN |
| Line 145... | Line 141... | ||
| 145 | #else |
141 | #else |
| 146 | #ifndef __ALIGN_END |
142 | #ifndef __ALIGN_END |
| 147 | #define __ALIGN_END |
143 | #define __ALIGN_END |
| 148 | #endif /* __ALIGN_END */ |
144 | #endif /* __ALIGN_END */ |
| 149 | #ifndef __ALIGN_BEGIN |
145 | #ifndef __ALIGN_BEGIN |
| 150 | #if defined (__CC_ARM) /* ARM Compiler */ |
146 | #if defined (__CC_ARM) /* ARM Compiler V5*/ |
| 151 | #define __ALIGN_BEGIN __align(4) |
147 | #define __ALIGN_BEGIN __align(4) |
| 152 | #elif defined (__ICCARM__) /* IAR Compiler */ |
148 | #elif defined (__ICCARM__) /* IAR Compiler */ |
| 153 | #define __ALIGN_BEGIN |
149 | #define __ALIGN_BEGIN |
| 154 | #endif /* __CC_ARM */ |
150 | #endif /* __CC_ARM */ |
| 155 | #endif /* __ALIGN_BEGIN */ |
151 | #endif /* __ALIGN_BEGIN */ |
| Line 157... | Line 153... | ||
| 157 | 153 | ||
| 158 | 154 | ||
| 159 | /** |
155 | /** |
| 160 | * @brief __RAM_FUNC definition |
156 | * @brief __RAM_FUNC definition |
| 161 | */ |
157 | */ |
| 162 | #if defined ( __CC_ARM ) |
158 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) |
| 163 | /* ARM Compiler |
159 | /* ARM Compiler V4/V5 and V6 |
| 164 | ------------ |
160 | -------------------------- |
| 165 | RAM functions are defined using the toolchain options. |
161 | RAM functions are defined using the toolchain options. |
| 166 | Functions that are executed in RAM should reside in a separate source module. |
162 | Functions that are executed in RAM should reside in a separate source module. |
| 167 | Using the 'Options for File' dialog you can simply change the 'Code / Const' |
163 | Using the 'Options for File' dialog you can simply change the 'Code / Const' |
| 168 | area of a module to a memory space in physical RAM. |
164 | area of a module to a memory space in physical RAM. |
| 169 | Available memory areas are declared in the 'Target' tab of the 'Options for Target' |
165 | Available memory areas are declared in the 'Target' tab of the 'Options for Target' |
| Line 189... | Line 185... | ||
| 189 | #endif |
185 | #endif |
| 190 | 186 | ||
| 191 | /** |
187 | /** |
| 192 | * @brief __NOINLINE definition |
188 | * @brief __NOINLINE definition |
| 193 | */ |
189 | */ |
| 194 | #if defined ( __CC_ARM ) || defined ( __GNUC__ ) |
190 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined ( __GNUC__ ) |
| 195 | /* ARM & GNUCompiler |
191 | /* ARM V4/V5 and V6 & GNU Compiler |
| 196 | ---------------- |
192 | ------------------------------- |
| 197 | */ |
193 | */ |
| 198 | #define __NOINLINE __attribute__ ( (noinline) ) |
194 | #define __NOINLINE __attribute__ ( (noinline) ) |
| 199 | 195 | ||
| 200 | #elif defined ( __ICCARM__ ) |
196 | #elif defined ( __ICCARM__ ) |
| 201 | /* ICCARM Compiler |
197 | /* ICCARM Compiler |