oscilloscope/User/lcd/bsp_xpt2046_lcd.h

114 lines
4.6 KiB
C
Raw Normal View History

2020-10-25 22:59:45 +08:00
#ifndef __BSP_XPT2046_LCD_H
#define __BSP_XPT2046_LCD_H
#include "stm32f10x.h"
/******************************* XPT2046 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD> ***************************/
#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 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>SPI<50><49><EFBFBD>Ŷ<EFBFBD><C5B6><EFBFBD> ***************************/
#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-ָ<><D6B8><EFBFBD><EFBFBD>_PIN GPIO_Pin_6
#define macXPT2046_SPI_MF103-ָ<><D6B8><EFBFBD><EFBFBD>_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-ָ<><D6B8><EFBFBD><EFBFBD>() GPIO_ReadInputDataBit ( macXPT2046_SPI_MF103-ָ<><D6B8><EFBFBD><EFBFBD>_PORT, macXPT2046_SPI_MF103-ָ<><D6B8><EFBFBD><EFBFBD>_PIN )
/******************************* XPT2046 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ***************************/
#define macXPT2046_Coordinate_GramScan 2 //ѡ<><D1A1> XPT2046 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ں<EFBFBD><DABA><EFBFBD>ɨ<EFBFBD><EFBFBD><E8B7BD>
#define macXPT2046_THRESHOLD_CalDiff 2 //У׼<D0A3><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ADֵ<44><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define macXPT2046_CHANNEL_X 0x90 //ͨ<><CDA8>Y+<2B><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define macXPT2046_CHANNEL_Y 0xd0 //ͨ<><CDA8>X+<2B><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/******************************* <20><><EFBFBD><EFBFBD> XPT2046 <20><><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ***************************/
typedef struct //Һ<><D2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B9B9>
{
uint16_t x;
uint16_t y;
} strType_XPT2046_Coordinate;
typedef struct //У׼<D0A3><D7BC><EFBFBD>ӽṹ<D3BD><E1B9B9>
{
long double An, //ע:sizeof(long double) = 8
Bn,
Cn,
Dn,
En,
Fn,
Divider;
} strType_XPT2046_Calibration;
typedef struct //У׼ϵ<D7BC><CFB5><EFBFBD><EFBFBD><EFBFBD><E5A3A8><EFBFBD><EFBFBD>ʹ<EFBFBD>ã<EFBFBD>
{
long double dX_X,
dX_Y,
dX,
dY_X,
dY_Y,
dY;
} strType_XPT2046_TouchPara;
/******************************* <20><><EFBFBD><EFBFBD> XPT2046 <20><><EFBFBD>ص<EFBFBD><D8B5>ⲿȫ<E2B2BF>ֱ<EFBFBD><D6B1><EFBFBD> ***************************/
extern volatile uint8_t ucXPT2046_TouchFlag;
extern strType_XPT2046_TouchPara strXPT2046_TouchPara;
/******************************** XPT2046 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> **********************************/
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 */