hk32f0xx.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /**************************************************************************
  2. * @file hk32f0xx.h
  3. * @version V1.0.1
  4. * @date 2019-08-15
  5. * @brief CMSIS Cortex-M Peripheral Access Layer for HKMicroChip devices
  6. *
  7. *****************************************************************************/
  8. /** @addtogroup hk32f0xx
  9. * @{
  10. */
  11. #ifndef __HK32F0xx_H
  12. #define __HK32F0xx_H
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif /* __cplusplus */
  16. /** @addtogroup Library_configuration_section
  17. * @{
  18. */
  19. /* Uncomment the line below according to the target HK32 device used in your
  20. application
  21. */
  22. #if !defined (HK32F030x4) && !defined (HK32F030x6) && !defined (HK32F030x8) &&\
  23. !defined (HK32F031x4) && !defined (HK32F031x6) && \
  24. !defined (HK32F04Ax4) && !defined (HK32F04Ax6) && !defined (HK32F04Ax8)
  25. #endif
  26. /* Tip: To avoid modifying this file each time you need to switch between these
  27. devices, you can define the device in your toolchain compiler preprocessor.
  28. */
  29. /**
  30. * @brief CMSIS Device version number V2.3.3
  31. */
  32. #define __HK32F0_DEVICE_VERSION_MAIN (0x02) /*!< [31:24] main version */
  33. #define __HK32F0_DEVICE_VERSION_SUB1 (0x03) /*!< [23:16] sub1 version */
  34. #define __HK32F0_DEVICE_VERSION_SUB2 (0x03) /*!< [15:8] sub2 version */
  35. #define __HK32F0_DEVICE_VERSION_RC (0x00) /*!< [7:0] release candidate */
  36. #define __HK32F0_DEVICE_VERSION ((__HK32F0_DEVICE_VERSION_MAIN << 24)\
  37. |(__HK32F0_DEVICE_VERSION_SUB1 << 16)\
  38. |(__HK32F0_DEVICE_VERSION_SUB2 << 8 )\
  39. |(__HK32F0_DEVICE_VERSION_RC))
  40. /**
  41. * @}
  42. */
  43. /** @addtogroup Device_Included
  44. * @{
  45. */
  46. #if defined(HK32F030x4)
  47. #include "hk32f030x4x6x8.h"
  48. #elif defined(HK32F030x6)
  49. #include "hk32f030x4x6x8.h"
  50. #elif defined(HK32F030x8)
  51. #include "hk32f030x4x6x8.h"
  52. #elif defined(HK32F031x4)
  53. #include "hk32f031x4x6.h"
  54. #elif defined(HK32F031x6)
  55. #include "hk32f031x4x6.h"
  56. #elif defined(HK32F04Ax)
  57. #include "hk32f04ax4x6x8.h"
  58. #else
  59. #error "Please select first the target HK32F0xx device used in your application (in hk32f0xx.h file)"
  60. #endif
  61. /**
  62. * @}
  63. */
  64. /** @addtogroup Exported_types
  65. * @{
  66. */
  67. typedef enum
  68. {
  69. RESET = 0,
  70. SET = 1
  71. } FlagStatus, ITStatus;
  72. typedef enum
  73. {
  74. DISABLE = 0,
  75. ENABLE = 1
  76. } FunctionalState;
  77. #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
  78. typedef enum
  79. {
  80. ERROR = 0,
  81. SUCCESS = 1
  82. } ErrorStatus;
  83. /**
  84. * @}
  85. */
  86. /** @addtogroup Exported_macros
  87. * @{
  88. */
  89. #define SET_BIT(REG, BIT) ((REG) |= (BIT))
  90. #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
  91. #define READ_BIT(REG, BIT) ((REG) & (BIT))
  92. #define CLEAR_REG(REG) ((REG) = (0x0))
  93. #define WRITE_REG(REG, VAL) ((REG) = (VAL))
  94. #define READ_REG(REG) ((REG))
  95. #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
  96. /** @addtogroup Library_configuration_section
  97. * @{
  98. */
  99. /**
  100. * @brief HK32 Family
  101. */
  102. #if !defined (HK32F0)
  103. #define HK32F0
  104. #endif /* HK32F0 */
  105. /*
  106. * @brief In the following line adjust the value of External High Speed oscillator (HSE)
  107. used in your application
  108. Tip: To avoid modifying this file each time you need to use different HSE, you
  109. can define the HSE value in your toolchain compiler preprocessor.
  110. */
  111. #if !defined (HSE_VALUE)
  112. #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz*/
  113. #endif /* HSE_VALUE */
  114. /**
  115. * @brief In the following line adjust the External High Speed oscillator (HSE) Startup
  116. Timeout value
  117. */
  118. #if !defined (HSE_STARTUP_TIMEOUT)
  119. #define HSE_STARTUP_TIMEOUT ((uint16_t)0xFFFF) /*!< Time out for HSE start up */
  120. #endif /* HSE_STARTUP_TIMEOUT */
  121. /**
  122. * @brief In the following line adjust the Internal High Speed oscillator (HSI) Startup
  123. Timeout value
  124. */
  125. #if !defined (HSI_STARTUP_TIMEOUT)
  126. #define HSI_STARTUP_TIMEOUT ((uint16_t)0xFFFF) /*!< Time out for HSI start up */
  127. #endif /* HSI_STARTUP_TIMEOUT */
  128. #if !defined (HSI_VALUE)
  129. #define HSI_VALUE ((uint32_t)8000000) /*!< Value of the Internal High Speed oscillator in Hz.
  130. The real value may vary depending on the variations
  131. in voltage and temperature. */
  132. #endif /* HSI_VALUE */
  133. #if !defined (HSI14_VALUE)
  134. #define HSI14_VALUE ((uint32_t)14000000) /*!< Value of the Internal High Speed oscillator for ADC in Hz.
  135. The real value may vary depending on the variations
  136. in voltage and temperature. */
  137. #endif /* HSI14_VALUE */
  138. #if !defined (HSI48_VALUE)
  139. #define HSI48_VALUE ((uint32_t)48000000) /*!< Value of the Internal High Speed oscillator for USB in Hz.
  140. The real value may vary depending on the variations
  141. in voltage and temperature. */
  142. #endif /* HSI48_VALUE */
  143. #if !defined (LSI_VALUE)
  144. #define LSI_VALUE ((uint32_t)40000) /*!< Value of the Internal Low Speed oscillator in Hz
  145. The real value may vary depending on the variations
  146. in voltage and temperature. */
  147. #endif /* LSI_VALUE */
  148. #if !defined (LSE_VALUE)
  149. #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External Low Speed oscillator in Hz */
  150. #endif /* LSE_VALUE */
  151. /**
  152. * @brief HK32F0xx Standard Peripheral Library version number V1.4.0
  153. */
  154. #define __HK32F0XX_STDPERIPH_VERSION_MAIN (0x01) /*!< [31:24] main version */
  155. #define __HK32F0XX_STDPERIPH_VERSION_SUB1 (0x05) /*!< [23:16] sub1 version */
  156. #define __HK32F0XX_STDPERIPH_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
  157. #define __HK32F0XX_STDPERIPH_VERSION_RC (0x00) /*!< [7:0] release candidate */
  158. #define __HK32F0XX_STDPERIPH_VERSION ((__HK32F0XX_STDPERIPH_VERSION_MAIN << 24)\
  159. |(__HK32F0XX_STDPERIPH_VERSION_SUB1 << 16)\
  160. |(__HK32F0XX_STDPERIPH_VERSION_SUB2 << 8)\
  161. |(__HK32F0XX_STDPERIPH_VERSION_RC))
  162. #ifdef USE_STDPERIPH_DRIVER
  163. #include "hk32f0xx_hk_conf.h"
  164. #endif
  165. /*#endif USE_STDPERIPH_DRIVER*/
  166. #endif /*#endif __HK32F0xx_H*/