123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- #ifndef __SYS_H__
- #define __SYS_H__
- #include "gd32e23x.h"
- #include "typedefine.h"
- #include "gd32e23x_libopt.h"
- #include "software_timer.h"
- #include "hardware_delay.h"
- //Ex_NVIC_Config专用定义
- #define GPIO_A 0
- #define GPIO_B 1
- #define GPIO_C 2
- #define GPIO_D 3
- #define GPIO_E 4
- #define GPIO_F 5
- #define GPIO_G 6
- #define GPIO_H 7
- #define GPIO_I 8
- //GPIO引脚编号定义
- #define PIN0 1<<0
- #define PIN1 1<<1
- #define PIN2 1<<2
- #define PIN3 1<<3
- #define PIN4 1<<4
- #define PIN5 1<<5
- #define PIN6 1<<6
- #define PIN7 1<<7
- #define PIN8 1<<8
- #define PIN9 1<<9
- #define PIN10 1<<10
- #define PIN11 1<<11
- #define PIN12 1<<12
- #define PIN13 1<<13
- #define PIN14 1<<14
- #define PIN15 1<<15
- #define UNUSED(X) (void)X
- /**
- * 读取系统当前时钟
- *
- * @author Lim (2023/3/14)
- *
- * @param void
- *
- * @return uint32_t
- */
- uint32_t Sys_Get_Core_Clock(void);
- /**
- * 系统时钟初始化
- * 时钟单位(MHZ)
- *
- * @author Lim (2023/3/14)
- *
- * @param core_clock 主时钟
- * @param source_clock 源时钟(晶振,一般是8M)
- * @param periph_clock 外设时钟
- */
- void Sys_Clock_Init(uint32_t core_clock,uint32_t source_clock,uint32_t periph_clock);
- /**
- * 中断向量表存储区域
- *
- * @author Lim (2023/3/14)
- *
- * @param tab 表存储区域
- * @param offset 表偏移
- */
- void Sys_NVIC_Set_VectorTable(uint32_t tab, uint32_t offset);
- /**
- * 设置中断优先级
- *
- * @author Lim (2023/3/14)
- *
- * @param NVIC_PreemptionPriority 主优先组
- * @param NVIC_SubPriority 子优先组
- * @param NVIC_Channel 中断通道
- * @param NVIC_Group 中断组选择
- */
- void Sys_NVIC_Init(uint8_t NVIC_PreemptionPriority,uint8_t NVIC_SubPriority,uint8_t NVIC_Channel,uint8_t NVIC_Group);
- /**
- * NVIC中断优先级组配置
- *
- * @author Lim (2023/3/14)
- *
- * @param NVIC_Group
- */
- void Sys_NVIC_PriorityGroupConfig(uint8_t NVIC_Group);
- //以下为汇编函数
- void WFI_SET(void); //执行WFI指令
- void INTX_DISABLE(void);//关闭所有中断
- void INTX_ENABLE(void); //开启所有中断
- void MSR_MSP(uint32_t addr); //设置堆栈地址
- /**
- * 获取外设的时钟使能位
- *
- * @author Lim (2023/3/15)
- *
- * @param base
- *
- * @return rcu_periph_enum
- */
- rcu_periph_enum rcu_periph_clock_bit(uint32_t base);
- void Sys_Soft_Reset(void);
- #endif
|