1 /**
2   ******************************************************************************
3   * @file    stm32l0xx.h
4   * @author  MCD Application Team
5   * @brief   CMSIS Cortex-M0+ Device Peripheral Access Layer Header File.
6   *          This file contains all the peripheral register's definitions, bits
7   *          definitions and memory mapping for STM32L0xx devices.
8   *
9   *          The file is the unique include file that the application programmer
10   *          is using in the C source code, usually in main.c. This file contains:
11   *           - Configuration section that allows to select:
12   *              - The device used in the target application
13   *              - To use or not the peripheral's drivers in application code(i.e.
14   *                code will be based on direct access to peripheral's registers
15   *                rather than drivers API), this option is controlled by
16   *                "#define USE_HAL_DRIVER"
17   *
18   ******************************************************************************
19   * @attention
20   *
21   * Copyright (c) 2016 STMicroelectronics.
22   * All rights reserved.
23   *
24   * This software is licensed under terms that can be found in the LICENSE file
25   * in the root directory of this software component.
26   * If no LICENSE file comes with this software, it is provided AS-IS.
27   *
28   ******************************************************************************
29   */
30 
31 /** @addtogroup CMSIS
32   * @{
33   */
34 
35 /** @addtogroup stm32l0xx
36   * @{
37   */
38 
39 #ifndef __STM32L0xx_H
40 #define __STM32L0xx_H
41 
42 #ifdef __cplusplus
43  extern "C" {
44 #endif /* __cplusplus */
45 
46 /** @addtogroup Library_configuration_section
47   * @{
48   */
49 
50 /**
51   * @brief STM32 Family
52   */
53 #if !defined (STM32L0)
54 #define STM32L0
55 #endif /* STM32L0 */
56 
57 /* Uncomment the line below according to the target STM32 device used in your
58    application
59   */
60 
61 #if !defined (STM32L010x4) && !defined (STM32L010x6) && !defined (STM32L010x8) && !defined (STM32L010xB) && \
62     !defined (STM32L011xx) && !defined (STM32L021xx) && \
63     !defined (STM32L031xx) && !defined (STM32L041xx) && \
64     !defined (STM32L051xx) && !defined (STM32L052xx) && !defined (STM32L053xx) && \
65     !defined (STM32L062xx) && !defined (STM32L063xx) && \
66     !defined (STM32L071xx) && !defined (STM32L072xx) && !defined (STM32L073xx) && \
67     !defined (STM32L081xx) && !defined (STM32L082xx) && !defined (STM32L083xx)
68   /* #define STM32L010x4 */   /*!< STM32L010K4, STM32L010F4 Devices                                                                                                                      */
69   /* #define STM32L010x6 */   /*!< STM32L010C6 Devices                                                                                                                                   */
70   /* #define STM32L010x8 */   /*!< STM32L010K8, STM32L010R8 Devices                                                                                                                      */
71   /* #define STM32L010xB */   /*!< STM32L010RB Devices                                                                                                                                   */
72   /* #define STM32L011xx */   /*!< STM32L031C6, STM32L031E6, STM32L031F6, STM32L031G6, STM32L031K6 Devices                                                                               */
73   /* #define STM32L021xx */   /*!< STM32L021D4, STM32L021F4, STM32L021G4, STM32L021K4 Devices                                                                                            */
74   /* #define STM32L031xx */   /*!< STM32L031C6, STM32L031E6, STM32L031F6, STM32L031G6, STM32L031K6 Devices                                                                               */
75   /* #define STM32L041xx */   /*!< STM32L041C6, STM32L041K6, STM32L041G6, STM32L041F6, STM32L041E6 Devices                                                                               */
76   /* #define STM32L051xx */   /*!< STM32L051K8, STM32L051C6, STM32L051C8, STM32L051R6, STM32L051R8, STM32L051K6, STM32L051T6, STM32L051T8 Devices                                        */
77   /* #define STM32L052xx */   /*!< STM32L052K6, STM32L052K8, STM32L052C6, STM32L052C8, STM32L052R6, STM32L052R8, STM32L052T6, STM32L052T8 Devices                                        */
78   /* #define STM32L053xx */   /*!< STM32L053C6, STM32L053C8, STM32L053R6, STM32L053R8 Devices                                                                                            */
79   /* #define STM32L062xx */   /*!< STM32L062K8 Devices                                                                                                                                   */
80   /* #define STM32L063xx */   /*!< STM32L063C8, STM32L063R8 Devices                                                                                                                      */
81   /* #define STM32L071xx */   /*!< STM32L071V8, STM32L071K8, STM32L071VB, STM32L071RB, STM32L071CB, STM32L071KB, STM32L071VZ, STM32L071RZ, STM32L071CZ, STM32L071KZ, STM32L071C8 Devices */
82   /* #define STM32L072xx */   /*!< STM32L072V8, STM32L072VB, STM32L072RB, STM32L072CB, STM32L072VZ, STM32L072RZ, STM32L072CZ, STM32L072KB, STM32L072KZ Devices                           */
83   /* #define STM32L073xx */   /*!< STM32L073V8, STM32L073VB, STM32L073RB, STM32L073VZ, STM32L073RZ, STM32L073CB, STM32L073CZ Devices                                                     */
84   /* #define STM32L081xx */   /*!< STM32L081CB, STM32L081CZ, STM32L081KZ Devices                                                                                                         */
85   /* #define STM32L082xx */   /*!< STM32L082KB, STM32L082KZ, STM32L082CZ Devices                                                                                                         */
86   /* #define STM32L083xx */   /*!< STM32L083V8, STM32L083VB, STM32L083RB, STM32L083VZ, STM32L083RZ, STM32L083CB, STM32L083CZ Devices                                                     */
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 #if !defined  (USE_HAL_DRIVER)
93 /**
94  * @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    be based on direct access to peripherals registers
97    */
98   /*#define USE_HAL_DRIVER */
99 #endif /* USE_HAL_DRIVER */
100 
101 /**
102   * @brief CMSIS Device version number
103   */
104 #define __STM32L0xx_CMSIS_VERSION_MAIN   (0x01) /*!< [31:24] main version */
105 #define __STM32L0xx_CMSIS_VERSION_SUB1   (0x09) /*!< [23:16] sub1 version */
106 #define __STM32L0xx_CMSIS_VERSION_SUB2   (0x03) /*!< [15:8]  sub2 version */
107 #define __STM32L0xx_CMSIS_VERSION_RC     (0x00) /*!< [7:0]  release candidate */
108 #define __STM32L0xx_CMSIS_VERSION        ((__STM32L0xx_CMSIS_VERSION_MAIN     << 24)\
109                                          |(__STM32L0xx_CMSIS_VERSION_SUB1 << 16)\
110                                          |(__STM32L0xx_CMSIS_VERSION_SUB2 << 8 )\
111                                          |(__STM32L0xx_CMSIS_VERSION_RC))
112 
113 /**
114   * @}
115   */
116 
117 /** @addtogroup Device_Included
118   * @{
119   */
120 #if defined(STM32L010xB)
121   #include "stm32l010xb.h"
122 #elif defined(STM32L010x8)
123   #include "stm32l010x8.h"
124 #elif defined(STM32L010x6)
125   #include "stm32l010x6.h"
126 #elif defined(STM32L010x4)
127   #include "stm32l010x4.h"
128 #elif defined(STM32L011xx)
129   #include "stm32l011xx.h"
130 #elif defined(STM32L021xx)
131   #include "stm32l021xx.h"
132 #elif defined(STM32L031xx)
133   #include "stm32l031xx.h"
134 #elif defined(STM32L041xx)
135   #include "stm32l041xx.h"
136 #elif defined(STM32L051xx)
137   #include "stm32l051xx.h"
138 #elif defined(STM32L052xx)
139   #include "stm32l052xx.h"
140 #elif defined(STM32L053xx)
141   #include "stm32l053xx.h"
142 #elif defined(STM32L062xx)
143   #include "stm32l062xx.h"
144 #elif defined(STM32L063xx)
145   #include "stm32l063xx.h"
146 #elif defined(STM32L071xx)
147   #include "stm32l071xx.h"
148 #elif defined(STM32L072xx)
149   #include "stm32l072xx.h"
150 #elif defined(STM32L073xx)
151   #include "stm32l073xx.h"
152 #elif defined(STM32L082xx)
153   #include "stm32l082xx.h"
154 #elif defined(STM32L083xx)
155   #include "stm32l083xx.h"
156 #elif defined(STM32L081xx)
157   #include "stm32l081xx.h"
158 #else
159  #error "Please select first the target STM32L0xx device used in your application (in stm32l0xx.h file)"
160 #endif
161 
162 /**
163   * @}
164   */
165 
166 /** @addtogroup Exported_types
167   * @{
168   */
169 typedef enum
170 {
171   RESET = 0,
172   SET = !RESET
173 } FlagStatus, ITStatus;
174 
175 typedef enum
176 {
177   DISABLE = 0,
178   ENABLE = !DISABLE
179 } FunctionalState;
180 #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
181 
182 typedef enum
183 {
184   SUCCESS = 0,
185   ERROR = !SUCCESS
186 } ErrorStatus;
187 
188 /**
189   * @}
190   */
191 
192 
193 /** @addtogroup Exported_macro
194   * @{
195   */
196 #define SET_BIT(REG, BIT)     ((REG) |= (BIT))
197 
198 #define CLEAR_BIT(REG, BIT)   ((REG) &= ~(BIT))
199 
200 #define READ_BIT(REG, BIT)    ((REG) & (BIT))
201 
202 #define CLEAR_REG(REG)        ((REG) = (0x0))
203 
204 #define WRITE_REG(REG, VAL)   ((REG) = (VAL))
205 
206 #define READ_REG(REG)         ((REG))
207 
208 #define MODIFY_REG(REG, CLEARMASK, SETMASK)  WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
209 
210 /* Use of interrupt control for register exclusive access */
211 /* Atomic 32-bit register access macro to set one or several bits */
212 #define ATOMIC_SET_BIT(REG, BIT)                             \
213   do {                                                       \
214     uint32_t primask;                                        \
215     primask = __get_PRIMASK();                               \
216     __set_PRIMASK(1);                                        \
217     SET_BIT((REG), (BIT));                                   \
218     __set_PRIMASK(primask);                                  \
219   } while(0)
220 
221 /* Atomic 32-bit register access macro to clear one or several bits */
222 #define ATOMIC_CLEAR_BIT(REG, BIT)                           \
223   do {                                                       \
224     uint32_t primask;                                        \
225     primask = __get_PRIMASK();                               \
226     __set_PRIMASK(1);                                        \
227     CLEAR_BIT((REG), (BIT));                                 \
228     __set_PRIMASK(primask);                                  \
229   } while(0)
230 
231 /* Atomic 32-bit register access macro to clear and set one or several bits */
232 #define ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK)            \
233   do {                                                       \
234     uint32_t primask;                                        \
235     primask = __get_PRIMASK();                               \
236     __set_PRIMASK(1);                                        \
237     MODIFY_REG((REG), (CLEARMSK), (SETMASK));                \
238     __set_PRIMASK(primask);                                  \
239   } while(0)
240 
241 /* Atomic 16-bit register access macro to set one or several bits */
242 #define ATOMIC_SETH_BIT(REG, BIT) ATOMIC_SET_BIT(REG, BIT)                                   \
243 
244 /* Atomic 16-bit register access macro to clear one or several bits */
245 #define ATOMIC_CLEARH_BIT(REG, BIT) ATOMIC_CLEAR_BIT(REG, BIT)                               \
246 
247 /* Atomic 16-bit register access macro to clear and set one or several bits */
248 #define ATOMIC_MODIFYH_REG(REG, CLEARMSK, SETMASK) ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \
249 
250 /**
251   * @}
252   */
253 
254 #if defined (USE_HAL_DRIVER)
255  #include "stm32l0xx_hal.h"
256 #endif /* USE_HAL_DRIVER */
257 
258 #ifdef __cplusplus
259 }
260 #endif /* __cplusplus */
261 
262 #endif /* __STM32L0xx_H */
263 /**
264   * @}
265   */
266 
267 /**
268   * @}
269   */
270 
271 
272 
273 
274 
275