aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ads7843.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ads7843.c')
-rw-r--r--drivers/ads7843.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/ads7843.c b/drivers/ads7843.c
new file mode 100644
index 00000000..5349ab08
--- /dev/null
+++ b/drivers/ads7843.c
@@ -0,0 +1,41 @@
+#include "drivers/ads7843.h"
+
+#ifdef TOUCHPAD_USE_ADS7843
+
+__inline uint16_t lld_readX(void) {
+ uint8_t txbuf[1];
+ uint8_t rxbuf[2];
+ uint16_t x;
+
+ txbuf[0] = 0xd0;
+ SET_CS(0);
+ spiSend(&SPID1, 1, txbuf);
+ spiReceive(&SPID1, 2, rxbuf);
+ SET_CS(1);
+
+ x = rxbuf[0] << 4;
+ x |= rxbuf[1] >> 4;
+
+ return x;
+}
+
+__inline uint16_t lld_readY(void) {
+ uint8_t txbuf[1];
+ uint8_t rxbuf[2];
+ uint16_t x;
+
+ txbuf[0] = 0x90;
+ SET_CS(0);
+ spiSend(&SPID1, 1, txbuf);
+ spiReceive(&SPID1, 2, rxbuf);
+ SET_CS(1);
+
+ x = rxbuf[0] << 4;
+ x |= rxbuf[1] >> 4;
+
+ return x;
+
+}
+
+#endif
+