stm32f3xx.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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</center></h2>
  20. *
  21. * Redistribution and use in source and binary forms, with or without modification,
  22. * are permitted provided that the following conditions are met:
  23. * 1. Redistributions of source code must retain the above copyright notice,
  24. * this list of conditions and the following disclaimer.
  25. * 2. Redistributions in binary form must reproduce the above copyright notice,
  26. * this list of conditions and the following disclaimer in the documentation
  27. * and/or other materials provided with the distribution.
  28. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  29. * may be used to endorse or promote products derived from this software
  30. * without specific prior written permission.
  31. *
  32. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  33. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  34. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  35. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  36. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  37. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  38. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  39. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  40. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  41. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  42. *
  43. ******************************************************************************
  44. */
  45. /** @addtogroup CMSIS
  46. * @{
  47. */
  48. /** @addtogroup stm32f3xx
  49. * @{
  50. */
  51. #ifndef __STM32F3xx_H
  52. #define __STM32F3xx_H
  53. #ifdef __cplusplus
  54. extern "C" {
  55. #endif /* __cplusplus */
  56. /** @addtogroup Library_configuration_section
  57. * @{
  58. */
  59. /**
  60. * @brief STM32 Family
  61. */
  62. #if !defined (STM32F3)
  63. #define STM32F3
  64. #endif /* STM32F3 */
  65. /* Uncomment the line below according to the target STM32 device used in your
  66. application
  67. */
  68. #if !defined (STM32F301x8) && !defined (STM32F302x8) && !defined (STM32F318xx) && \
  69. !defined (STM32F302xC) && !defined (STM32F303xC) && !defined (STM32F358xx) && \
  70. !defined (STM32F303x8) && !defined (STM32F334x8) && !defined (STM32F328xx) && \
  71. !defined (STM32F302xE) && !defined (STM32F303xE) && !defined (STM32F398xx) && \
  72. !defined (STM32F373xC) && !defined (STM32F378xx)
  73. /* #define STM32F301x8 */ /*!< STM32F301K6, STM32F301K8, STM32F301C6, STM32F301C8,
  74. STM32F301R6 and STM32F301R8 Devices */
  75. /* #define STM32F302x8 */ /*!< STM32F302K6, STM32F302K8, STM32F302C6, STM32F302C8,
  76. STM32F302R6 and STM32F302R8 Devices */
  77. /* #define STM32F302xC */ /*!< STM32F302CB, STM32F302CC, STM32F302RB, STM32F302RC,
  78. STM32F302VB and STM32F302VC Devices */
  79. /* #define STM32F302xE */ /*!< STM32F302RE, STM32F302VE, STM32F302ZE, STM32F302RD,
  80. STM32F302VD and STM32F302ZD Devices */
  81. /* #define STM32F303x8 */ /*!< STM32F303K6, STM32F303K8, STM32F303C6, STM32F303C8,
  82. STM32F303R6 and STM32F303R8 Devices */
  83. /* #define STM32F303xC */ /*!< STM32F303CB, STM32F303CC, STM32F303RB, STM32F303RC,
  84. STM32F303VB and STM32F303VC Devices */
  85. /* #define STM32F303xE */ /*!< STM32F303RE, STM32F303VE, STM32F303ZE, STM32F303RD,
  86. STM32F303VD and STM32F303ZD Devices */
  87. /* #define STM32F373xC */ /*!< STM32F373C8, STM32F373CB, STM32F373CC,
  88. STM32F373R8, STM32F373RB, STM32F373RC,
  89. STM32F373V8, STM32F373VB and STM32F373VC Devices */
  90. /* #define STM32F334x8 */ /*!< STM32F334K4, STM32F334K6, STM32F334K8,
  91. STM32F334C4, STM32F334C6, STM32F334C8,
  92. STM32F334R4, STM32F334R6 and STM32F334R8 Devices */
  93. /* #define STM32F318xx */ /*!< STM32F318K8, STM32F318C8: STM32F301x8 with regulator off: STM32F318xx Devices */
  94. /* #define STM32F328xx */ /*!< STM32F328C8, STM32F328R8: STM32F334x8 with regulator off: STM32F328xx Devices */
  95. /* #define STM32F358xx */ /*!< STM32F358CC, STM32F358RC, STM32F358VC: STM32F303xC with regulator off: STM32F358xx Devices */
  96. /* #define STM32F378xx */ /*!< STM32F378CC, STM32F378RC, STM32F378VC: STM32F373xC with regulator off: STM32F378xx Devices */
  97. /* #define STM32F398xx */ /*!< STM32F398VE: STM32F303xE with regulator off: STM32F398xx Devices */
  98. #endif
  99. /* Tip: To avoid modifying this file each time you need to switch between these
  100. devices, you can define the device in your toolchain compiler preprocessor.
  101. */
  102. #if !defined (USE_HAL_DRIVER)
  103. /**
  104. * @brief Comment the line below if you will not use the peripherals drivers.
  105. In this case, these drivers will not be included and the application code will
  106. be based on direct access to peripherals registers
  107. */
  108. /*#define USE_HAL_DRIVER */
  109. #endif /* USE_HAL_DRIVER */
  110. /**
  111. * @brief CMSIS Device version number V2.3.2
  112. */
  113. #define __STM32F3_CMSIS_VERSION_MAIN (0x02) /*!< [31:24] main version */
  114. #define __STM32F3_CMSIS_VERSION_SUB1 (0x03) /*!< [23:16] sub1 version */
  115. #define __STM32F3_CMSIS_VERSION_SUB2 (0x02) /*!< [15:8] sub2 version */
  116. #define __STM32F3_CMSIS_VERSION_RC (0x00) /*!< [7:0] release candidate */
  117. #define __STM32F3_CMSIS_VERSION ((__STM32F3_CMSIS_VERSION_MAIN << 24)\
  118. |(__STM32F3_CMSIS_VERSION_SUB1 << 16)\
  119. |(__STM32F3_CMSIS_VERSION_SUB2 << 8 )\
  120. |(__STM32F3_CMSIS_VERSION_RC))
  121. /**
  122. * @}
  123. */
  124. /** @addtogroup Device_Included
  125. * @{
  126. */
  127. #if defined(STM32F301x8)
  128. #include "stm32f301x8.h"
  129. #elif defined(STM32F302x8)
  130. #include "stm32f302x8.h"
  131. #elif defined(STM32F302xC)
  132. #include "stm32f302xc.h"
  133. #elif defined(STM32F302xE)
  134. #include "stm32f302xe.h"
  135. #elif defined(STM32F303x8)
  136. #include "stm32f303x8.h"
  137. #elif defined(STM32F303xC)
  138. #include "stm32f303xc.h"
  139. #elif defined(STM32F303xE)
  140. #include "stm32f303xe.h"
  141. #elif defined(STM32F373xC)
  142. #include "stm32f373xc.h"
  143. #elif defined(STM32F334x8)
  144. #include "stm32f334x8.h"
  145. #elif defined(STM32F318xx)
  146. #include "stm32f318xx.h"
  147. #elif defined(STM32F328xx)
  148. #include "stm32f328xx.h"
  149. #elif defined(STM32F358xx)
  150. #include "stm32f358xx.h"
  151. #elif defined(STM32F378xx)
  152. #include "stm32f378xx.h"
  153. #elif defined(STM32F398xx)
  154. #include "stm32f398xx.h"
  155. #else
  156. #error "Please select first the target STM32F3xx device used in your application (in stm32f3xx.h file)"
  157. #endif
  158. /**
  159. * @}
  160. */
  161. /** @addtogroup Exported_types
  162. * @{
  163. */
  164. typedef enum
  165. {
  166. RESET = 0,
  167. SET = !RESET
  168. } FlagStatus, ITStatus;
  169. typedef enum
  170. {
  171. DISABLE = 0,
  172. ENABLE = !DISABLE
  173. } FunctionalState;
  174. #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
  175. typedef enum
  176. {
  177. ERROR = 0,
  178. SUCCESS = !ERROR
  179. } ErrorStatus;
  180. /**
  181. * @}
  182. */
  183. /** @addtogroup Exported_macros
  184. * @{
  185. */
  186. #define SET_BIT(REG, BIT) ((REG) |= (BIT))
  187. #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
  188. #define READ_BIT(REG, BIT) ((REG) & (BIT))
  189. #define CLEAR_REG(REG) ((REG) = (0x0))
  190. #define WRITE_REG(REG, VAL) ((REG) = (VAL))
  191. #define READ_REG(REG) ((REG))
  192. #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
  193. #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL)))
  194. #if defined (USE_HAL_DRIVER)
  195. #include "stm32f3xx_hal.h"
  196. #endif /* USE_HAL_DRIVER */
  197. /**
  198. * @}
  199. */
  200. #ifdef __cplusplus
  201. }
  202. #endif /* __cplusplus */
  203. #endif /* __STM32F3xx_H */
  204. /**
  205. * @}
  206. */
  207. /**
  208. * @}
  209. */
  210. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/