stm32g0xx.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /**
  2. ******************************************************************************
  3. * @file stm32g0xx.h
  4. * @author MCD Application Team
  5. * @brief CMSIS STM32G0xx 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 STM32G0xx device used in the target application
  11. * - To use or not the peripherals drivers in application code(i.e.
  12. * code will be based on direct access to peripherals registers
  13. * rather than drivers API), this option is controlled by
  14. * "#define USE_HAL_DRIVER"
  15. *
  16. ******************************************************************************
  17. * @attention
  18. *
  19. * Copyright (c) 2018-2021 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 stm32g0xx
  32. * @{
  33. */
  34. #ifndef STM32G0xx_H
  35. #define STM32G0xx_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 (STM32G0)
  46. #define STM32G0
  47. #endif /* STM32G0 */
  48. /* Uncomment the line below according to the target STM32G0 device used in your
  49. application
  50. */
  51. #if !defined (STM32G071xx) && !defined (STM32G081xx) && !defined (STM32G070xx) \
  52. && !defined (STM32G030xx) && !defined (STM32G031xx) && !defined (STM32G041xx) \
  53. && !defined (STM32G0B0xx) && !defined (STM32G0B1xx) && !defined (STM32G0C1xx) \
  54. && !defined (STM32G050xx) && !defined (STM32G051xx) && !defined (STM32G061xx)
  55. /* #define STM32G0B0xx */ /*!< STM32G0B0xx Devices */
  56. /* #define STM32G0B1xx */ /*!< STM32G0B1xx Devices */
  57. /* #define STM32G0C1xx */ /*!< STM32G0C1xx Devices */
  58. /* #define STM32G070xx */ /*!< STM32G070xx Devices */
  59. /* #define STM32G071xx */ /*!< STM32G071xx Devices */
  60. /* #define STM32G081xx */ /*!< STM32G081xx Devices */
  61. /* #define STM32G050xx */ /*!< STM32G050xx Devices */
  62. /* #define STM32G051xx */ /*!< STM32G051xx Devices */
  63. /* #define STM32G061xx */ /*!< STM32G061xx Devices */
  64. /* #define STM32G030xx */ /*!< STM32G030xx Devices */
  65. /* #define STM32G031xx */ /*!< STM32G031xx Devices */
  66. /* #define STM32G041xx */ /*!< STM32G041xx Devices */
  67. #endif
  68. /* Tip: To avoid modifying this file each time you need to switch between these
  69. devices, you can define the device in your toolchain compiler preprocessor.
  70. */
  71. #if !defined (USE_HAL_DRIVER)
  72. /**
  73. * @brief Comment the line below if you will not use the peripherals drivers.
  74. In this case, these drivers will not be included and the application code will
  75. be based on direct access to peripherals registers
  76. */
  77. /*#define USE_HAL_DRIVER */
  78. #endif /* USE_HAL_DRIVER */
  79. /**
  80. * @brief CMSIS Device version number $VERSION$
  81. */
  82. #define __STM32G0_CMSIS_VERSION_MAIN (0x01U) /*!< [31:24] main version */
  83. #define __STM32G0_CMSIS_VERSION_SUB1 (0x04U) /*!< [23:16] sub1 version */
  84. #define __STM32G0_CMSIS_VERSION_SUB2 (0x01U) /*!< [15:8] sub2 version */
  85. #define __STM32G0_CMSIS_VERSION_RC (0x00U) /*!< [7:0] release candidate */
  86. #define __STM32G0_CMSIS_VERSION ((__STM32G0_CMSIS_VERSION_MAIN << 24)\
  87. |(__STM32G0_CMSIS_VERSION_SUB1 << 16)\
  88. |(__STM32G0_CMSIS_VERSION_SUB2 << 8 )\
  89. |(__STM32G0_CMSIS_VERSION_RC))
  90. /**
  91. * @}
  92. */
  93. /** @addtogroup Device_Included
  94. * @{
  95. */
  96. #if defined(STM32G0B1xx)
  97. #include "stm32g0b1xx.h"
  98. #elif defined(STM32G0C1xx)
  99. #include "stm32g0c1xx.h"
  100. #elif defined(STM32G0B0xx)
  101. #include "stm32g0b0xx.h"
  102. #elif defined(STM32G071xx)
  103. #include "stm32g071xx.h"
  104. #elif defined(STM32G081xx)
  105. #include "stm32g081xx.h"
  106. #elif defined(STM32G070xx)
  107. #include "stm32g070xx.h"
  108. #elif defined(STM32G031xx)
  109. #include "stm32g031xx.h"
  110. #elif defined(STM32G041xx)
  111. #include "stm32g041xx.h"
  112. #elif defined(STM32G030xx)
  113. #include "stm32g030xx.h"
  114. #elif defined(STM32G051xx)
  115. #include "stm32g051xx.h"
  116. #elif defined(STM32G061xx)
  117. #include "stm32g061xx.h"
  118. #elif defined(STM32G050xx)
  119. #include "stm32g050xx.h"
  120. #else
  121. #error "Please select first the target STM32G0xx device used in your application (in stm32g0xx.h file)"
  122. #endif
  123. /**
  124. * @}
  125. */
  126. /** @addtogroup Exported_types
  127. * @{
  128. */
  129. typedef enum
  130. {
  131. RESET = 0,
  132. SET = !RESET
  133. } FlagStatus, ITStatus;
  134. typedef enum
  135. {
  136. DISABLE = 0,
  137. ENABLE = !DISABLE
  138. } FunctionalState;
  139. #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
  140. typedef enum
  141. {
  142. SUCCESS = 0,
  143. ERROR = !SUCCESS
  144. } ErrorStatus;
  145. /**
  146. * @}
  147. */
  148. /** @addtogroup Exported_macros
  149. * @{
  150. */
  151. #define SET_BIT(REG, BIT) ((REG) |= (BIT))
  152. #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
  153. #define READ_BIT(REG, BIT) ((REG) & (BIT))
  154. #define CLEAR_REG(REG) ((REG) = (0x0))
  155. #define WRITE_REG(REG, VAL) ((REG) = (VAL))
  156. #define READ_REG(REG) ((REG))
  157. #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
  158. /* Use of interrupt control for register exclusive access */
  159. /* Atomic 32-bit register access macro to set one or several bits */
  160. #define ATOMIC_SET_BIT(REG, BIT) \
  161. do { \
  162. uint32_t primask; \
  163. primask = __get_PRIMASK(); \
  164. __set_PRIMASK(1); \
  165. SET_BIT((REG), (BIT)); \
  166. __set_PRIMASK(primask); \
  167. } while(0)
  168. /* Atomic 32-bit register access macro to clear one or several bits */
  169. #define ATOMIC_CLEAR_BIT(REG, BIT) \
  170. do { \
  171. uint32_t primask; \
  172. primask = __get_PRIMASK(); \
  173. __set_PRIMASK(1); \
  174. CLEAR_BIT((REG), (BIT)); \
  175. __set_PRIMASK(primask); \
  176. } while(0)
  177. /* Atomic 32-bit register access macro to clear and set one or several bits */
  178. #define ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \
  179. do { \
  180. uint32_t primask; \
  181. primask = __get_PRIMASK(); \
  182. __set_PRIMASK(1); \
  183. MODIFY_REG((REG), (CLEARMSK), (SETMASK)); \
  184. __set_PRIMASK(primask); \
  185. } while(0)
  186. /* Atomic 16-bit register access macro to set one or several bits */
  187. #define ATOMIC_SETH_BIT(REG, BIT) ATOMIC_SET_BIT(REG, BIT) \
  188. /* Atomic 16-bit register access macro to clear one or several bits */
  189. #define ATOMIC_CLEARH_BIT(REG, BIT) ATOMIC_CLEAR_BIT(REG, BIT) \
  190. /* Atomic 16-bit register access macro to clear and set one or several bits */
  191. #define ATOMIC_MODIFYH_REG(REG, CLEARMSK, SETMASK) ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \
  192. /*#define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL)))*/
  193. /**
  194. * @}
  195. */
  196. #if defined (USE_HAL_DRIVER)
  197. #include "stm32g0xx_hal.h"
  198. #endif /* USE_HAL_DRIVER */
  199. #ifdef __cplusplus
  200. }
  201. #endif /* __cplusplus */
  202. #endif /* STM32G0xx_H */
  203. /**
  204. * @}
  205. */
  206. /**
  207. * @}
  208. */
  209. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/