1 /** 2 ****************************************************************************** 3 * @file stm32wbxx.h 4 * @author MCD Application Team 5 * @brief CMSIS STM32WBxx Device Peripheral Access Layer Header File. 6 * 7 * The file is the unique include file that the application programmer 8 * is using in the C source code, usually in main.c. This file contains: 9 * - Configuration section that allows to select: 10 * - The STM32WBxx 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 13 * rather than drivers API), this option is controlled by 14 * "#define USE_HAL_DRIVER" 15 * 16 ****************************************************************************** 17 * @attention 18 * 19 * Copyright (c) 2019-2021 STMicroelectronics. 20 * All rights reserved. 21 * 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. 25 * 26 ****************************************************************************** 27 */ 28 29 /** @addtogroup CMSIS 30 * @{ 31 */ 32 33 /** @addtogroup stm32wbxx 34 * @{ 35 */ 36 37 #ifndef __STM32WBxx_H 38 #define __STM32WBxx_H 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif /* __cplusplus */ 43 44 /** @addtogroup Library_configuration_section 45 * @{ 46 */ 47 48 /** 49 * @brief STM32 Family 50 */ 51 #if !defined (STM32WB) 52 #define STM32WB 53 #endif /* STM32WB */ 54 55 /* Tip: To avoid modifying this file each time you need to switch between these 56 devices, you can define the device in your toolchain compiler preprocessor. 57 */ 58 #if !defined (USE_HAL_DRIVER) 59 /** 60 * @brief Comment the line below if you will not use the peripherals drivers. 61 In this case, these drivers will not be included and the application code will 62 be based on direct access to peripherals registers 63 */ 64 /*#define USE_HAL_DRIVER */ 65 #endif /* USE_HAL_DRIVER */ 66 67 /** 68 * @brief CMSIS Device version number 69 */ 70 #define __STM32WBxx_CMSIS_VERSION_MAIN (0x01U) /*!< [31:24] main version */ 71 #define __STM32WBxx_CMSIS_VERSION_SUB1 (0x0CU) /*!< [23:16] sub1 version */ 72 #define __STM32WBxx_CMSIS_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */ 73 #define __STM32WBxx_CMSIS_VERSION_RC (0x00U) /*!< [7:0] release candidate */ 74 #define __STM32WBxx_CMSIS_DEVICE_VERSION ((__STM32WBxx_CMSIS_VERSION_MAIN << 24)\ 75 |(__STM32WBxx_CMSIS_VERSION_SUB1 << 16)\ 76 |(__STM32WBxx_CMSIS_VERSION_SUB2 << 8 )\ 77 |(__STM32WBxx_CMSIS_VERSION_RC)) 78 79 /** 80 * @} 81 */ 82 83 /** @addtogroup Device_Included 84 * @{ 85 */ 86 87 #if defined(STM32WB55xx) 88 #include "stm32wb55xx.h" 89 #elif defined(STM32WB5Mxx) 90 #include "stm32wb5mxx.h" 91 #elif defined(STM32WB50xx) 92 #include "stm32wb50xx.h" 93 #elif defined(STM32WB35xx) 94 #include "stm32wb35xx.h" 95 #elif defined(STM32WB30xx) 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" 103 #else 104 #error "Please select first the target STM32WBxx device used in your application, for instance xxx (in stm32wbxx.h file)" 105 #endif 106 /** 107 * @} 108 */ 109 110 /** @addtogroup Exported_types 111 * @{ 112 */ 113 typedef enum 114 { 115 RESET = 0, 116 SET = !RESET 117 } FlagStatus, ITStatus; 118 119 typedef enum 120 { 121 DISABLE = 0, 122 ENABLE = !DISABLE 123 } FunctionalState; 124 #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) 125 126 typedef enum 127 { 128 SUCCESS = 0, 129 ERROR = !SUCCESS 130 } ErrorStatus; 131 132 /** 133 * @} 134 */ 135 136 137 /** @addtogroup Exported_macros 138 * @{ 139 */ 140 #define SET_BIT(REG, BIT) ((REG) |= (BIT)) 141 142 #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) 143 144 #define READ_BIT(REG, BIT) ((REG) & (BIT)) 145 146 #define CLEAR_REG(REG) ((REG) = (0x0)) 147 148 #define WRITE_REG(REG, VAL) ((REG) = (VAL)) 149 150 #define READ_REG(REG) ((REG)) 151 152 #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) 153 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 209 #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL))) 210 211 /** 212 * @} 213 */ 214 215 #if defined (USE_HAL_DRIVER) 216 #include "stm32wbxx_hal.h" 217 #endif /* USE_HAL_DRIVER */ 218 219 #ifdef __cplusplus 220 } 221 #endif /* __cplusplus */ 222 223 #endif /* __STM32WBxx_H */ 224 /** 225 * @} 226 */ 227 228 /** 229 * @} 230 */ 231