📄 touchtest.c
字号:
#include "LPC24xx.h"
#include "type.h"
#include "data_types.h"
#include "touch_screen.h"
#include "lcd_driver.h"
#include "lcd_params.h"
#include "irq.h"
#include "uart.h"
extern INT32U x_values[num_samples]; // array to store x_samples
extern INT32U y_values[num_samples]; // array to store y_samples
static INT32U x_pos, y_pos;
volatile DWORD eint0_counter;
/***********************************************************************
*
* Function: gpio0_handler
*
* Purpose: gpio0_handler.
*
* Processing:
*
* Parameters: None
*
* Outputs: None
*
* Returns: None
*
**********************************************************************/
__irq void IRQ_Handler (void)
{ INT32U i;
FIO3CLR=0X00FF0000;
FIO3SET=0x00C30000;
if (IO_INT_STAT & 0x1)
{
// timer_delay(debounce); /* debounce the touch */
if (touch_detect()) /* loop as long as screen is touched */
{
read_ch_x(); /* read and collect the x values */
read_ch_y(); /* read and collect the y values */
x_pos = 0;
for (i=0; i < num_samples; i++)
{
x_pos += x_values[i]; /* add up the conversion results */
}
x_pos = x_pos / num_samples; /* get average */
y_pos = 0;
for (i=0; i < num_samples; i++)
{
y_pos += y_values[i]; /* add up conversion results */
}
y_pos = y_pos / num_samples; /* get average */
y_pos =y_pos;
UARTSendChar(x_pos, y_pos);
test_touch(x_pos,y_pos);
delayMs(1500);
}
touch_detect();
IO0_INT_CLR = X_plus; /* clear X-plus interrupt */
VICAddress = 0; /* Acknowledge Interrupt */
}
}
/*****************************************************************************
** Function name: EINTInit
**
** Descriptions: Install_irq
**
** parameters: None
** Returned value: true or false, return false if the interrupt
** handler can't be installed to the VIC table.
**
*****************************************************************************/
DWORD EINTInit(void)
{
VICIntSelect=0x00000000;
IO0_INT_CLR = 0xffffffff;
IO2_INT_CLR = 0xffffffff;
if ( install_irq( EINT3_INT, (void *)IRQ_Handler, HIGHEST_PRIORITY ) == FALSE )
{
return (FALSE);
}
VICVectAddr17 = (DWORD)IRQ_Handler;
VICIntEnable = 1 << 17;
IO0_INT_EN_F = X_plus;
return( TRUE );
}
/******************************************************************************
** End Of File
******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -