提交 | 用户 | age
|
483170
|
1 |
/** |
Q |
2 |
****************************************************************************** |
|
3 |
* @file stm32f0xx_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 |
* |
|
10 |
* <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
|
11 |
* |
|
12 |
* Redistribution and use in source and binary forms, with or without modification, |
|
13 |
* are permitted provided that the following conditions are met: |
|
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. |
|
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 |
|
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 |
* |
|
34 |
****************************************************************************** |
|
35 |
*/ |
|
36 |
|
|
37 |
/* Define to prevent recursive inclusion -------------------------------------*/ |
|
38 |
#ifndef __STM32F0xx_HAL_DEF |
|
39 |
#define __STM32F0xx_HAL_DEF |
|
40 |
|
|
41 |
#ifdef __cplusplus |
|
42 |
extern "C" { |
|
43 |
#endif |
|
44 |
|
|
45 |
/* Includes ------------------------------------------------------------------*/ |
|
46 |
#include "stm32f0xx.h" |
|
47 |
#if defined(USE_HAL_LEGACY) |
|
48 |
#include "Legacy/stm32_hal_legacy.h" |
|
49 |
#endif |
|
50 |
#include <stdio.h> |
|
51 |
|
|
52 |
/* Exported types ------------------------------------------------------------*/ |
|
53 |
|
|
54 |
/** |
|
55 |
* @brief HAL Status structures definition |
|
56 |
*/ |
|
57 |
typedef enum |
|
58 |
{ |
|
59 |
HAL_OK = 0x00U, |
|
60 |
HAL_ERROR = 0x01U, |
|
61 |
HAL_BUSY = 0x02U, |
|
62 |
HAL_TIMEOUT = 0x03U |
|
63 |
} HAL_StatusTypeDef; |
|
64 |
|
|
65 |
/** |
|
66 |
* @brief HAL Lock structures definition |
|
67 |
*/ |
|
68 |
typedef enum |
|
69 |
{ |
|
70 |
HAL_UNLOCKED = 0x00U, |
|
71 |
HAL_LOCKED = 0x01U |
|
72 |
} HAL_LockTypeDef; |
|
73 |
|
|
74 |
/* Exported macro ------------------------------------------------------------*/ |
|
75 |
|
|
76 |
#define HAL_MAX_DELAY 0xFFFFFFFFU |
|
77 |
|
|
78 |
#define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != RESET) |
|
79 |
#define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == RESET) |
|
80 |
|
|
81 |
#define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD_, __DMA_HANDLE_) \ |
|
82 |
do{ \ |
|
83 |
(__HANDLE__)->__PPP_DMA_FIELD_ = &(__DMA_HANDLE_); \ |
|
84 |
(__DMA_HANDLE_).Parent = (__HANDLE__); \ |
|
85 |
} while(0) |
|
86 |
|
|
87 |
#define UNUSED(x) ((void)(x)) |
|
88 |
|
|
89 |
/** @brief Reset the Handle's State field. |
|
90 |
* @param __HANDLE__ specifies the Peripheral Handle. |
|
91 |
* @note This macro can be used for the following purpose: |
|
92 |
* - 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 |
|
94 |
* to set to 0 the Handle's "State" field. |
|
95 |
* 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 |
|
97 |
* (i.e. HAL_PPP_MspInit() will not be executed). |
|
98 |
* - 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(). |
|
100 |
* 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. |
|
102 |
* @retval None |
|
103 |
*/ |
|
104 |
#define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0) |
|
105 |
|
|
106 |
#if (USE_RTOS == 1) |
|
107 |
#error " USE_RTOS should be 0 in the current HAL release " |
|
108 |
#else |
|
109 |
#define __HAL_LOCK(__HANDLE__) \ |
|
110 |
do{ \ |
|
111 |
if((__HANDLE__)->Lock == HAL_LOCKED) \ |
|
112 |
{ \ |
|
113 |
return HAL_BUSY; \ |
|
114 |
} \ |
|
115 |
else \ |
|
116 |
{ \ |
|
117 |
(__HANDLE__)->Lock = HAL_LOCKED; \ |
|
118 |
} \ |
|
119 |
}while (0) |
|
120 |
|
|
121 |
#define __HAL_UNLOCK(__HANDLE__) \ |
|
122 |
do{ \ |
|
123 |
(__HANDLE__)->Lock = HAL_UNLOCKED; \ |
|
124 |
}while (0) |
|
125 |
#endif /* USE_RTOS */ |
|
126 |
|
|
127 |
#if defined ( __GNUC__ ) |
|
128 |
#ifndef __weak |
|
129 |
#define __weak __attribute__((weak)) |
|
130 |
#endif /* __weak */ |
|
131 |
#ifndef __packed |
|
132 |
#define __packed __attribute__((__packed__)) |
|
133 |
#endif /* __packed */ |
|
134 |
#endif /* __GNUC__ */ |
|
135 |
|
|
136 |
|
|
137 |
/* 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 */ |
|
139 |
#ifndef __ALIGN_END |
|
140 |
#define __ALIGN_END __attribute__ ((aligned (4))) |
|
141 |
#endif /* __ALIGN_END */ |
|
142 |
#ifndef __ALIGN_BEGIN |
|
143 |
#define __ALIGN_BEGIN |
|
144 |
#endif /* __ALIGN_BEGIN */ |
|
145 |
#else |
|
146 |
#ifndef __ALIGN_END |
|
147 |
#define __ALIGN_END |
|
148 |
#endif /* __ALIGN_END */ |
|
149 |
#ifndef __ALIGN_BEGIN |
|
150 |
#if defined (__CC_ARM) /* ARM Compiler */ |
|
151 |
#define __ALIGN_BEGIN __align(4) |
|
152 |
#elif defined (__ICCARM__) /* IAR Compiler */ |
|
153 |
#define __ALIGN_BEGIN |
|
154 |
#endif /* __CC_ARM */ |
|
155 |
#endif /* __ALIGN_BEGIN */ |
|
156 |
#endif /* __GNUC__ */ |
|
157 |
|
|
158 |
/** |
|
159 |
* @brief __NOINLINE definition |
|
160 |
*/ |
|
161 |
#if defined ( __CC_ARM ) || defined ( __GNUC__ ) |
|
162 |
/* ARM & GNUCompiler |
|
163 |
---------------- |
|
164 |
*/ |
|
165 |
#define __NOINLINE __attribute__ ( (noinline) ) |
|
166 |
|
|
167 |
#elif defined ( __ICCARM__ ) |
|
168 |
/* ICCARM Compiler |
|
169 |
--------------- |
|
170 |
*/ |
|
171 |
#define __NOINLINE _Pragma("optimize = no_inline") |
|
172 |
|
|
173 |
#endif |
|
174 |
|
|
175 |
#ifdef __cplusplus |
|
176 |
} |
|
177 |
#endif |
|
178 |
|
|
179 |
#endif /* ___STM32F0xx_HAL_DEF */ |
|
180 |
|
|
181 |
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
|
182 |
|