📄 ads7843.c
字号:
#include "ADS7843.h"
#include "stm32f10x_lib.h"
unsigned char SPI_WriteByte(unsigned char data)
{
unsigned char Data = 0;
//Wait until the transmit buffer is empty
while(SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_TXE)==RESET);
// Send the byte
SPI_I2S_SendData(SPI1,data);
//Wait until a data is received
while(SPI_I2S_GetFlagStatus(SPI1,SPI_I2S_FLAG_RXNE)==RESET);
// Get the received data
Data = SPI_I2S_ReceiveData(SPI1);
// Return the shifted data
return Data;
}
void SpiDelay(unsigned int DelayCnt)
{
unsigned int i;
for(i=0;i<DelayCnt;i++);
}
int TPReadX(void)
{
int x=0;
TP_CS();
SpiDelay(10);
SPI_WriteByte(0x90);
SpiDelay(10);
//WaitTPReady();
x=SPI_WriteByte(0x00);
x<<=8;
x+=SPI_WriteByte(0x00);
//SpiDelay(10);
TP_DCS();
return x>>4;
}
int TPReadY(void)
{
int y=0;
TP_CS();
SpiDelay(10);
SPI_WriteByte(0xD0);
SpiDelay(10);
//WaitTPReady();
y=SPI_WriteByte(0x00);
y<<=8;
y+=SPI_WriteByte(0x00);
//SpiDelay(10);
TP_DCS();
return y>>4;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -