1 /** 2 ****************************************************************************** 3 * @file stm32wbaxx.h 4 * @author MCD Application Team 5 * @brief CMSIS STM32WBAxx 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 STM32WBAxx 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) 2022 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 stm32wbaxx 34 * @{ 35 */ 36 37 #ifndef STM32WBAxx_H 38 #define STM32WBAxx_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(STM32WBA) 52 #define STM32WBA 53 #endif /* !STM32WBA */ 54 55 /* Uncomment the line below according to the target STM32WBA device used in your 56 application 57 */ 58 59 #if !defined(STM32WBA50xx) && !defined(STM32WBA52xx) && !defined(STM32WBA54xx) && !defined(STM32WBA55xx) && \ 60 !defined(STM32WBA5Mxx) 61 /* #define STM32WBA50xx */ /*!< STM32WBA50xx Devices */ 62 /* #define STM32WBA52xx */ /*!< STM32WBA52xx Devices */ 63 /* #define STM32WBA54xx */ /*!< STM32WBA54xx Devices */ 64 /* #define STM32WBA55xx */ /*!< STM32WBA55xx Devices */ 65 /* #define STM32WBA5Mxx */ /*!< STM32WBA5Mxx Devices */ 66 #endif /* !STM32WBA50xx && !STM32WBA52xx ...*/ 67 68 /* Tip: To avoid modifying this file each time you need to switch between these 69 devices, you can define the device in your toolchain compiler preprocessor. 70 */ 71 #if !defined(USE_HAL_DRIVER) 72 /** 73 * @brief Comment the line below if you will not use the peripherals drivers. 74 In this case, these drivers will not be included and the application code will 75 be based on direct access to peripherals registers 76 */ 77 /*#define USE_HAL_DRIVER */ 78 #endif /* USE_HAL_DRIVER */ 79 80 /** 81 * @brief CMSIS Device version number 82 */ 83 #define __STM32WBA_CMSIS_VERSION_MAIN (0x01U) /*!< [31:24] main version */ 84 #define __STM32WBA_CMSIS_VERSION_SUB1 (0x05U) /*!< [23:16] sub1 version */ 85 #define __STM32WBA_CMSIS_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */ 86 #define __STM32WBA_CMSIS_VERSION_RC (0x00U) /*!< [7:0] release candidate */ 87 #define __STM32WBA_CMSIS_VERSION ((__STM32WBA_CMSIS_VERSION_MAIN << 24U)\ 88 |(__STM32WBA_CMSIS_VERSION_SUB1 << 16U)\ 89 |(__STM32WBA_CMSIS_VERSION_SUB2 << 8U )\ 90 |(__STM32WBA_CMSIS_VERSION_RC)) 91 92 /** 93 * @} 94 */ 95 96 /** @addtogroup Device_Included 97 * @{ 98 */ 99 100 #if defined(STM32WBA50xx) 101 #include "stm32wba50xx.h" 102 #elif defined(STM32WBA52xx) 103 #include "stm32wba52xx.h" 104 #elif defined(STM32WBA54xx) 105 #include "stm32wba54xx.h" 106 #elif defined(STM32WBA55xx) 107 #include "stm32wba55xx.h" 108 #elif defined(STM32WBA5Mxx) 109 #include "stm32wba5mxx.h" 110 #else 111 #error "Please select first the target STM32WBAxx device used in your application (in stm32wbaxx.h file)" 112 #endif /* STM32WBA50xx */ 113 114 /** 115 * @} 116 */ 117 118 /** @addtogroup Exported_types 119 * @{ 120 */ 121 typedef enum 122 { 123 RESET = 0, 124 SET = !RESET 125 } FlagStatus, ITStatus; 126 127 typedef enum 128 { 129 DISABLE = 0, 130 ENABLE = !DISABLE 131 } FunctionalState; 132 #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) 133 134 typedef enum 135 { 136 SUCCESS = 0, 137 ERROR = !SUCCESS 138 } ErrorStatus; 139 140 /** 141 * @} 142 */ 143 144 145 /** @addtogroup Exported_macros 146 * @{ 147 */ 148 #define SET_BIT(REG, BIT) ((REG) |= (BIT)) 149 150 #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) 151 152 #define READ_BIT(REG, BIT) ((REG) & (BIT)) 153 154 #define CLEAR_REG(REG) ((REG) = (0x0)) 155 156 #define WRITE_REG(REG, VAL) ((REG) = (VAL)) 157 158 #define READ_REG(REG) ((REG)) 159 160 #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) 161 162 /* Use of CMSIS compiler intrinsics for register exclusive access */ 163 /* Atomic 32-bit register access macro to set one or several bits */ 164 #define ATOMIC_SET_BIT(REG, BIT) \ 165 do { \ 166 uint32_t val; \ 167 do { \ 168 val = __LDREXW((__IO uint32_t *)&(REG)) | (BIT); \ 169 } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \ 170 } while(0) 171 172 /* Atomic 32-bit register access macro to clear one or several bits */ 173 #define ATOMIC_CLEAR_BIT(REG, BIT) \ 174 do { \ 175 uint32_t val; \ 176 do { \ 177 val = __LDREXW((__IO uint32_t *)&(REG)) & ~(BIT); \ 178 } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \ 179 } while(0) 180 181 /* Atomic 32-bit register access macro to clear and set one or several bits */ 182 #define ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \ 183 do { \ 184 uint32_t val; \ 185 do { \ 186 val = (__LDREXW((__IO uint32_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \ 187 } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \ 188 } while(0) 189 190 /* Atomic 16-bit register access macro to set one or several bits */ 191 #define ATOMIC_SETH_BIT(REG, BIT) \ 192 do { \ 193 uint16_t val; \ 194 do { \ 195 val = __LDREXH((__IO uint16_t *)&(REG)) | (BIT); \ 196 } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \ 197 } while(0) 198 199 /* Atomic 16-bit register access macro to clear one or several bits */ 200 #define ATOMIC_CLEARH_BIT(REG, BIT) \ 201 do { \ 202 uint16_t val; \ 203 do { \ 204 val = __LDREXH((__IO uint16_t *)&(REG)) & ~(BIT); \ 205 } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \ 206 } while(0) 207 208 /* Atomic 16-bit register access macro to clear and set one or several bits */ 209 #define ATOMIC_MODIFYH_REG(REG, CLEARMSK, SETMASK) \ 210 do { \ 211 uint16_t val; \ 212 do { \ 213 val = (__LDREXH((__IO uint16_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \ 214 } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \ 215 } while(0) 216 217 #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL))) 218 219 220 /** 221 * @} 222 */ 223 224 #if defined (USE_HAL_DRIVER) 225 #include "stm32wbaxx_hal.h" 226 #endif /* USE_HAL_DRIVER */ 227 228 #ifdef __cplusplus 229 } 230 #endif /* __cplusplus */ 231 232 #endif /* STM32WBAxx_H */ 233 /** 234 * @} 235 */ 236 237 /** 238 * @} 239 */ 240 241