2012-06-15 08:19:34 +00:00
|
|
|
#include "xpt2046_lld.h"
|
|
|
|
|
|
|
|
#ifdef TOUCHPAD_USE_XPT2046
|
|
|
|
|
2012-07-22 20:21:19 +00:00
|
|
|
__inline uint16_t lld_tpReadX(void) {
|
2012-06-15 08:19:34 +00:00
|
|
|
uint8_t txbuf[1];
|
|
|
|
uint8_t rxbuf[2];
|
|
|
|
uint16_t x;
|
|
|
|
|
|
|
|
txbuf[0] = 0xd0;
|
2012-06-29 11:08:53 +00:00
|
|
|
TP_CS_LOW;
|
|
|
|
spiSend(&SPID1, 1, txbuf);
|
2012-06-15 08:19:34 +00:00
|
|
|
spiReceive(&SPID1, 2, rxbuf);
|
2012-06-29 11:08:53 +00:00
|
|
|
TP_CS_HIGH;
|
2012-06-15 08:19:34 +00:00
|
|
|
|
|
|
|
x = rxbuf[0] << 4;
|
|
|
|
x |= rxbuf[1] >> 4;
|
|
|
|
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2012-07-22 20:21:19 +00:00
|
|
|
__inline uint16_t lld_tpReadY(void) {
|
2012-06-15 08:19:34 +00:00
|
|
|
uint8_t txbuf[1];
|
|
|
|
uint8_t rxbuf[2];
|
|
|
|
uint16_t y;
|
|
|
|
|
|
|
|
txbuf[0] = 0x90;
|
2012-06-29 11:08:53 +00:00
|
|
|
TP_CS_LOW;
|
2012-06-15 08:19:34 +00:00
|
|
|
spiSend(&SPID1, 1, txbuf);
|
|
|
|
spiReceive(&SPID1, 2, rxbuf);
|
2012-06-29 11:08:53 +00:00
|
|
|
TP_CS_HIGH;
|
2012-06-15 08:19:34 +00:00
|
|
|
|
|
|
|
y = rxbuf[0] << 4;
|
|
|
|
y |= rxbuf[1] >> 4;
|
|
|
|
|
|
|
|
return y;
|
|
|
|
}
|
|
|
|
|
2012-07-22 20:21:19 +00:00
|
|
|
__inline uint16_t lld_tpReadZ(void) {
|
2012-06-15 08:19:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|