added driver for xpt2046 touchpad driver
This commit is contained in:
parent
c7a393c6d7
commit
688cd9c879
2 changed files with 58 additions and 0 deletions
43
drivers/xpt2046_lld.c
Normal file
43
drivers/xpt2046_lld.c
Normal file
|
@ -0,0 +1,43 @@
|
|||
#include "xpt2046_lld.h"
|
||||
|
||||
#ifdef TOUCHPAD_USE_XPT2046
|
||||
|
||||
__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 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;
|
||||
}
|
||||
|
||||
__inline uint16_t lld_readZ(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
15
drivers/xpt2046_lld.h
Normal file
15
drivers/xpt2046_lld.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef XPT2046_LLD_H
|
||||
#define XPT2046_LLD_H
|
||||
|
||||
#include "glcdconf.h"
|
||||
#include "touchpad.h"
|
||||
|
||||
#ifdef TOUCHPAD_USE_XPT2046
|
||||
|
||||
uint16_t lld_readX(void);
|
||||
uint16_t lld_readY(void);
|
||||
uint16_t lld_readZ(void);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
Loading…
Add table
Reference in a new issue