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