stm32f3xx.h 10 KB

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