mikroSDK Reference Manual
stm32f1xx.h
Go to the documentation of this file.
1
38#ifndef __STM32F1XX_H
39#define __STM32F1XX_H
40
41#ifdef __cplusplus
42 extern "C" {
43#endif /* __cplusplus */
44
52#if !defined (STM32F1)
53#define STM32F1
54#endif /* STM32F1 */
55
56/* Uncomment the line below according to the target STM32L device used in your
57 application
58 */
59
60#if !defined (STM32F100xB) && !defined (STM32F100xE) && !defined (STM32F101x6) && \
61 !defined (STM32F101xB) && !defined (STM32F101xE) && !defined (STM32F101xG) && !defined (STM32F102x6) && !defined (STM32F102xB) && !defined (STM32F103x6) && \
62 !defined (STM32F103xB) && !defined (STM32F103xE) && !defined (STM32F103xG) && !defined (STM32F105xC) && !defined (STM32F107xC)
63 /* #define STM32F100xB */
64 /* #define STM32F100xE */
65 /* #define STM32F101x6 */
66 /* #define STM32F101xB */
67 /* #define STM32F101xE */
68 /* #define STM32F101xG */
69 /* #define STM32F102x6 */
70 /* #define STM32F102xB */
71 /* #define STM32F103x6 */
72 /* #define STM32F103xB */
73 /* #define STM32F103xE */
74 /* #define STM32F103xG */
75 /* #define STM32F105xC */
76 /* #define STM32F107xC */
77#endif
78
79/* Tip: To avoid modifying this file each time you need to switch between these
80 devices, you can define the device in your toolchain compiler preprocessor.
81 */
82
83#if !defined (USE_HAL_DRIVER)
89 /*#define USE_HAL_DRIVER */
90#endif /* USE_HAL_DRIVER */
91
95#define __STM32F1_CMSIS_VERSION_MAIN (0x04)
96#define __STM32F1_CMSIS_VERSION_SUB1 (0x03)
97#define __STM32F1_CMSIS_VERSION_SUB2 (0x03)
98#define __STM32F1_CMSIS_VERSION_RC (0x00)
99#define __STM32F1_CMSIS_VERSION ((__STM32F1_CMSIS_VERSION_MAIN << 24)\
100 |(__STM32F1_CMSIS_VERSION_SUB1 << 16)\
101 |(__STM32F1_CMSIS_VERSION_SUB2 << 8 )\
102 |(__STM32F1_CMSIS_VERSION_RC))
103
112#if defined(STM32F100xB)
113 #include "stm32f100xb.h"
114#elif defined(STM32F100xE)
115 #include "stm32f100xe.h"
116#elif defined(STM32F101x6)
117 #include "stm32f101x6.h"
118#elif defined(STM32F101xB)
119 #include "stm32f101xb.h"
120#elif defined(STM32F101xE)
121 #include "stm32f101xe.h"
122#elif defined(STM32F101xG)
123 #include "stm32f101xg.h"
124#elif defined(STM32F102x6)
125 #include "stm32f102x6.h"
126#elif defined(STM32F102xB)
127 #include "stm32f102xb.h"
128#elif defined(STM32F103x6)
129 #include "stm32f103x6.h"
130#elif defined(STM32F103xB)
131 #include "stm32f103xb.h"
132#elif defined(STM32F103xE)
133 #include "stm32f103xe.h"
134#elif defined(STM32F103xG)
135 #include "stm32f103xg.h"
136#elif defined(STM32F105xC)
137 #include "stm32f105xc.h"
138#elif defined(STM32F107xC)
139 #include "stm32f107xc.h"
140#else
141 #error "Please select first the target STM32F1xx device used in your application (in stm32f1xx.h file)"
142#endif
143
151typedef enum
152{
153 RESET = 0,
154 SET = !RESET
155} FlagStatus, ITStatus;
156
157typedef enum
158{
159 DISABLE = 0,
160 ENABLE = !DISABLE
161} FunctionalState;
162#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
163
164typedef enum
165{
166 SUCCESS = 0U,
167 ERROR = !SUCCESS
168} ErrorStatus;
169
178#define SET_BIT(REG, BIT) ((REG) |= (BIT))
179
180#define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
181
182#define READ_BIT(REG, BIT) ((REG) & (BIT))
183
184#define CLEAR_REG(REG) ((REG) = (0x0))
185
186#define WRITE_REG(REG, VAL) ((REG) = (VAL))
187
188#define READ_REG(REG) ((REG))
189
190#define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
191
192#define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL)))
193
194/* Use of CMSIS compiler intrinsics for register exclusive access */
195/* Atomic 32-bit register access macro to set one or several bits */
196#define ATOMIC_SET_BIT(REG, BIT) \
197 do { \
198 uint32_t val; \
199 do { \
200 val = __LDREXW((__IO uint32_t *)&(REG)) | (BIT); \
201 } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
202 } while(0)
203
204/* Atomic 32-bit register access macro to clear one or several bits */
205#define ATOMIC_CLEAR_BIT(REG, BIT) \
206 do { \
207 uint32_t val; \
208 do { \
209 val = __LDREXW((__IO uint32_t *)&(REG)) & ~(BIT); \
210 } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
211 } while(0)
212
213/* Atomic 32-bit register access macro to clear and set one or several bits */
214#define ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \
215 do { \
216 uint32_t val; \
217 do { \
218 val = (__LDREXW((__IO uint32_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \
219 } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
220 } while(0)
221
222/* Atomic 16-bit register access macro to set one or several bits */
223#define ATOMIC_SETH_BIT(REG, BIT) \
224 do { \
225 uint16_t val; \
226 do { \
227 val = __LDREXH((__IO uint16_t *)&(REG)) | (BIT); \
228 } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
229 } while(0)
230
231/* Atomic 16-bit register access macro to clear one or several bits */
232#define ATOMIC_CLEARH_BIT(REG, BIT) \
233 do { \
234 uint16_t val; \
235 do { \
236 val = __LDREXH((__IO uint16_t *)&(REG)) & ~(BIT); \
237 } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
238 } while(0)
239
240/* Atomic 16-bit register access macro to clear and set one or several bits */
241#define ATOMIC_MODIFYH_REG(REG, CLEARMSK, SETMASK) \
242 do { \
243 uint16_t val; \
244 do { \
245 val = (__LDREXH((__IO uint16_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \
246 } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
247 } while(0)
248
249
254#if defined (USE_HAL_DRIVER)
255 #include "stm32f1xx_hal.h"
256#endif /* USE_HAL_DRIVER */
257
258
259#ifdef __cplusplus
260}
261#endif /* __cplusplus */
262
263#endif /* __STM32F1xx_H */
275/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
CMSIS Cortex-M3 Device Peripheral Access Layer Header File. This file contains all the peripheral reg...
This file contains all the functions prototypes for the HAL module driver.