8
8
* is using in the C source code, usually in main.c. This file contains:
9
9
* - Configuration section that allows to select:
10
10
* - The STM32F2xx device used in the target application
11
- * - To use or not the peripheral’ s drivers in application code(i.e.
12
- * code will be based on direct access to peripheral’ s registers
11
+ * - To use or not the peripheral' s drivers in application code(i.e.
12
+ * code will be based on direct access to peripheral' s registers
13
13
* rather than drivers API), this option is controlled by
14
14
* "#define USE_HAL_DRIVER"
15
15
*
16
16
******************************************************************************
17
17
* @attention
18
18
*
19
- * <h2><center>© Copyright (c) 2017 STMicroelectronics.
20
- * All rights reserved.</center></h2>
19
+ * Copyright (c) 2017-2021 STMicroelectronics.
20
+ * All rights reserved.
21
21
*
22
- * This software component is licensed by ST under BSD 3-Clause license,
23
- * the "License"; You may not use this file except in compliance with the
24
- * License. You may obtain a copy of the License at:
25
- * opensource.org/licenses/BSD-3-Clause
22
+ * This software is licensed under terms that can be found in the LICENSE file
23
+ * in the root directory of this software component.
24
+ * If no LICENSE file comes with this software, it is provided AS-IS.
26
25
*
27
26
******************************************************************************
28
27
*/
81
80
#endif /* USE_HAL_DRIVER */
82
81
83
82
/**
84
- * @brief CMSIS Device version number V2.2.5
83
+ * @brief CMSIS Device version number
85
84
*/
86
85
#define __STM32F2xx_CMSIS_VERSION_MAIN (0x02U) /*!< [31:24] main version */
87
86
#define __STM32F2xx_CMSIS_VERSION_SUB1 (0x02U) /*!< [23:16] sub1 version */
88
- #define __STM32F2xx_CMSIS_VERSION_SUB2 (0x05U ) /*!< [15:8] sub2 version */
87
+ #define __STM32F2xx_CMSIS_VERSION_SUB2 (0x06U ) /*!< [15:8] sub2 version */
89
88
#define __STM32F2xx_CMSIS_VERSION_RC (0x00U) /*!< [7:0] release candidate */
90
89
#define __STM32F2xx_CMSIS_VERSION ((__STM32F2xx_CMSIS_VERSION_MAIN << 24)\
91
90
|(__STM32F2xx_CMSIS_VERSION_SUB1 << 16)\
@@ -162,6 +161,60 @@ typedef enum
162
161
163
162
#define POSITION_VAL (VAL ) (__CLZ(__RBIT(VAL)))
164
163
164
+ /* Use of CMSIS compiler intrinsics for register exclusive access */
165
+ /* Atomic 32-bit register access macro to set one or several bits */
166
+ #define ATOMIC_SET_BIT (REG , BIT ) \
167
+ do { \
168
+ uint32_t val; \
169
+ do { \
170
+ val = __LDREXW((__IO uint32_t *)&(REG)) | (BIT); \
171
+ } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
172
+ } while(0)
173
+
174
+ /* Atomic 32-bit register access macro to clear one or several bits */
175
+ #define ATOMIC_CLEAR_BIT (REG , BIT ) \
176
+ do { \
177
+ uint32_t val; \
178
+ do { \
179
+ val = __LDREXW((__IO uint32_t *)&(REG)) & ~(BIT); \
180
+ } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
181
+ } while(0)
182
+
183
+ /* Atomic 32-bit register access macro to clear and set one or several bits */
184
+ #define ATOMIC_MODIFY_REG (REG , CLEARMSK , SETMASK ) \
185
+ do { \
186
+ uint32_t val; \
187
+ do { \
188
+ val = (__LDREXW((__IO uint32_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \
189
+ } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
190
+ } while(0)
191
+
192
+ /* Atomic 16-bit register access macro to set one or several bits */
193
+ #define ATOMIC_SETH_BIT (REG , BIT ) \
194
+ do { \
195
+ uint16_t val; \
196
+ do { \
197
+ val = __LDREXH((__IO uint16_t *)&(REG)) | (BIT); \
198
+ } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
199
+ } while(0)
200
+
201
+ /* Atomic 16-bit register access macro to clear one or several bits */
202
+ #define ATOMIC_CLEARH_BIT (REG , BIT ) \
203
+ do { \
204
+ uint16_t val; \
205
+ do { \
206
+ val = __LDREXH((__IO uint16_t *)&(REG)) & ~(BIT); \
207
+ } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
208
+ } while(0)
209
+
210
+ /* Atomic 16-bit register access macro to clear and set one or several bits */
211
+ #define ATOMIC_MODIFYH_REG (REG , CLEARMSK , SETMASK ) \
212
+ do { \
213
+ uint16_t val; \
214
+ do { \
215
+ val = (__LDREXH((__IO uint16_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \
216
+ } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
217
+ } while(0)
165
218
166
219
/**
167
220
* @}
@@ -188,4 +241,3 @@ typedef enum
188
241
189
242
190
243
191
- /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
0 commit comments