El uso de parámetros de estructura

 

1, una nueva estructura de

m10_api.h ---- 32 líneas

//Touch 感应相关参数
typedef struct{
    unsigned short countPresent;              //感应时间计数
    volatile unsigned short dropInterval;     //2次感应间隔计时计数
    volatile unsigned short touchFlag;
 
}TOUCH;

 

 

2, la definición de una inicialización de parámetros de estructura.

m10_api.c ---- 25 líneas

TOUCH  touchSt={ 0 };

Definir variables globales, llamada externa:

m10_api.h ---- 104 OK

extern TOUCH touchSt;

 

3, utilizando el parámetro de estructura

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);      // 红灯灭
}

 

 

Publicados 162 artículos originales · ganado elogios 125 · vistas 470 000 +

Supongo que te gusta

Origin blog.csdn.net/jiangchao3392/article/details/99652261
Recomendado
Clasificación