1616 ******************************************************************************
1717 * @attention
1818 *
19- * <h2><center>© Copyright (c) 2019 STMicroelectronics.
20- * All rights reserved.</center></h2>
19+ * Copyright (c) 2019-2021 STMicroelectronics.
20+ * All rights reserved.
2121 *
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.
2625 *
2726 ******************************************************************************
2827 */
3938#define __STM32WBxx_H
4039
4140#ifdef __cplusplus
42- extern "C" {
41+ extern "C" {
4342#endif /* __cplusplus */
4443
4544/** @addtogroup Library_configuration_section
5857 */
5958#if !defined (USE_HAL_DRIVER )
6059/**
61- * @brief Comment the line below if you will not use the peripherals drivers.
60+ * @brief Comment the line below if you will not use the peripherals drivers.
6261 In this case, these drivers will not be included and the application code will
6362 be based on direct access to peripherals registers
6463 */
65- /*#define USE_HAL_DRIVER */
64+ /*#define USE_HAL_DRIVER */
6665#endif /* USE_HAL_DRIVER */
6766
6867/**
6968 * @brief CMSIS Device version number
7069 */
7170#define __STM32WBxx_CMSIS_VERSION_MAIN (0x01U) /*!< [31:24] main version */
72- #define __STM32WBxx_CMSIS_VERSION_SUB1 (0x07U ) /*!< [23:16] sub1 version */
73- #define __STM32WBxx_CMSIS_VERSION_SUB2 (0x00U ) /*!< [15:8] sub2 version */
71+ #define __STM32WBxx_CMSIS_VERSION_SUB1 (0x0CU ) /*!< [23:16] sub1 version */
72+ #define __STM32WBxx_CMSIS_VERSION_SUB2 (0x03U ) /*!< [15:8] sub2 version */
7473#define __STM32WBxx_CMSIS_VERSION_RC (0x00U) /*!< [7:0] release candidate */
7574#define __STM32WBxx_CMSIS_DEVICE_VERSION ((__STM32WBxx_CMSIS_VERSION_MAIN << 24)\
7675 |(__STM32WBxx_CMSIS_VERSION_SUB1 << 16)\
8685 */
8786
8887#if defined(STM32WB55xx )
89- #include "stm32wb55xx.h"
88+ #include "stm32wb55xx.h"
9089#elif defined(STM32WB5Mxx )
91- #include "stm32wb5mxx.h"
90+ #include "stm32wb5mxx.h"
9291#elif defined(STM32WB50xx )
93- #include "stm32wb50xx.h"
92+ #include "stm32wb50xx.h"
9493#elif defined(STM32WB35xx )
95- #include "stm32wb35xx.h"
94+ #include "stm32wb35xx.h"
9695#elif defined(STM32WB30xx )
97- #include "stm32wb30xx.h"
96+ #include "stm32wb30xx.h"
97+ #elif defined(STM32WB15xx )
98+ #include "stm32wb15xx.h"
99+ #elif defined(STM32WB10xx )
100+ #include "stm32wb10xx.h"
101+ #elif defined(STM32WB1Mxx )
102+ #include "stm32wb1mxx.h"
98103#else
99- #error "Please select first the target STM32WBxx device used in your application, for instance xxx (in stm32wbxx.h file)"
104+ #error "Please select first the target STM32WBxx device used in your application, for instance xxx (in stm32wbxx.h file)"
100105#endif
101106/**
102107 * @}
@@ -146,13 +151,69 @@ typedef enum
146151
147152#define MODIFY_REG (REG , CLEARMASK , SETMASK ) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
148153
154+ /* Use of CMSIS compiler intrinsics for register exclusive access */
155+ /* Atomic 32-bit register access macro to set one or several bits */
156+ #define ATOMIC_SET_BIT (REG , BIT ) \
157+ do { \
158+ uint32_t val; \
159+ do { \
160+ val = __LDREXW((__IO uint32_t *)&(REG)) | (BIT); \
161+ } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
162+ } while(0)
163+
164+ /* Atomic 32-bit register access macro to clear one or several bits */
165+ #define ATOMIC_CLEAR_BIT (REG , BIT ) \
166+ do { \
167+ uint32_t val; \
168+ do { \
169+ val = __LDREXW((__IO uint32_t *)&(REG)) & ~(BIT); \
170+ } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
171+ } while(0)
172+
173+ /* Atomic 32-bit register access macro to clear and set one or several bits */
174+ #define ATOMIC_MODIFY_REG (REG , CLEARMSK , SETMASK ) \
175+ do { \
176+ uint32_t val; \
177+ do { \
178+ val = (__LDREXW((__IO uint32_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \
179+ } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
180+ } while(0)
181+
182+ /* Atomic 16-bit register access macro to set one or several bits */
183+ #define ATOMIC_SETH_BIT (REG , BIT ) \
184+ do { \
185+ uint16_t val; \
186+ do { \
187+ val = __LDREXH((__IO uint16_t *)&(REG)) | (BIT); \
188+ } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
189+ } while(0)
190+
191+ /* Atomic 16-bit register access macro to clear one or several bits */
192+ #define ATOMIC_CLEARH_BIT (REG , BIT ) \
193+ do { \
194+ uint16_t val; \
195+ do { \
196+ val = __LDREXH((__IO uint16_t *)&(REG)) & ~(BIT); \
197+ } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
198+ } while(0)
199+
200+ /* Atomic 16-bit register access macro to clear and set one or several bits */
201+ #define ATOMIC_MODIFYH_REG (REG , CLEARMSK , SETMASK ) \
202+ do { \
203+ uint16_t val; \
204+ do { \
205+ val = (__LDREXH((__IO uint16_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \
206+ } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
207+ } while(0)
208+
149209#define POSITION_VAL (VAL ) (__CLZ(__RBIT(VAL)))
210+
150211/**
151212 * @}
152213 */
153214
154215#if defined (USE_HAL_DRIVER )
155- #include "stm32wbxx_hal.h"
216+ #include "stm32wbxx_hal.h"
156217#endif /* USE_HAL_DRIVER */
157218
158219#ifdef __cplusplus
@@ -167,8 +228,3 @@ typedef enum
167228/**
168229 * @}
169230 */
170-
171-
172-
173-
174- /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
0 commit comments