1, a new structure
m10_api.h ---- 32 lines
//Touch 感应相关参数
typedef struct{
unsigned short countPresent; //感应时间计数
volatile unsigned short dropInterval; //2次感应间隔计时计数
volatile unsigned short touchFlag;
}TOUCH;
2, the definition of a structure parameter initialization.
m10_api.c ---- 25 lines
TOUCH touchSt={ 0 };
Define global variables, external call:
m10_api.h ---- 104 OK
extern TOUCH touchSt;
3, using the structure parameter
gpio.c ----- 498 line
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); // 红灯灭
}