stm32l0xx.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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. /** @addtogroup CMSIS
  31. * @{
  32. */
  33. /** @addtogroup stm32l0xx
  34. * @{
  35. */
  36. #ifndef __STM32L0xx_H
  37. #define __STM32L0xx_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif /* __cplusplus */
  41. /** @addtogroup Library_configuration_section
  42. * @{
  43. */
  44. /**
  45. * @brief STM32 Family
  46. */
  47. #if !defined (STM32L0)
  48. #define STM32L0
  49. #endif /* STM32L0 */
  50. /* Uncomment the line below according to the target STM32 device used in your
  51. application
  52. */
  53. #if !defined (STM32L010x4) && !defined (STM32L010x6) && !defined (STM32L010x8) && !defined (STM32L010xB) && \
  54. !defined (STM32L011xx) && !defined (STM32L021xx) && \
  55. !defined (STM32L031xx) && !defined (STM32L041xx) && \
  56. !defined (STM32L051xx) && !defined (STM32L052xx) && !defined (STM32L053xx) && \
  57. !defined (STM32L062xx) && !defined (STM32L063xx) && \
  58. !defined (STM32L071xx) && !defined (STM32L072xx) && !defined (STM32L073xx) && \
  59. !defined (STM32L081xx) && !defined (STM32L082xx) && !defined (STM32L083xx)
  60. /* #define STM32L010x4 */ /*!< STM32L010K4, STM32L010F4 Devices */
  61. /* #define STM32L010x6 */ /*!< STM32L010C6 Devices */
  62. /* #define STM32L010x8 */ /*!< STM32L010K8, STM32L010R8 Devices */
  63. /* #define STM32L010xB */ /*!< STM32L010RB Devices */
  64. /* #define STM32L011xx */ /*!< STM32L031C6, STM32L031E6, STM32L031F6, STM32L031G6, STM32L031K6 Devices */
  65. /* #define STM32L021xx */ /*!< STM32L021D4, STM32L021F4, STM32L021G4, STM32L021K4 Devices */
  66. /* #define STM32L031xx */ /*!< STM32L031C6, STM32L031E6, STM32L031F6, STM32L031G6, STM32L031K6 Devices */
  67. /* #define STM32L041xx */ /*!< STM32L041C6, STM32L041K6, STM32L041G6, STM32L041F6, STM32L041E6 Devices */
  68. /* #define STM32L051xx */ /*!< STM32L051K8, STM32L051C6, STM32L051C8, STM32L051R6, STM32L051R8, STM32L051K6, STM32L051T6, STM32L051T8 Devices */
  69. /* #define STM32L052xx */ /*!< STM32L052K6, STM32L052K8, STM32L052C6, STM32L052C8, STM32L052R6, STM32L052R8, STM32L052T6, STM32L052T8 Devices */
  70. /* #define STM32L053xx */ /*!< STM32L053C6, STM32L053C8, STM32L053R6, STM32L053R8 Devices */
  71. /* #define STM32L062xx */ /*!< STM32L062K8 Devices */
  72. /* #define STM32L063xx */ /*!< STM32L063C8, STM32L063R8 Devices */
  73. /* #define STM32L071xx */ /*!< STM32L071V8, STM32L071K8, STM32L071VB, STM32L071RB, STM32L071CB, STM32L071KB, STM32L071VZ, STM32L071RZ, STM32L071CZ, STM32L071KZ, STM32L071C8 Devices */
  74. /* #define STM32L072xx */ /*!< STM32L072V8, STM32L072VB, STM32L072RB, STM32L072CB, STM32L072VZ, STM32L072RZ, STM32L072CZ, STM32L072KB, STM32L072KZ Devices */
  75. /* #define STM32L073xx */ /*!< STM32L073V8, STM32L073VB, STM32L073RB, STM32L073VZ, STM32L073RZ, STM32L073CB, STM32L073CZ Devices */
  76. /* #define STM32L081xx */ /*!< STM32L081CB, STM32L081CZ, STM32L081KZ Devices */
  77. /* #define STM32L082xx */ /*!< STM32L082KB, STM32L082KZ, STM32L082CZ Devices */
  78. /* #define STM32L083xx */ /*!< STM32L083V8, STM32L083VB, STM32L083RB, STM32L083VZ, STM32L083RZ, STM32L083CB, STM32L083CZ Devices */
  79. #endif
  80. /* Tip: To avoid modifying this file each time you need to switch between these
  81. devices, you can define the device in your toolchain compiler preprocessor.
  82. */
  83. #if !defined (USE_HAL_DRIVER)
  84. /**
  85. * @brief Comment the line below if you will not use the peripherals drivers.
  86. In this case, these drivers will not be included and the application code will
  87. be based on direct access to peripherals registers
  88. */
  89. /*#define USE_HAL_DRIVER */
  90. #endif /* USE_HAL_DRIVER */
  91. /**
  92. * @brief CMSIS Device version number
  93. */
  94. #define __STM32L0xx_CMSIS_VERSION_MAIN (0x01) /*!< [31:24] main version */
  95. #define __STM32L0xx_CMSIS_VERSION_SUB1 (0x09) /*!< [23:16] sub1 version */
  96. #define __STM32L0xx_CMSIS_VERSION_SUB2 (0x03) /*!< [15:8] sub2 version */
  97. #define __STM32L0xx_CMSIS_VERSION_RC (0x00) /*!< [7:0] release candidate */
  98. #define __STM32L0xx_CMSIS_VERSION ((__STM32L0xx_CMSIS_VERSION_MAIN << 24)\
  99. |(__STM32L0xx_CMSIS_VERSION_SUB1 << 16)\
  100. |(__STM32L0xx_CMSIS_VERSION_SUB2 << 8 )\
  101. |(__STM32L0xx_CMSIS_VERSION_RC))
  102. /**
  103. * @}
  104. */
  105. /** @addtogroup Device_Included
  106. * @{
  107. */
  108. #if defined(STM32L010xB)
  109. #include "stm32l010xb.h"
  110. #elif defined(STM32L010x8)
  111. #include "stm32l010x8.h"
  112. #elif defined(STM32L010x6)
  113. #include "stm32l010x6.h"
  114. #elif defined(STM32L010x4)
  115. #include "stm32l010x4.h"
  116. #elif defined(STM32L011xx)
  117. #include "stm32l011xx.h"
  118. #elif defined(STM32L021xx)
  119. #include "stm32l021xx.h"
  120. #elif defined(STM32L031xx)
  121. #include "stm32l031xx.h"
  122. #elif defined(STM32L041xx)
  123. #include "stm32l041xx.h"
  124. #elif defined(STM32L051xx)
  125. #include "stm32l051xx.h"
  126. #elif defined(STM32L052xx)
  127. #include "stm32l052xx.h"
  128. #elif defined(STM32L053xx)
  129. #include "stm32l053xx.h"
  130. #elif defined(STM32L062xx)
  131. #include "stm32l062xx.h"
  132. #elif defined(STM32L063xx)
  133. #include "stm32l063xx.h"
  134. #elif defined(STM32L071xx)
  135. #include "stm32l071xx.h"
  136. #elif defined(STM32L072xx)
  137. #include "stm32l072xx.h"
  138. #elif defined(STM32L073xx)
  139. #include "stm32l073xx.h"
  140. #elif defined(STM32L082xx)
  141. #include "stm32l082xx.h"
  142. #elif defined(STM32L083xx)
  143. #include "stm32l083xx.h"
  144. #elif defined(STM32L081xx)
  145. #include "stm32l081xx.h"
  146. #else
  147. #error "Please select first the target STM32L0xx device used in your application (in stm32l0xx.h file)"
  148. #endif
  149. /**
  150. * @}
  151. */
  152. /** @addtogroup Exported_types
  153. * @{
  154. */
  155. typedef enum
  156. {
  157. RESET = 0,
  158. SET = !RESET
  159. } FlagStatus, ITStatus;
  160. typedef enum
  161. {
  162. DISABLE = 0,
  163. ENABLE = !DISABLE
  164. } FunctionalState;
  165. #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
  166. typedef enum
  167. {
  168. SUCCESS = 0,
  169. ERROR = !SUCCESS
  170. } ErrorStatus;
  171. /**
  172. * @}
  173. */
  174. /** @addtogroup Exported_macro
  175. * @{
  176. */
  177. #define SET_BIT(REG, BIT) ((REG) |= (BIT))
  178. #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
  179. #define READ_BIT(REG, BIT) ((REG) & (BIT))
  180. #define CLEAR_REG(REG) ((REG) = (0x0))
  181. #define WRITE_REG(REG, VAL) ((REG) = (VAL))
  182. #define READ_REG(REG) ((REG))
  183. #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
  184. /* Use of interrupt control for register exclusive access */
  185. /* Atomic 32-bit register access macro to set one or several bits */
  186. #define ATOMIC_SET_BIT(REG, BIT) \
  187. do { \
  188. uint32_t primask; \
  189. primask = __get_PRIMASK(); \
  190. __set_PRIMASK(1); \
  191. SET_BIT((REG), (BIT)); \
  192. __set_PRIMASK(primask); \
  193. } while(0)
  194. /* Atomic 32-bit register access macro to clear one or several bits */
  195. #define ATOMIC_CLEAR_BIT(REG, BIT) \
  196. do { \
  197. uint32_t primask; \
  198. primask = __get_PRIMASK(); \
  199. __set_PRIMASK(1); \
  200. CLEAR_BIT((REG), (BIT)); \
  201. __set_PRIMASK(primask); \
  202. } while(0)
  203. /* Atomic 32-bit register access macro to clear and set one or several bits */
  204. #define ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \
  205. do { \
  206. uint32_t primask; \
  207. primask = __get_PRIMASK(); \
  208. __set_PRIMASK(1); \
  209. MODIFY_REG((REG), (CLEARMSK), (SETMASK)); \
  210. __set_PRIMASK(primask); \
  211. } while(0)
  212. /* Atomic 16-bit register access macro to set one or several bits */
  213. #define ATOMIC_SETH_BIT(REG, BIT) ATOMIC_SET_BIT(REG, BIT) \
  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. /* Atomic 16-bit register access macro to clear and set one or several bits */
  217. #define ATOMIC_MODIFYH_REG(REG, CLEARMSK, SETMASK) ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \
  218. /**
  219. * @}
  220. */
  221. #if defined (USE_HAL_DRIVER)
  222. #include "stm32l0xx_hal.h"
  223. #endif /* USE_HAL_DRIVER */
  224. #ifdef __cplusplus
  225. }
  226. #endif /* __cplusplus */
  227. #endif /* __STM32L0xx_H */
  228. /**
  229. * @}
  230. */
  231. /**
  232. * @}
  233. */