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