1 /** 2 ****************************************************************************** 3 * @file stm32l1xx.h 4 * @author MCD Application Team 5 * @brief CMSIS STM32L1xx 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 STM32L1xx 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 * <h2><center>© Copyright (c) 2017 STMicroelectronics. 20 * All rights reserved.</center></h2> 21 * 22 * This software component is licensed by ST under BSD 3-Clause license, 23 * the "License"; You may not use this file except in compliance with the 24 * License. You may obtain a copy of the License at: 25 * opensource.org/licenses/BSD-3-Clause 26 * 27 ****************************************************************************** 28 */ 29 30 /** @addtogroup CMSIS 31 * @{ 32 */ 33 34 /** @addtogroup stm32l1xx 35 * @{ 36 */ 37 38 #ifndef __STM32L1XX_H 39 #define __STM32L1XX_H 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif /* __cplusplus */ 44 45 /** @addtogroup Library_configuration_section 46 * @{ 47 */ 48 49 /** 50 * @brief STM32 Family 51 */ 52 #if !defined (STM32L1) 53 #define STM32L1 54 #endif /* STM32L1 */ 55 56 57 /* Uncomment the line below according to the target STM32L device used in your 58 application 59 */ 60 61 #if !defined (STM32L100xB) && !defined (STM32L100xBA) && !defined (STM32L100xC) && \ 62 !defined (STM32L151xB) && !defined (STM32L151xBA) && !defined (STM32L151xC) && !defined (STM32L151xCA) && !defined (STM32L151xD) && !defined (STM32L151xDX) && !defined (STM32L151xE) && \ 63 !defined (STM32L152xB) && !defined (STM32L152xBA) && !defined (STM32L152xC) && !defined (STM32L152xCA) && !defined (STM32L152xD) && !defined (STM32L152xDX) && !defined (STM32L152xE) && \ 64 !defined (STM32L162xC) && !defined (STM32L162xCA) && !defined (STM32L162xD) && !defined (STM32L162xDX) && !defined (STM32L162xE) 65 /* #define STM32L100xB */ /*!< STM32L100C6, STM32L100R and STM32L100RB Devices */ 66 /* #define STM32L100xBA */ /*!< STM32L100C6-A, STM32L100R8-A and STM32L100RB-A Devices */ 67 /* #define STM32L100xC */ /*!< STM32L100RC Devices */ 68 /* #define STM32L151xB */ /*!< STM32L151C6, STM32L151R6, STM32L151C8, STM32L151R8, STM32L151V8, STM32L151CB, STM32L151RB and STM32L151VB */ 69 /* #define STM32L151xBA */ /*!< STM32L151C6-A, STM32L151R6-A, STM32L151C8-A, STM32L151R8-A, STM32L151V8-A, STM32L151CB-A, STM32L151RB-A and STM32L151VB-A */ 70 /* #define STM32L151xC */ /*!< STM32L151CC, STM32L151UC, STM32L151RC and STM32L151VC */ 71 /* #define STM32L151xCA */ /*!< STM32L151RC-A, STM32L151VC-A, STM32L151QC and STM32L151ZC */ 72 /* #define STM32L151xD */ /*!< STM32L151QD, STM32L151RD, STM32L151VD & STM32L151ZD */ 73 /* #define STM32L151xDX */ /*!< STM32L151VD-X Devices */ 74 /* #define STM32L151xE */ /*!< STM32L151QE, STM32L151RE, STM32L151VE and STM32L151ZE */ 75 /* #define STM32L152xB */ /*!< STM32L152C6, STM32L152R6, STM32L152C8, STM32L152R8, STM32L152V8, STM32L152CB, STM32L152RB and STM32L152VB */ 76 /* #define STM32L152xBA */ /*!< STM32L152C6-A, STM32L152R6-A, STM32L152C8-A, STM32L152R8-A, STM32L152V8-A, STM32L152CB-A, STM32L152RB-A and STM32L152VB-A */ 77 /* #define STM32L152xC */ /*!< STM32L152CC, STM32L152UC, STM32L152RC and STM32L152VC */ 78 /* #define STM32L152xCA */ /*!< STM32L152RC-A, STM32L152VC-A, STM32L152QC and STM32L152ZC */ 79 /* #define STM32L152xD */ /*!< STM32L152QD, STM32L152RD, STM32L152VD and STM32L152ZD */ 80 /* #define STM32L152xDX */ /*!< STM32L152VD-X Devices */ 81 /* #define STM32L152xE */ /*!< STM32L152QE, STM32L152RE, STM32L152VE and STM32L152ZE */ 82 /* #define STM32L162xC */ /*!< STM32L162RC and STM32L162VC */ 83 /* #define STM32L162xCA */ /*!< STM32L162RC-A, STM32L162VC-A, STM32L162QC and STM32L162ZC */ 84 /* #define STM32L162xD */ /*!< STM32L162QD, STM32L162RD, STM32L162VD and STM32L162ZD */ 85 /* #define STM32L162xDX */ /*!< STM32L162VD-X Devices */ 86 /* #define STM32L162xE */ /*!< STM32L162RE, STM32L162VE and STM32L162ZE */ 87 #endif 88 89 /* Tip: To avoid modifying this file each time you need to switch between these 90 devices, you can define the device in your toolchain compiler preprocessor. 91 */ 92 93 #if !defined (USE_HAL_DRIVER) 94 /** 95 * @brief Comment the line below if you will not use the peripherals drivers. 96 In this case, these drivers will not be included and the application code will 97 be based on direct access to peripherals registers 98 */ 99 /*#define USE_HAL_DRIVER */ 100 #endif /* USE_HAL_DRIVER */ 101 102 /** 103 * @brief CMSIS Device version number V2.3.2 104 */ 105 #define __STM32L1xx_CMSIS_VERSION_MAIN (0x02) /*!< [31:24] main version */ 106 #define __STM32L1xx_CMSIS_VERSION_SUB1 (0x03) /*!< [23:16] sub1 version */ 107 #define __STM32L1xx_CMSIS_VERSION_SUB2 (0x02) /*!< [15:8] sub2 version */ 108 #define __STM32L1xx_CMSIS_VERSION_RC (0x00) /*!< [7:0] release candidate */ 109 #define __STM32L1xx_CMSIS_VERSION ((__STM32L1xx_CMSIS_VERSION_MAIN << 24)\ 110 |(__STM32L1xx_CMSIS_VERSION_SUB1 << 16)\ 111 |(__STM32L1xx_CMSIS_VERSION_SUB2 << 8 )\ 112 |(__STM32L1xx_CMSIS_VERSION_RC)) 113 114 /** 115 * @} 116 */ 117 118 /** @addtogroup Device_Included 119 * @{ 120 */ 121 122 #if defined(STM32L100xB) 123 #include "stm32l100xb.h" 124 #elif defined(STM32L100xBA) 125 #include "stm32l100xba.h" 126 #elif defined(STM32L100xC) 127 #include "stm32l100xc.h" 128 #elif defined(STM32L151xB) 129 #include "stm32l151xb.h" 130 #elif defined(STM32L151xBA) 131 #include "stm32l151xba.h" 132 #elif defined(STM32L151xC) 133 #include "stm32l151xc.h" 134 #elif defined(STM32L151xCA) 135 #include "stm32l151xca.h" 136 #elif defined(STM32L151xD) 137 #include "stm32l151xd.h" 138 #elif defined(STM32L151xDX) 139 #include "stm32l151xdx.h" 140 #elif defined(STM32L151xE) 141 #include "stm32l151xe.h" 142 #elif defined(STM32L152xB) 143 #include "stm32l152xb.h" 144 #elif defined(STM32L152xBA) 145 #include "stm32l152xba.h" 146 #elif defined(STM32L152xC) 147 #include "stm32l152xc.h" 148 #elif defined(STM32L152xCA) 149 #include "stm32l152xca.h" 150 #elif defined(STM32L152xD) 151 #include "stm32l152xd.h" 152 #elif defined(STM32L152xDX) 153 #include "stm32l152xdx.h" 154 #elif defined(STM32L152xE) 155 #include "stm32l152xe.h" 156 #elif defined(STM32L162xC) 157 #include "stm32l162xc.h" 158 #elif defined(STM32L162xCA) 159 #include "stm32l162xca.h" 160 #elif defined(STM32L162xD) 161 #include "stm32l162xd.h" 162 #elif defined(STM32L162xDX) 163 #include "stm32l162xdx.h" 164 #elif defined(STM32L162xE) 165 #include "stm32l162xe.h" 166 #else 167 #error "Please select first the target STM32L1xx device used in your application (in stm32l1xx.h file)" 168 #endif 169 170 /** 171 * @} 172 */ 173 174 /** @addtogroup Exported_types 175 * @{ 176 */ 177 typedef enum 178 { 179 RESET = 0, 180 SET = !RESET 181 } FlagStatus, ITStatus; 182 183 typedef enum 184 { 185 DISABLE = 0, 186 ENABLE = !DISABLE 187 } FunctionalState; 188 #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) 189 190 typedef enum 191 { 192 SUCCESS = 0, 193 ERROR = !SUCCESS 194 } ErrorStatus; 195 196 /** 197 * @} 198 */ 199 200 201 /** @addtogroup Exported_macros 202 * @{ 203 */ 204 #define SET_BIT(REG, BIT) ((REG) |= (BIT)) 205 206 #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) 207 208 #define READ_BIT(REG, BIT) ((REG) & (BIT)) 209 210 #define CLEAR_REG(REG) ((REG) = (0x0)) 211 212 #define WRITE_REG(REG, VAL) ((REG) = (VAL)) 213 214 #define READ_REG(REG) ((REG)) 215 216 #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) 217 218 /* Use of CMSIS compiler intrinsics for register exclusive access */ 219 /* Atomic 32-bit register access macro to set one or several bits */ 220 #define ATOMIC_SET_BIT(REG, BIT) \ 221 do { \ 222 uint32_t val; \ 223 do { \ 224 val = __LDREXW((__IO uint32_t *)&(REG)) | (BIT); \ 225 } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \ 226 } while(0) 227 228 /* Atomic 32-bit register access macro to clear one or several bits */ 229 #define ATOMIC_CLEAR_BIT(REG, BIT) \ 230 do { \ 231 uint32_t val; \ 232 do { \ 233 val = __LDREXW((__IO uint32_t *)&(REG)) & ~(BIT); \ 234 } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \ 235 } while(0) 236 237 /* Atomic 32-bit register access macro to clear and set one or several bits */ 238 #define ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \ 239 do { \ 240 uint32_t val; \ 241 do { \ 242 val = (__LDREXW((__IO uint32_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \ 243 } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \ 244 } while(0) 245 246 /* Atomic 16-bit register access macro to set one or several bits */ 247 #define ATOMIC_SETH_BIT(REG, BIT) \ 248 do { \ 249 uint16_t val; \ 250 do { \ 251 val = __LDREXH((__IO uint16_t *)&(REG)) | (BIT); \ 252 } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \ 253 } while(0) 254 255 /* Atomic 16-bit register access macro to clear one or several bits */ 256 #define ATOMIC_CLEARH_BIT(REG, BIT) \ 257 do { \ 258 uint16_t val; \ 259 do { \ 260 val = __LDREXH((__IO uint16_t *)&(REG)) & ~(BIT); \ 261 } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \ 262 } while(0) 263 264 /* Atomic 16-bit register access macro to clear and set one or several bits */ 265 #define ATOMIC_MODIFYH_REG(REG, CLEARMSK, SETMASK) \ 266 do { \ 267 uint16_t val; \ 268 do { \ 269 val = (__LDREXH((__IO uint16_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \ 270 } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \ 271 } while(0) 272 273 #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL))) 274 275 276 /** 277 * @} 278 */ 279 280 #if defined (USE_HAL_DRIVER) 281 #include "stm32l1xx_hal.h" 282 #endif /* USE_HAL_DRIVER */ 283 284 285 #ifdef __cplusplus 286 } 287 #endif /* __cplusplus */ 288 289 #endif /* __STM32L1xx_H */ 290 /** 291 * @} 292 */ 293 294 /** 295 * @} 296 */ 297 298 299 300 301 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 302