stm32l1xx.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. /**
  2. ******************************************************************************
  3. * @file stm32l1xx.h
  4. * @author MCD Application Team
  5. * @version 21-April-2017
  6. * @date V2.2.1
  7. * @brief CMSIS STM32L1xx Device Peripheral Access Layer Header File.
  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 STM32L1xx 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. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  22. *
  23. * Redistribution and use in source and binary forms, with or without modification,
  24. * are permitted provided that the following conditions are met:
  25. * 1. Redistributions of source code must retain the above copyright notice,
  26. * this list of conditions and the following disclaimer.
  27. * 2. Redistributions in binary form must reproduce the above copyright notice,
  28. * this list of conditions and the following disclaimer in the documentation
  29. * and/or other materials provided with the distribution.
  30. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  31. * may be used to endorse or promote products derived from this software
  32. * without specific prior written permission.
  33. *
  34. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  35. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  36. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  37. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  38. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  39. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  40. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  41. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  42. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  43. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  44. *
  45. ******************************************************************************
  46. */
  47. /** @addtogroup CMSIS
  48. * @{
  49. */
  50. /** @addtogroup stm32l1xx
  51. * @{
  52. */
  53. #ifndef __STM32L1XX_H
  54. #define __STM32L1XX_H
  55. #ifdef __cplusplus
  56. extern "C" {
  57. #endif /* __cplusplus */
  58. /** @addtogroup Library_configuration_section
  59. * @{
  60. */
  61. /**
  62. * @brief STM32 Family
  63. */
  64. #if !defined (STM32L1)
  65. #define STM32L1
  66. #endif /* STM32L1 */
  67. /* Uncomment the line below according to the target STM32L device used in your
  68. application
  69. */
  70. #if !defined (STM32L100xB) && !defined (STM32L100xBA) && !defined (STM32L100xC) && \
  71. !defined (STM32L151xB) && !defined (STM32L151xBA) && !defined (STM32L151xC) && !defined (STM32L151xCA) && !defined (STM32L151xD) && !defined (STM32L151xDX) && !defined (STM32L151xE) && \
  72. !defined (STM32L152xB) && !defined (STM32L152xBA) && !defined (STM32L152xC) && !defined (STM32L152xCA) && !defined (STM32L152xD) && !defined (STM32L152xDX) && !defined (STM32L152xE) && \
  73. !defined (STM32L162xC) && !defined (STM32L162xCA) && !defined (STM32L162xD) && !defined (STM32L162xDX) && !defined (STM32L162xE)
  74. /* #define STM32L100xB */ /*!< STM32L100C6, STM32L100R and STM32L100RB Devices */
  75. /* #define STM32L100xBA */ /*!< STM32L100C6-A, STM32L100R8-A and STM32L100RB-A Devices */
  76. /* #define STM32L100xC */ /*!< STM32L100RC Devices */
  77. /* #define STM32L151xB */ /*!< STM32L151C6, STM32L151R6, STM32L151C8, STM32L151R8, STM32L151V8, STM32L151CB, STM32L151RB and STM32L151VB */
  78. /* #define STM32L151xBA */ /*!< STM32L151C6-A, STM32L151R6-A, STM32L151C8-A, STM32L151R8-A, STM32L151V8-A, STM32L151CB-A, STM32L151RB-A and STM32L151VB-A */
  79. /* #define STM32L151xC */ /*!< STM32L151CC, STM32L151UC, STM32L151RC and STM32L151VC */
  80. /* #define STM32L151xCA */ /*!< STM32L151RC-A, STM32L151VC-A, STM32L151QC and STM32L151ZC */
  81. /* #define STM32L151xD */ /*!< STM32L151QD, STM32L151RD, STM32L151VD & STM32L151ZD */
  82. /* #define STM32L151xDX */ /*!< STM32L151VD-X Devices */
  83. /* #define STM32L151xE */ /*!< STM32L151QE, STM32L151RE, STM32L151VE and STM32L151ZE */
  84. /* #define STM32L152xB */ /*!< STM32L152C6, STM32L152R6, STM32L152C8, STM32L152R8, STM32L152V8, STM32L152CB, STM32L152RB and STM32L152VB */
  85. /* #define STM32L152xBA */ /*!< STM32L152C6-A, STM32L152R6-A, STM32L152C8-A, STM32L152R8-A, STM32L152V8-A, STM32L152CB-A, STM32L152RB-A and STM32L152VB-A */
  86. /* #define STM32L152xC */ /*!< STM32L152CC, STM32L152UC, STM32L152RC and STM32L152VC */
  87. /* #define STM32L152xCA */ /*!< STM32L152RC-A, STM32L152VC-A, STM32L152QC and STM32L152ZC */
  88. /* #define STM32L152xD */ /*!< STM32L152QD, STM32L152RD, STM32L152VD and STM32L152ZD */
  89. /* #define STM32L152xDX */ /*!< STM32L152VD-X Devices */
  90. /* #define STM32L152xE */ /*!< STM32L152QE, STM32L152RE, STM32L152VE and STM32L152ZE */
  91. /* #define STM32L162xC */ /*!< STM32L162RC and STM32L162VC */
  92. /* #define STM32L162xCA */ /*!< STM32L162RC-A, STM32L162VC-A, STM32L162QC and STM32L162ZC */
  93. /* #define STM32L162xD */ /*!< STM32L162QD, STM32L162RD, STM32L162VD and STM32L162ZD */
  94. /* #define STM32L162xDX */ /*!< STM32L162VD-X Devices */
  95. /* #define STM32L162xE */ /*!< STM32L162RE, STM32L162VE and STM32L162ZE */
  96. #endif
  97. /* Tip: To avoid modifying this file each time you need to switch between these
  98. devices, you can define the device in your toolchain compiler preprocessor.
  99. */
  100. #if !defined (USE_HAL_DRIVER)
  101. /**
  102. * @brief Comment the line below if you will not use the peripherals drivers.
  103. In this case, these drivers will not be included and the application code will
  104. be based on direct access to peripherals registers
  105. */
  106. /*#define USE_HAL_DRIVER */
  107. #endif /* USE_HAL_DRIVER */
  108. /**
  109. * @brief CMSIS Device version number
  110. */
  111. #define __STM32L1xx_CMSIS_VERSION_MAIN (0x02) /*!< [31:24] main version */
  112. #define __STM32L1xx_CMSIS_VERSION_SUB1 (0x02) /*!< [23:16] sub1 version */
  113. #define __STM32L1xx_CMSIS_VERSION_SUB2 (0x01) /*!< [15:8] sub2 version */
  114. #define __STM32L1xx_CMSIS_VERSION_RC (0x00) /*!< [7:0] release candidate */
  115. #define __STM32L1xx_CMSIS_VERSION ((__STM32L1xx_CMSIS_VERSION_MAIN << 24)\
  116. |(__STM32L1xx_CMSIS_VERSION_SUB1 << 16)\
  117. |(__STM32L1xx_CMSIS_VERSION_SUB2 << 8 )\
  118. |(__STM32L1xx_CMSIS_VERSION_RC))
  119. /**
  120. * @}
  121. */
  122. /** @addtogroup Device_Included
  123. * @{
  124. */
  125. #if defined(STM32L100xB)
  126. #include "stm32l100xb.h"
  127. #elif defined(STM32L100xBA)
  128. #include "stm32l100xba.h"
  129. #elif defined(STM32L100xC)
  130. #include "stm32l100xc.h"
  131. #elif defined(STM32L151xB)
  132. #include "stm32l151xb.h"
  133. #elif defined(STM32L151xBA)
  134. #include "stm32l151xba.h"
  135. #elif defined(STM32L151xC)
  136. #include "stm32l151xc.h"
  137. #elif defined(STM32L151xCA)
  138. #include "stm32l151xca.h"
  139. #elif defined(STM32L151xD)
  140. #include "stm32l151xd.h"
  141. #elif defined(STM32L151xDX)
  142. #include "stm32l151xdx.h"
  143. #elif defined(STM32L151xE)
  144. #include "stm32l151xe.h"
  145. #elif defined(STM32L152xB)
  146. #include "stm32l152xb.h"
  147. #elif defined(STM32L152xBA)
  148. #include "stm32l152xba.h"
  149. #elif defined(STM32L152xC)
  150. #include "stm32l152xc.h"
  151. #elif defined(STM32L152xCA)
  152. #include "stm32l152xca.h"
  153. #elif defined(STM32L152xD)
  154. #include "stm32l152xd.h"
  155. #elif defined(STM32L152xDX)
  156. #include "stm32l152xdx.h"
  157. #elif defined(STM32L152xE)
  158. #include "stm32l152xe.h"
  159. #elif defined(STM32L162xC)
  160. #include "stm32l162xc.h"
  161. #elif defined(STM32L162xCA)
  162. #include "stm32l162xca.h"
  163. #elif defined(STM32L162xD)
  164. #include "stm32l162xd.h"
  165. #elif defined(STM32L162xDX)
  166. #include "stm32l162xdx.h"
  167. #elif defined(STM32L162xE)
  168. #include "stm32l162xe.h"
  169. #else
  170. #error "Please select first the target STM32L1xx device used in your application (in stm32l1xx.h file)"
  171. #endif
  172. /**
  173. * @}
  174. */
  175. /** @addtogroup Exported_types
  176. * @{
  177. */
  178. typedef enum
  179. {
  180. RESET = 0,
  181. SET = !RESET
  182. } FlagStatus, ITStatus;
  183. typedef enum
  184. {
  185. DISABLE = 0,
  186. ENABLE = !DISABLE
  187. } FunctionalState;
  188. #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
  189. typedef enum
  190. {
  191. ERROR = 0,
  192. SUCCESS = !ERROR
  193. } ErrorStatus;
  194. /**
  195. * @}
  196. */
  197. /** @addtogroup Exported_macros
  198. * @{
  199. */
  200. #define SET_BIT(REG, BIT) ((REG) |= (BIT))
  201. #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
  202. #define READ_BIT(REG, BIT) ((REG) & (BIT))
  203. #define CLEAR_REG(REG) ((REG) = (0x0))
  204. #define WRITE_REG(REG, VAL) ((REG) = (VAL))
  205. #define READ_REG(REG) ((REG))
  206. #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
  207. #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL)))
  208. /**
  209. * @}
  210. */
  211. #if defined (USE_HAL_DRIVER)
  212. #include "stm32l1xx_hal.h"
  213. #endif /* USE_HAL_DRIVER */
  214. #ifdef __cplusplus
  215. }
  216. #endif /* __cplusplus */
  217. #endif /* __STM32L1xx_H */
  218. /**
  219. * @}
  220. */
  221. /**
  222. * @}
  223. */
  224. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/