GD32Sys.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #ifndef __SYS_H__
  2. #define __SYS_H__
  3. #include "gd32e23x.h"
  4. #include "typedefine.h"
  5. #include "gd32e23x_libopt.h"
  6. #include "software_timer.h"
  7. #include "hardware_delay.h"
  8. //Ex_NVIC_Config专用定义
  9. #define GPIO_A 0
  10. #define GPIO_B 1
  11. #define GPIO_C 2
  12. #define GPIO_D 3
  13. #define GPIO_E 4
  14. #define GPIO_F 5
  15. #define GPIO_G 6
  16. #define GPIO_H 7
  17. #define GPIO_I 8
  18. //GPIO引脚编号定义
  19. #define PIN0 1<<0
  20. #define PIN1 1<<1
  21. #define PIN2 1<<2
  22. #define PIN3 1<<3
  23. #define PIN4 1<<4
  24. #define PIN5 1<<5
  25. #define PIN6 1<<6
  26. #define PIN7 1<<7
  27. #define PIN8 1<<8
  28. #define PIN9 1<<9
  29. #define PIN10 1<<10
  30. #define PIN11 1<<11
  31. #define PIN12 1<<12
  32. #define PIN13 1<<13
  33. #define PIN14 1<<14
  34. #define PIN15 1<<15
  35. #define UNUSED(X) (void)X
  36. /**
  37. * 读取系统当前时钟
  38. *
  39. * @author Lim (2023/3/14)
  40. *
  41. * @param void
  42. *
  43. * @return uint32_t
  44. */
  45. uint32_t Sys_Get_Core_Clock(void);
  46. /**
  47. * 系统时钟初始化
  48. * 时钟单位(MHZ)
  49. *
  50. * @author Lim (2023/3/14)
  51. *
  52. * @param core_clock 主时钟
  53. * @param source_clock 源时钟(晶振,一般是8M)
  54. * @param periph_clock 外设时钟
  55. */
  56. void Sys_Clock_Init(uint32_t core_clock,uint32_t source_clock,uint32_t periph_clock);
  57. /**
  58. * 中断向量表存储区域
  59. *
  60. * @author Lim (2023/3/14)
  61. *
  62. * @param tab 表存储区域
  63. * @param offset 表偏移
  64. */
  65. void Sys_NVIC_Set_VectorTable(uint32_t tab, uint32_t offset);
  66. /**
  67. * 设置中断优先级
  68. *
  69. * @author Lim (2023/3/14)
  70. *
  71. * @param NVIC_PreemptionPriority 主优先组
  72. * @param NVIC_SubPriority 子优先组
  73. * @param NVIC_Channel 中断通道
  74. * @param NVIC_Group 中断组选择
  75. */
  76. void Sys_NVIC_Init(uint8_t NVIC_PreemptionPriority,uint8_t NVIC_SubPriority,uint8_t NVIC_Channel,uint8_t NVIC_Group);
  77. /**
  78. * NVIC中断优先级组配置
  79. *
  80. * @author Lim (2023/3/14)
  81. *
  82. * @param NVIC_Group
  83. */
  84. void Sys_NVIC_PriorityGroupConfig(uint8_t NVIC_Group);
  85. //以下为汇编函数
  86. void WFI_SET(void); //执行WFI指令
  87. void INTX_DISABLE(void);//关闭所有中断
  88. void INTX_ENABLE(void); //开启所有中断
  89. void MSR_MSP(uint32_t addr); //设置堆栈地址
  90. /**
  91. * 获取外设的时钟使能位
  92. *
  93. * @author Lim (2023/3/15)
  94. *
  95. * @param base
  96. *
  97. * @return rcu_periph_enum
  98. */
  99. rcu_periph_enum rcu_periph_clock_bit(uint32_t base);
  100. void Sys_Soft_Reset(void);
  101. #endif