114 lines
4.6 KiB
C
114 lines
4.6 KiB
C
#ifndef __BSP_XPT2046_LCD_H
|
||
#define __BSP_XPT2046_LCD_H
|
||
|
||
|
||
#include "stm32f10x.h"
|
||
|
||
|
||
|
||
/******************************* XPT2046 뇰층팁櫓뙤多신땍屢 ***************************/
|
||
#define macXPT2046_EXTI_GPIO_CLK RCC_APB2Periph_GPIOF
|
||
#define macXPT2046_EXTI_GPIO_PORT GPIOF
|
||
#define macXPT2046_EXTI_GPIO_PIN GPIO_Pin_9
|
||
#define macXPT2046_EXTI_SOURCE_PORT GPIO_PortSourceGPIOF
|
||
#define macXPT2046_EXTI_SOURCE_PIN GPIO_PinSource9
|
||
#define macXPT2046_EXTI_LINE EXTI_Line9
|
||
#define macXPT2046_EXTI_IRQ EXTI9_5_IRQn
|
||
#define macXPT2046_EXTI_INT_FUNCTION EXTI9_5_IRQHandler
|
||
|
||
#define macXPT2046_EXTI_ActiveLevel 0
|
||
#define macXPT2046_EXTI_Read() GPIO_ReadInputDataBit ( macXPT2046_EXTI_GPIO_PORT, macXPT2046_EXTI_GPIO_PIN )
|
||
|
||
|
||
|
||
/******************************* XPT2046 뇰층팁친콰SPI多신땍屢 ***************************/
|
||
#define macXPT2046_SPI_GPIO_CLK RCC_APB2Periph_GPIOF| RCC_APB2Periph_GPIOG
|
||
|
||
#define macXPT2046_SPI_CS_PIN GPIO_Pin_10
|
||
#define macXPT2046_SPI_CS_PORT GPIOF
|
||
|
||
#define macXPT2046_SPI_CLK_PIN GPIO_Pin_7
|
||
#define macXPT2046_SPI_CLK_PORT GPIOG
|
||
|
||
#define macXPT2046_SPI_MOSI_PIN GPIO_Pin_11
|
||
#define macXPT2046_SPI_MOSI_PORT GPIOF
|
||
|
||
#define macXPT2046_SPI_MF103-寧켓諒_PIN GPIO_Pin_6
|
||
#define macXPT2046_SPI_MF103-寧켓諒_PORT GPIOF
|
||
|
||
|
||
#define macXPT2046_CS_ENABLE() GPIO_SetBits ( macXPT2046_SPI_CS_PORT, macXPT2046_SPI_CS_PIN )
|
||
#define macXPT2046_CS_DISABLE() GPIO_ResetBits ( macXPT2046_SPI_CS_PORT, macXPT2046_SPI_CS_PIN )
|
||
|
||
#define macXPT2046_CLK_HIGH() GPIO_SetBits ( macXPT2046_SPI_CLK_PORT, macXPT2046_SPI_CLK_PIN )
|
||
#define macXPT2046_CLK_LOW() GPIO_ResetBits ( macXPT2046_SPI_CLK_PORT, macXPT2046_SPI_CLK_PIN )
|
||
|
||
#define macXPT2046_MOSI_1() GPIO_SetBits ( macXPT2046_SPI_MOSI_PORT, macXPT2046_SPI_MOSI_PIN )
|
||
#define macXPT2046_MOSI_0() GPIO_ResetBits ( macXPT2046_SPI_MOSI_PORT, macXPT2046_SPI_MOSI_PIN )
|
||
|
||
#define macXPT2046_MF103-寧켓諒() GPIO_ReadInputDataBit ( macXPT2046_SPI_MF103-寧켓諒_PORT, macXPT2046_SPI_MF103-寧켓諒_PIN )
|
||
|
||
|
||
|
||
/******************************* XPT2046 뇰층팁꽝鑒땍屢 ***************************/
|
||
#define macXPT2046_Coordinate_GramScan 2 //朞嶝 XPT2046 뇰층팁돨麟깃宮뚤黨부蘆<EBB680>췄렘蕨
|
||
#define macXPT2046_THRESHOLD_CalDiff 2 //叫硫뇰층팁珂뇰층麟깃돨AD令宮뀌쳔掘
|
||
|
||
#define macXPT2046_CHANNEL_X 0x90 //繫돛Y+돨朞嶝왠齡俚
|
||
#define macXPT2046_CHANNEL_Y 0xd0 //繫돛X+돨朞嶝왠齡俚
|
||
|
||
|
||
|
||
/******************************* <20>츠 XPT2046 宮밑돨鑒앴잚謹 ***************************/
|
||
typedef struct //捻쑨麟깃써뭐竟
|
||
{
|
||
uint16_t x;
|
||
uint16_t y;
|
||
|
||
} strType_XPT2046_Coordinate;
|
||
|
||
|
||
typedef struct //叫硫凜綾써뭐竟
|
||
{
|
||
long double An, //鬧:sizeof(long double) = 8
|
||
Bn,
|
||
Cn,
|
||
Dn,
|
||
En,
|
||
Fn,
|
||
Divider;
|
||
|
||
} strType_XPT2046_Calibration;
|
||
|
||
|
||
typedef struct //叫硫溝鑒써뭐竟(離老賈痰)
|
||
{
|
||
long double dX_X,
|
||
dX_Y,
|
||
dX,
|
||
dY_X,
|
||
dY_Y,
|
||
dY;
|
||
|
||
} strType_XPT2046_TouchPara;
|
||
|
||
|
||
|
||
/******************************* <20>츠 XPT2046 宮밑돨棍꼬홍애긴좆 ***************************/
|
||
extern volatile uint8_t ucXPT2046_TouchFlag;
|
||
|
||
extern strType_XPT2046_TouchPara strXPT2046_TouchPara;
|
||
|
||
|
||
|
||
/******************************** XPT2046 뇰층팁변鑒<EBB380>츠 **********************************/
|
||
void XPT2046_Init ( void );
|
||
|
||
uint8_t XPT2046_Touch_Calibrate ( void );
|
||
uint8_t XPT2046_Get_TouchedPoint ( strType_XPT2046_Coordinate * displayPtr, strType_XPT2046_TouchPara * para );
|
||
|
||
|
||
|
||
#endif /* __BSP_TOUCH_H */
|
||
|