1, 新建一个结构体
m10_api.h----32行
//Touch 感应相关参数
typedef struct{
unsigned short countPresent; //感应时间计数
volatile unsigned short dropInterval; //2次感应间隔计时计数
volatile unsigned short touchFlag;
}TOUCH;
2, 定义一个结构体参数, 初始化。
m10_api.c----25行
TOUCH touchSt={ 0 };
定义全局变量,外部调用:
m10_api.h----104行
extern TOUCH touchSt;
3,使用结构体参数
gpio.c -----498行
void GPIO1_Handler(void)
{
touchSt.dropInterval = DropCnt;
touchSt.touchFlag =1;
DropCnt = 0; //计数器清零
GPIOn_Handler(GPIO1_IRQn);
}
main.c
if(touchSt.touchFlag ==1)
{
touchSt.touchFlag=0;
touch_flag=!touch_flag;
}
if(touch_flag==0)
{
GPIO_SetInactive(RedLED_PORT, RedLED_PIN); //红灯亮
else
{
GPIO_SetActive(RedLED_PORT, RedLED_PIN); // 红灯灭
}