added ADS7843 lld support
This commit is contained in:
parent
4c90a487f7
commit
346fec7eb4
7 changed files with 60 additions and 31 deletions
39
drivers/ads7843_lld.c
Normal file
39
drivers/ads7843_lld.c
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#include "ads7843_lld.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 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
14
drivers/ads7843_lld.h
Normal file
14
drivers/ads7843_lld.h
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#ifndef ADS7843_LLD_H
|
||||||
|
#define ADS7843_LLD_H
|
||||||
|
|
||||||
|
#include "glcdconf.h"
|
||||||
|
#include "touchpad.h"
|
||||||
|
|
||||||
|
#ifdef TOUCHPAD_USE_ADS7843
|
||||||
|
|
||||||
|
uint16_t lld_readX(void);
|
||||||
|
uint16_t lld_readY(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define S6D1121_H
|
#define S6D1121_H
|
||||||
|
|
||||||
#include "glcd.h"
|
#include "glcd.h"
|
||||||
#include "lcdconf.h"
|
#include "glcdconf.h"
|
||||||
|
|
||||||
#ifdef LCD_USE_S6D1121
|
#ifdef LCD_USE_S6D1121
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define SSD1289_H
|
#define SSD1289_H
|
||||||
|
|
||||||
#include "glcd.h"
|
#include "glcd.h"
|
||||||
#include "lcdconf.h"
|
#include "glcdconf.h"
|
||||||
|
|
||||||
#ifdef LCD_USE_SSD1289
|
#ifdef LCD_USE_SSD1289
|
||||||
|
|
||||||
|
|
3
lcd.mk
3
lcd.mk
|
@ -5,7 +5,8 @@ LCDSRC = ${CHIBIOS}/ext/lcd/glcd.c \
|
||||||
${CHIBIOS}/ext/lcd/graph.c \
|
${CHIBIOS}/ext/lcd/graph.c \
|
||||||
${CHIBIOS}/ext/lcd/gui.c \
|
${CHIBIOS}/ext/lcd/gui.c \
|
||||||
${CHIBIOS}/ext/lcd/drivers/ssd1289_lld.c \
|
${CHIBIOS}/ext/lcd/drivers/ssd1289_lld.c \
|
||||||
${CHIBIOS}/ext/lcd/drivers/s6d1121_lld.c
|
${CHIBIOS}/ext/lcd/drivers/s6d1121_lld.c \
|
||||||
|
${CHIBIOS}/ext/lcd/drivers/ads7843_lld.c
|
||||||
|
|
||||||
LCDINC = ${CHIBIOS}/ext/lcd \
|
LCDINC = ${CHIBIOS}/ext/lcd \
|
||||||
${CHIBIOS}/etc/lcd/drivers
|
${CHIBIOS}/etc/lcd/drivers
|
||||||
|
|
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) {
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "ch.h"
|
#include "ch.h"
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "glcd.h"
|
#include "glcd.h"
|
||||||
|
#include "drivers/ads7843_lld.h"
|
||||||
|
|
||||||
#define CONVERSIONS 3
|
#define CONVERSIONS 3
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue