added ads7843 lld functions
This commit is contained in:
parent
af394c2ba2
commit
163a42e48e
3 changed files with 54 additions and 28 deletions
41
drivers/ads7843.c
Normal file
41
drivers/ads7843.c
Normal file
|
@ -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
|
||||||
|
|
11
drivers/ads7843.h
Normal file
11
drivers/ads7843.h
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#ifndef ADS7843_H
|
||||||
|
#define ADS7843_h
|
||||||
|
|
||||||
|
#ifdef TOUCHPAD_USE_ADS7843
|
||||||
|
#include "touchpad.h"
|
||||||
|
|
||||||
|
uint16_t lld_readX(void):
|
||||||
|
uint16_t lld_readY(void)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
30
touchpad.c
30
touchpad.c
|
@ -17,37 +17,11 @@ void tpInit(SPIDriver *spip) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline uint16_t readX(void) {
|
static __inline uint16_t readX(void) {
|
||||||
uint8_t txbuf[1];
|
return lld_readX();
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline uint16_t readY(void) {
|
static __inline uint16_t readY(void) {
|
||||||
uint8_t txbuf[1];
|
return lld_readY();
|
||||||
uint8_t rxbuf[2];
|
|
||||||
uint16_t y;
|
|
||||||
|
|
||||||
txbuf[0] = 0x90;
|
|
||||||
SET_CS(0);
|
|
||||||
spiSend(&SPID1, 1, txbuf);
|
|
||||||
spiReceive(&SPID1, 2, rxbuf);
|
|
||||||
SET_CS(1);
|
|
||||||
|
|
||||||
y = rxbuf[0] << 4;
|
|
||||||
y |= rxbuf[1] >> 4;
|
|
||||||
|
|
||||||
return y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t tpIRQ(void) {
|
uint8_t tpIRQ(void) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue