stm32h5xx.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. /**
  2. ******************************************************************************
  3. * @file stm32h5xx.h
  4. * @author MCD Application Team
  5. * @brief CMSIS STM32H5xx 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 STM32H5xx 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) 2023 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 stm32h5xx
  32. * @{
  33. */
  34. #ifndef STM32H5xx_H
  35. #define STM32H5xx_H
  36. #include "math.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 (STM32H5)
  47. #define STM32H5
  48. #endif /* STM32H5 */
  49. /* Uncomment the line below according to the target STM32H5 device used in your
  50. application
  51. */
  52. #if !defined (STM32H573xx) && !defined (STM32H563xx) \
  53. && !defined (STM32H562xx) && !defined (STM32H503xx) \
  54. && !defined (STM32H533xx) && !defined (STM32H523xx)
  55. /* #define STM32H573xx */ /*!< STM32H573xx Devices */
  56. /* #define STM32H563xx */ /*!< STM32H563xx Devices */
  57. /* #define STM32H562xx */ /*!< STM32H562xx Devices */
  58. /* #define STM32H503xx */ /*!< STM32H503xx Devices */
  59. /* #define STM32H533xx */ /*!< STM32H533xx Devices */
  60. /* #define STM32H523xx */ /*!< STM32H523xx Devices */
  61. #endif
  62. /* Tip: To avoid modifying this file each time you need to switch between these
  63. devices, you can define the device in your toolchain compiler preprocessor.
  64. */
  65. #if !defined (USE_HAL_DRIVER)
  66. /**
  67. * @brief Comment the line below if you will not use the peripherals drivers.
  68. In this case, these drivers will not be included and the application code will
  69. be based on direct access to peripherals registers
  70. */
  71. /*#define USE_HAL_DRIVER */
  72. #endif /* USE_HAL_DRIVER */
  73. /**
  74. * @brief CMSIS Device version number 1.4.0
  75. */
  76. #define __STM32H5_CMSIS_VERSION_MAIN (0x01) /*!< [31:24] main version */
  77. #define __STM32H5_CMSIS_VERSION_SUB1 (0x04) /*!< [23:16] sub1 version */
  78. #define __STM32H5_CMSIS_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
  79. #define __STM32H5_CMSIS_VERSION_RC (0x00) /*!< [7:0] release candidate */
  80. #define __STM32H5_CMSIS_VERSION ((__STM32H5_CMSIS_VERSION_MAIN << 24U)\
  81. |(__STM32H5_CMSIS_VERSION_SUB1 << 16U)\
  82. |(__STM32H5_CMSIS_VERSION_SUB2 << 8U )\
  83. |(__STM32H5_CMSIS_VERSION_RC))
  84. /**
  85. * @}
  86. */
  87. /** @addtogroup Device_Included
  88. * @{
  89. */
  90. #if defined(STM32H5F5xx)
  91. #include "stm32h5f5xx.h"
  92. #elif defined(STM32H5F4xx)
  93. #include "stm32h5f4xx.h"
  94. #elif defined(STM32H5E5xx)
  95. #include "stm32h5e5xx.h"
  96. #elif defined(STM32H5E4xx)
  97. #include "stm32h5e4xx.h"
  98. #elif defined(STM32H573xx)
  99. #include "stm32h573xx.h"
  100. #elif defined(STM32H563xx)
  101. #include "stm32h563xx.h"
  102. #elif defined(STM32H562xx)
  103. #include "stm32h562xx.h"
  104. #elif defined(STM32H503xx)
  105. #include "stm32h503xx.h"
  106. #elif defined(STM32H523xx)
  107. #include "stm32h523xx.h"
  108. #elif defined(STM32H533xx)
  109. #include "stm32h533xx.h"
  110. #else
  111. #error "Please select first the target STM32H5xx device used in your application (in stm32h5xx.h file)"
  112. #endif
  113. /**
  114. * @}
  115. */
  116. /** @addtogroup Exported_types
  117. * @{
  118. */
  119. typedef enum
  120. {
  121. RESET = 0,
  122. SET = !RESET
  123. } FlagStatus, ITStatus;
  124. typedef enum
  125. {
  126. DISABLE = 0,
  127. ENABLE = !DISABLE
  128. } FunctionalState;
  129. #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
  130. typedef enum
  131. {
  132. SUCCESS = 0,
  133. ERROR = !SUCCESS
  134. } ErrorStatus;
  135. /**
  136. * @}
  137. */
  138. /** @addtogroup Exported_macros
  139. * @{
  140. */
  141. #define SET_BIT(REG, BIT) ((REG) |= (BIT))
  142. #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
  143. #define READ_BIT(REG, BIT) ((REG) & (BIT))
  144. #define CLEAR_REG(REG) ((REG) = (0x0))
  145. #define WRITE_REG(REG, VAL) ((REG) = (VAL))
  146. #define READ_REG(REG) ((REG))
  147. #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
  148. /* Use of CMSIS compiler intrinsics for register exclusive access */
  149. /* Atomic 32-bit register access macro to set one or several bits */
  150. #define ATOMIC_SET_BIT(REG, BIT) \
  151. do { \
  152. uint32_t val; \
  153. do { \
  154. val = __LDREXW((__IO uint32_t *)&(REG)) | (BIT); \
  155. } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
  156. } while(0)
  157. /* Atomic 32-bit register access macro to clear one or several bits */
  158. #define ATOMIC_CLEAR_BIT(REG, BIT) \
  159. do { \
  160. uint32_t val; \
  161. do { \
  162. val = __LDREXW((__IO uint32_t *)&(REG)) & ~(BIT); \
  163. } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
  164. } while(0)
  165. /* Atomic 32-bit register access macro to clear and set one or several bits */
  166. #define ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \
  167. do { \
  168. uint32_t val; \
  169. do { \
  170. val = (__LDREXW((__IO uint32_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \
  171. } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
  172. } while(0)
  173. /* Atomic 16-bit register access macro to set one or several bits */
  174. #define ATOMIC_SETH_BIT(REG, BIT) \
  175. do { \
  176. uint16_t val; \
  177. do { \
  178. val = __LDREXH((__IO uint16_t *)&(REG)) | (BIT); \
  179. } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
  180. } while(0)
  181. /* Atomic 16-bit register access macro to clear one or several bits */
  182. #define ATOMIC_CLEARH_BIT(REG, BIT) \
  183. do { \
  184. uint16_t val; \
  185. do { \
  186. val = __LDREXH((__IO uint16_t *)&(REG)) & ~(BIT); \
  187. } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
  188. } while(0)
  189. /* Atomic 16-bit register access macro to clear and set one or several bits */
  190. #define ATOMIC_MODIFYH_REG(REG, CLEARMSK, SETMASK) \
  191. do { \
  192. uint16_t val; \
  193. do { \
  194. val = (__LDREXH((__IO uint16_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \
  195. } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
  196. } while(0)
  197. #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL)))
  198. /**
  199. * @}
  200. */
  201. #if defined (USE_HAL_DRIVER)
  202. #include "stm32h5xx_hal.h"
  203. #endif /* USE_HAL_DRIVER */
  204. #ifdef __cplusplus
  205. }
  206. #endif /* __cplusplus */
  207. #endif /* STM32H5xx_H */
  208. /**
  209. * @}
  210. */
  211. /**
  212. * @}
  213. */