|
| 1 | +/** |
| 2 | + ****************************************************************************** |
| 3 | + * @file stm32wb0x.h |
| 4 | + * @author MCD Application Team |
| 5 | + * @brief CMSIS STM32WB0x 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 STM32WB0x 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) 2024 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 stm32wb0x |
| 34 | + * @{ |
| 35 | + */ |
| 36 | + |
| 37 | +#ifndef __STM32WB0x_H |
| 38 | +#define __STM32WB0x_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 (STM32WB0) |
| 52 | +#define STM32WB0 |
| 53 | +#endif /* STM32WB0 */ |
| 54 | + |
| 55 | +/* Uncomment the line below according to the target STM32WB0 device used in your |
| 56 | + application |
| 57 | + */ |
| 58 | + |
| 59 | +#if !defined(STM32WB05) && !defined(STM32WB06) && !defined(STM32WB07) && !defined(STM32WB09) |
| 60 | + /* #define STM32WB05 */ /*!< STM32WB05 Devices */ |
| 61 | + /* #define STM32WB06 */ /*!< STM32WB06 Devices */ |
| 62 | + /* #define STM32WB07 */ /*!< STM32WB07 Devices */ |
| 63 | + /* #define STM32WB09 */ /*!< STM32WB09 Devices */ |
| 64 | +#endif /* !STM32WB05 && !STM32WB06 && !STM32WB07 && !STM32WB09 */ |
| 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 __STM32WB0x_CMSIS_VERSION_MAIN (0x01U) /*!< [31:24] main version */ |
| 82 | +#define __STM32WB0x_CMSIS_VERSION_SUB1 (0x03U) /*!< [23:16] sub1 version */ |
| 83 | +#define __STM32WB0x_CMSIS_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */ |
| 84 | +#define __STM32WB0x_CMSIS_VERSION_RC (0x00U) /*!< [7:0] release candidate */ |
| 85 | +#define __STM32WB0x_CMSIS_DEVICE_VERSION ((__STM32WB0x_CMSIS_VERSION_MAIN << 24)\ |
| 86 | + |(__STM32WB0x_CMSIS_VERSION_SUB1 << 16)\ |
| 87 | + |(__STM32WB0x_CMSIS_VERSION_SUB2 << 8 )\ |
| 88 | + |(__STM32WB0x_CMSIS_VERSION_RC)) |
| 89 | + |
| 90 | +/** |
| 91 | + * @} |
| 92 | + */ |
| 93 | + |
| 94 | +/** @addtogroup Device_Included |
| 95 | + * @{ |
| 96 | + */ |
| 97 | + |
| 98 | +#if defined( STM32WB05) || defined( STM32WB05x) |
| 99 | + |
| 100 | +#include "stm32wb05.h" /* Header file supporting STM32WB05 */ |
| 101 | + |
| 102 | +#elif defined( STM32WB06) || defined( STM32WB06x) |
| 103 | + |
| 104 | +#include "stm32wb06.h" /* Header file supporting STM32WB06 */ |
| 105 | + |
| 106 | +#elif defined( STM32WB07) || defined( STM32WB07x) |
| 107 | + |
| 108 | +#include "stm32wb07.h" /* Header file supporting STM32WB07 */ |
| 109 | + |
| 110 | +#elif defined( STM32WB09) || defined( STM32WB09x) |
| 111 | + |
| 112 | +#include "stm32wb09.h" /* Header file supporting STM32WB09 */ |
| 113 | + |
| 114 | +#else |
| 115 | + |
| 116 | +#error "Please select first the target STM32WB0x device used in your application, for instance xx (in stm32wb0x.h file)" |
| 117 | + |
| 118 | +#endif |
| 119 | +#include "system_stm32wb0x.h" |
| 120 | + |
| 121 | +/** |
| 122 | + * @} |
| 123 | + */ |
| 124 | + |
| 125 | +/** @addtogroup Exported_types |
| 126 | + * @{ |
| 127 | + */ |
| 128 | +typedef enum |
| 129 | +{ |
| 130 | + RESET = 0, |
| 131 | + SET = !RESET |
| 132 | +} FlagStatus, ITStatus; |
| 133 | + |
| 134 | +typedef enum |
| 135 | +{ |
| 136 | + DISABLE = 0, |
| 137 | + ENABLE = !DISABLE |
| 138 | +} FunctionalState; |
| 139 | +#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) |
| 140 | + |
| 141 | +typedef enum |
| 142 | +{ |
| 143 | + SUCCESS = 0, |
| 144 | + ERROR = !SUCCESS |
| 145 | +} ErrorStatus; |
| 146 | + |
| 147 | +/** @brief Booelan definition */ |
| 148 | +typedef uint8_t BOOL; |
| 149 | + |
| 150 | +#define TRUE ((BOOL)1U) |
| 151 | +#define FALSE ((BOOL)0U) |
| 152 | + |
| 153 | +/** |
| 154 | + * @} |
| 155 | + */ |
| 156 | + |
| 157 | + |
| 158 | +/** @addtogroup Exported_macros |
| 159 | + * @{ |
| 160 | + */ |
| 161 | +#define SET_BIT(REG, BIT) ((REG) |= (BIT)) |
| 162 | + |
| 163 | +#define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) |
| 164 | + |
| 165 | +#define READ_BIT(REG, BIT) ((REG) & (BIT)) |
| 166 | + |
| 167 | +#define TOGGLE_BIT(REG, BIT) ((REG) ^= (BIT)) |
| 168 | + |
| 169 | +#define CLEAR_REG(REG) ((REG) = (0x0)) |
| 170 | + |
| 171 | +#define WRITE_REG(REG, VAL) ((REG) = (VAL)) |
| 172 | + |
| 173 | +#define READ_REG(REG) ((REG)) |
| 174 | + |
| 175 | +#define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) |
| 176 | + |
| 177 | +#define MODIFY_REG_FIELD(REG, FIELD_NAME, VAL) MODIFY_REG(REG, FIELD_NAME##_Msk, ((VAL)<<(FIELD_NAME##_Pos))&\ |
| 178 | + (FIELD_NAME##_Msk)) |
| 179 | + |
| 180 | +/* Use of interrupt control for register exclusive access (privileged mode only) */ |
| 181 | +/* Atomic 32-bit register access macro to set one or several bits */ |
| 182 | +#define ATOMIC_SET_BIT(REG, BIT) \ |
| 183 | + do { \ |
| 184 | + uint32_t primask; \ |
| 185 | + primask = __get_PRIMASK(); \ |
| 186 | + __set_PRIMASK(1); \ |
| 187 | + SET_BIT((REG), (BIT)); \ |
| 188 | + __set_PRIMASK(primask); \ |
| 189 | + } while(0) |
| 190 | + |
| 191 | +/* Atomic 32-bit register access macro to clear one or several bits */ |
| 192 | +#define ATOMIC_CLEAR_BIT(REG, BIT) \ |
| 193 | + do { \ |
| 194 | + uint32_t primask; \ |
| 195 | + primask = __get_PRIMASK(); \ |
| 196 | + __set_PRIMASK(1); \ |
| 197 | + CLEAR_BIT((REG), (BIT)); \ |
| 198 | + __set_PRIMASK(primask); \ |
| 199 | + } while(0) |
| 200 | + |
| 201 | +/* Atomic 32-bit register access macro to clear and set one or several bits */ |
| 202 | +#define ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \ |
| 203 | + do { \ |
| 204 | + uint32_t primask; \ |
| 205 | + primask = __get_PRIMASK(); \ |
| 206 | + __set_PRIMASK(1); \ |
| 207 | + MODIFY_REG((REG), (CLEARMSK), (SETMASK)); \ |
| 208 | + __set_PRIMASK(primask); \ |
| 209 | + } while(0) |
| 210 | + |
| 211 | +/* Atomic 16-bit register access macro to set one or several bits */ |
| 212 | +#define ATOMIC_SETH_BIT(REG, BIT) ATOMIC_SET_BIT(REG, BIT) |
| 213 | + |
| 214 | +/* Atomic 16-bit register access macro to clear one or several bits */ |
| 215 | +#define ATOMIC_CLEARH_BIT(REG, BIT) ATOMIC_CLEAR_BIT(REG, BIT) |
| 216 | + |
| 217 | +/* Atomic 16-bit register access macro to clear and set one or several bits */ |
| 218 | +#define ATOMIC_MODIFYH_REG(REG, CLEARMSK, SETMASK) ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) |
| 219 | + |
| 220 | +/** |
| 221 | + * @} |
| 222 | + */ |
| 223 | + |
| 224 | +#if defined (USE_HAL_DRIVER) |
| 225 | +#include "stm32wb0x_hal.h" |
| 226 | +#endif /* USE_HAL_DRIVER */ |
| 227 | + |
| 228 | +#ifdef __cplusplus |
| 229 | +} |
| 230 | +#endif /* __cplusplus */ |
| 231 | + |
| 232 | +#endif /* __STM32WB0x_H */ |
| 233 | +/** |
| 234 | + * @} |
| 235 | + */ |
| 236 | + |
| 237 | +/** |
| 238 | + * @} |
| 239 | + */ |
0 commit comments