1 /** 2 ****************************************************************************** 3 * @file stm32f2xx.h 4 * @author MCD Application Team 5 * @brief CMSIS STM32F2xx 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 STM32F2xx 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) 2017-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 stm32f2xx 34 * @{ 35 */ 36 37 #ifndef __STM32F2xx_H 38 #define __STM32F2xx_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 (STM32F2) 52 #define STM32F2 53 #endif /* STM32F2 */ 54 55 /* Uncomment the line below according to the target STM32 device used in your 56 application 57 */ 58 #if !defined (STM32F205xx) && !defined (STM32F215xx) && !defined (STM32F207xx) && !defined (STM32F217xx) 59 60 /* #define STM32F205xx */ /*!< STM32F205RG, STM32F205VG, STM32F205ZG, STM32F205RF, STM32F205VF, STM32F205ZF, 61 STM32F205RE, STM32F205VE, STM32F205ZE, STM32F205RC, STM32F205VC, STM32F205ZC, 62 STM32F205RB and STM32F205VB Devices */ 63 /* #define STM32F215xx */ /*!< STM32F215RG, STM32F215VG, STM32F215ZG, STM32F215RE, STM32F215VE and STM32F215ZE Devices */ 64 /* #define STM32F207xx */ /*!< STM32F207VG, STM32F207ZG, STM32F207IG, STM32F207VF, STM32F207ZF, STM32F207IF, 65 STM32F207VE, STM32F207ZE, STM32F207IE, STM32F207VC, STM32F207ZC and STM32F207IC Devices */ 66 /* #define STM32F217xx */ /*!< STM32F217VG, STM32F217ZG, STM32F217IG, STM32F217VE, STM32F217ZE and STM32F217IE Devices */ 67 68 #endif 69 70 /* Tip: To avoid modifying this file each time you need to switch between these 71 devices, you can define the device in your toolchain compiler preprocessor. 72 */ 73 #if !defined (USE_HAL_DRIVER) 74 /** 75 * @brief Comment the line below if you will not use the peripherals drivers. 76 In this case, these drivers will not be included and the application code will 77 be based on direct access to peripherals registers 78 */ 79 /*#define USE_HAL_DRIVER */ 80 #endif /* USE_HAL_DRIVER */ 81 82 /** 83 * @brief CMSIS Device version number 84 */ 85 #define __STM32F2xx_CMSIS_VERSION_MAIN (0x02U) /*!< [31:24] main version */ 86 #define __STM32F2xx_CMSIS_VERSION_SUB1 (0x02U) /*!< [23:16] sub1 version */ 87 #define __STM32F2xx_CMSIS_VERSION_SUB2 (0x06U) /*!< [15:8] sub2 version */ 88 #define __STM32F2xx_CMSIS_VERSION_RC (0x00U) /*!< [7:0] release candidate */ 89 #define __STM32F2xx_CMSIS_VERSION ((__STM32F2xx_CMSIS_VERSION_MAIN << 24)\ 90 |(__STM32F2xx_CMSIS_VERSION_SUB1 << 16)\ 91 |(__STM32F2xx_CMSIS_VERSION_SUB2 << 8 )\ 92 |(__STM32F2xx_CMSIS_VERSION)) 93 94 /** 95 * @} 96 */ 97 98 /** @addtogroup Device_Included 99 * @{ 100 */ 101 102 #if defined(STM32F205xx) 103 #include "stm32f205xx.h" 104 #elif defined(STM32F215xx) 105 #include "stm32f215xx.h" 106 #elif defined(STM32F207xx) 107 #include "stm32f207xx.h" 108 #elif defined(STM32F217xx) 109 #include "stm32f217xx.h" 110 #else 111 #error "Please select first the target STM32F2xx device used in your application (in stm32f2xx.h file)" 112 #endif 113 114 /** 115 * @} 116 */ 117 118 /** @addtogroup Exported_types 119 * @{ 120 */ 121 typedef enum 122 { 123 RESET = 0U, 124 SET = !RESET 125 } FlagStatus, ITStatus; 126 127 typedef enum 128 { 129 DISABLE = 0U, 130 ENABLE = !DISABLE 131 } FunctionalState; 132 #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) 133 134 typedef enum 135 { 136 SUCCESS = 0U, 137 ERROR = !SUCCESS 138 } ErrorStatus; 139 140 /** 141 * @} 142 */ 143 144 145 /** @addtogroup Exported_macro 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 #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL))) 163 164 /* Use of CMSIS compiler intrinsics for register exclusive access */ 165 /* Atomic 32-bit register access macro to set one or several bits */ 166 #define ATOMIC_SET_BIT(REG, BIT) \ 167 do { \ 168 uint32_t val; \ 169 do { \ 170 val = __LDREXW((__IO uint32_t *)&(REG)) | (BIT); \ 171 } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \ 172 } while(0) 173 174 /* Atomic 32-bit register access macro to clear one or several bits */ 175 #define ATOMIC_CLEAR_BIT(REG, BIT) \ 176 do { \ 177 uint32_t val; \ 178 do { \ 179 val = __LDREXW((__IO uint32_t *)&(REG)) & ~(BIT); \ 180 } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \ 181 } while(0) 182 183 /* Atomic 32-bit register access macro to clear and set one or several bits */ 184 #define ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \ 185 do { \ 186 uint32_t val; \ 187 do { \ 188 val = (__LDREXW((__IO uint32_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \ 189 } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \ 190 } while(0) 191 192 /* Atomic 16-bit register access macro to set one or several bits */ 193 #define ATOMIC_SETH_BIT(REG, BIT) \ 194 do { \ 195 uint16_t val; \ 196 do { \ 197 val = __LDREXH((__IO uint16_t *)&(REG)) | (BIT); \ 198 } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \ 199 } while(0) 200 201 /* Atomic 16-bit register access macro to clear one or several bits */ 202 #define ATOMIC_CLEARH_BIT(REG, BIT) \ 203 do { \ 204 uint16_t val; \ 205 do { \ 206 val = __LDREXH((__IO uint16_t *)&(REG)) & ~(BIT); \ 207 } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \ 208 } while(0) 209 210 /* Atomic 16-bit register access macro to clear and set one or several bits */ 211 #define ATOMIC_MODIFYH_REG(REG, CLEARMSK, SETMASK) \ 212 do { \ 213 uint16_t val; \ 214 do { \ 215 val = (__LDREXH((__IO uint16_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \ 216 } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \ 217 } while(0) 218 219 /** 220 * @} 221 */ 222 223 #if defined (USE_HAL_DRIVER) 224 #include "stm32f2xx_hal.h" 225 #endif /* USE_HAL_DRIVER */ 226 227 #ifdef __cplusplus 228 } 229 #endif /* __cplusplus */ 230 231 #endif /* __STM32F2xx_H */ 232 233 /** 234 * @} 235 */ 236 237 /** 238 * @} 239 */ 240 241 242 243 244