stm32f3xx.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. /**
  2. ******************************************************************************
  3. * @file stm32f3xx.h
  4. * @author MCD Application Team
  5. * @brief CMSIS STM32F3xx 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 STM32F3xx 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>&copy; Copyright (c) 2016 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. /** @addtogroup CMSIS
  30. * @{
  31. */
  32. /** @addtogroup stm32f3xx
  33. * @{
  34. */
  35. #ifndef __STM32F3xx_H
  36. #define __STM32F3xx_H
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif /* __cplusplus */
  40. /** @addtogroup Library_configuration_section
  41. * @{
  42. */
  43. /**
  44. * @brief STM32 Family
  45. */
  46. #if !defined (STM32F3)
  47. #define STM32F3
  48. #endif /* STM32F3 */
  49. /* Uncomment the line below according to the target STM32 device used in your
  50. application
  51. */
  52. #if !defined (STM32F301x8) && !defined (STM32F302x8) && !defined (STM32F318xx) && \
  53. !defined (STM32F302xC) && !defined (STM32F303xC) && !defined (STM32F358xx) && \
  54. !defined (STM32F303x8) && !defined (STM32F334x8) && !defined (STM32F328xx) && \
  55. !defined (STM32F302xE) && !defined (STM32F303xE) && !defined (STM32F398xx) && \
  56. !defined (STM32F373xC) && !defined (STM32F378xx)
  57. /* #define STM32F301x8 */ /*!< STM32F301K6, STM32F301K8, STM32F301C6, STM32F301C8,
  58. STM32F301R6 and STM32F301R8 Devices */
  59. /* #define STM32F302x8 */ /*!< STM32F302K6, STM32F302K8, STM32F302C6, STM32F302C8,
  60. STM32F302R6 and STM32F302R8 Devices */
  61. /* #define STM32F302xC */ /*!< STM32F302CB, STM32F302CC, STM32F302RB, STM32F302RC,
  62. STM32F302VB and STM32F302VC Devices */
  63. /* #define STM32F302xE */ /*!< STM32F302RE, STM32F302VE, STM32F302ZE, STM32F302RD,
  64. STM32F302VD and STM32F302ZD Devices */
  65. /* #define STM32F303x8 */ /*!< STM32F303K6, STM32F303K8, STM32F303C6, STM32F303C8,
  66. STM32F303R6 and STM32F303R8 Devices */
  67. /* #define STM32F303xC */ /*!< STM32F303CB, STM32F303CC, STM32F303RB, STM32F303RC,
  68. STM32F303VB and STM32F303VC Devices */
  69. /* #define STM32F303xE */ /*!< STM32F303RE, STM32F303VE, STM32F303ZE, STM32F303RD,
  70. STM32F303VD and STM32F303ZD Devices */
  71. /* #define STM32F373xC */ /*!< STM32F373C8, STM32F373CB, STM32F373CC,
  72. STM32F373R8, STM32F373RB, STM32F373RC,
  73. STM32F373V8, STM32F373VB and STM32F373VC Devices */
  74. /* #define STM32F334x8 */ /*!< STM32F334K4, STM32F334K6, STM32F334K8,
  75. STM32F334C4, STM32F334C6, STM32F334C8,
  76. STM32F334R4, STM32F334R6 and STM32F334R8 Devices */
  77. /* #define STM32F318xx */ /*!< STM32F318K8, STM32F318C8: STM32F301x8 with regulator off: STM32F318xx Devices */
  78. /* #define STM32F328xx */ /*!< STM32F328C8, STM32F328R8: STM32F334x8 with regulator off: STM32F328xx Devices */
  79. /* #define STM32F358xx */ /*!< STM32F358CC, STM32F358RC, STM32F358VC: STM32F303xC with regulator off: STM32F358xx Devices */
  80. /* #define STM32F378xx */ /*!< STM32F378CC, STM32F378RC, STM32F378VC: STM32F373xC with regulator off: STM32F378xx Devices */
  81. /* #define STM32F398xx */ /*!< STM32F398VE: STM32F303xE with regulator off: STM32F398xx Devices */
  82. #endif
  83. /* Tip: To avoid modifying this file each time you need to switch between these
  84. devices, you can define the device in your toolchain compiler preprocessor.
  85. */
  86. #if !defined (USE_HAL_DRIVER)
  87. /**
  88. * @brief Comment the line below if you will not use the peripherals drivers.
  89. In this case, these drivers will not be included and the application code will
  90. be based on direct access to peripherals registers
  91. */
  92. /*#define USE_HAL_DRIVER */
  93. #endif /* USE_HAL_DRIVER */
  94. /**
  95. * @brief CMSIS Device version number V2.3.6
  96. */
  97. #define __STM32F3_CMSIS_VERSION_MAIN (0x02) /*!< [31:24] main version */
  98. #define __STM32F3_CMSIS_VERSION_SUB1 (0x03) /*!< [23:16] sub1 version */
  99. #define __STM32F3_CMSIS_VERSION_SUB2 (0x06) /*!< [15:8] sub2 version */
  100. #define __STM32F3_CMSIS_VERSION_RC (0x00) /*!< [7:0] release candidate */
  101. #define __STM32F3_CMSIS_VERSION ((__STM32F3_CMSIS_VERSION_MAIN << 24)\
  102. |(__STM32F3_CMSIS_VERSION_SUB1 << 16)\
  103. |(__STM32F3_CMSIS_VERSION_SUB2 << 8 )\
  104. |(__STM32F3_CMSIS_VERSION_RC))
  105. /**
  106. * @}
  107. */
  108. /** @addtogroup Device_Included
  109. * @{
  110. */
  111. #if defined(STM32F301x8)
  112. #include "stm32f301x8.h"
  113. #elif defined(STM32F302x8)
  114. #include "stm32f302x8.h"
  115. #elif defined(STM32F302xC)
  116. #include "stm32f302xc.h"
  117. #elif defined(STM32F302xE)
  118. #include "stm32f302xe.h"
  119. #elif defined(STM32F303x8)
  120. #include "stm32f303x8.h"
  121. #elif defined(STM32F303xC)
  122. #include "stm32f303xc.h"
  123. #elif defined(STM32F303xE)
  124. #include "stm32f303xe.h"
  125. #elif defined(STM32F373xC)
  126. #include "stm32f373xc.h"
  127. #elif defined(STM32F334x8)
  128. #include "stm32f334x8.h"
  129. #elif defined(STM32F318xx)
  130. #include "stm32f318xx.h"
  131. #elif defined(STM32F328xx)
  132. #include "stm32f328xx.h"
  133. #elif defined(STM32F358xx)
  134. #include "stm32f358xx.h"
  135. #elif defined(STM32F378xx)
  136. #include "stm32f378xx.h"
  137. #elif defined(STM32F398xx)
  138. #include "stm32f398xx.h"
  139. #else
  140. #error "Please select first the target STM32F3xx device used in your application (in stm32f3xx.h file)"
  141. #endif
  142. /**
  143. * @}
  144. */
  145. /** @addtogroup Exported_types
  146. * @{
  147. */
  148. typedef enum
  149. {
  150. RESET = 0U,
  151. SET = !RESET
  152. } FlagStatus, ITStatus;
  153. typedef enum
  154. {
  155. DISABLE = 0U,
  156. ENABLE = !DISABLE
  157. } FunctionalState;
  158. #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
  159. typedef enum
  160. {
  161. SUCCESS = 0U,
  162. ERROR = !SUCCESS
  163. } ErrorStatus;
  164. /**
  165. * @}
  166. */
  167. /** @addtogroup Exported_macros
  168. * @{
  169. */
  170. #define SET_BIT(REG, BIT) ((REG) |= (BIT))
  171. #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
  172. #define READ_BIT(REG, BIT) ((REG) & (BIT))
  173. #define CLEAR_REG(REG) ((REG) = (0x0))
  174. #define WRITE_REG(REG, VAL) ((REG) = (VAL))
  175. #define READ_REG(REG) ((REG))
  176. #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
  177. #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL)))
  178. /* Use of CMSIS compiler intrinsics for register exclusive access */
  179. /* Atomic 32-bit register access macro to set one or several bits */
  180. #define ATOMIC_SET_BIT(REG, BIT) \
  181. do { \
  182. uint32_t val; \
  183. do { \
  184. val = __LDREXW((__IO uint32_t *)&(REG)) | (BIT); \
  185. } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
  186. } while(0)
  187. /* Atomic 32-bit register access macro to clear one or several bits */
  188. #define ATOMIC_CLEAR_BIT(REG, BIT) \
  189. do { \
  190. uint32_t val; \
  191. do { \
  192. val = __LDREXW((__IO uint32_t *)&(REG)) & ~(BIT); \
  193. } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
  194. } while(0)
  195. /* Atomic 32-bit register access macro to clear and set one or several bits */
  196. #define ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \
  197. do { \
  198. uint32_t val; \
  199. do { \
  200. val = (__LDREXW((__IO uint32_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \
  201. } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
  202. } while(0)
  203. /* Atomic 16-bit register access macro to set one or several bits */
  204. #define ATOMIC_SETH_BIT(REG, BIT) \
  205. do { \
  206. uint16_t val; \
  207. do { \
  208. val = __LDREXH((__IO uint16_t *)&(REG)) | (BIT); \
  209. } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
  210. } while(0)
  211. /* Atomic 16-bit register access macro to clear one or several bits */
  212. #define ATOMIC_CLEARH_BIT(REG, BIT) \
  213. do { \
  214. uint16_t val; \
  215. do { \
  216. val = __LDREXH((__IO uint16_t *)&(REG)) & ~(BIT); \
  217. } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
  218. } while(0)
  219. /* Atomic 16-bit register access macro to clear and set one or several bits */
  220. #define ATOMIC_MODIFYH_REG(REG, CLEARMSK, SETMASK) \
  221. do { \
  222. uint16_t val; \
  223. do { \
  224. val = (__LDREXH((__IO uint16_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \
  225. } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
  226. } while(0)
  227. /**
  228. * @}
  229. */
  230. #if defined (USE_HAL_DRIVER)
  231. #include "stm32f3xx_hal.h"
  232. #endif /* USE_HAL_DRIVER */
  233. #ifdef __cplusplus
  234. }
  235. #endif /* __cplusplus */
  236. #endif /* __STM32F3xx_H */
  237. /**
  238. * @}
  239. */
  240. /**
  241. * @}
  242. */
  243. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/