added ADS7843 lld support

This commit is contained in:
Tectu 2012-06-11 18:37:38 +02:00
parent 4c90a487f7
commit 346fec7eb4
7 changed files with 60 additions and 31 deletions

39
drivers/ads7843_lld.c Normal file
View 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
View 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

View File

@ -2,7 +2,7 @@
#define S6D1121_H
#include "glcd.h"
#include "lcdconf.h"
#include "glcdconf.h"
#ifdef LCD_USE_S6D1121

View File

@ -2,7 +2,7 @@
#define SSD1289_H
#include "glcd.h"
#include "lcdconf.h"
#include "glcdconf.h"
#ifdef LCD_USE_SSD1289

3
lcd.mk
View File

@ -5,7 +5,8 @@ LCDSRC = ${CHIBIOS}/ext/lcd/glcd.c \
${CHIBIOS}/ext/lcd/graph.c \
${CHIBIOS}/ext/lcd/gui.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 \
${CHIBIOS}/etc/lcd/drivers

View File

@ -17,37 +17,11 @@ void tpInit(SPIDriver *spip) {
}
static __inline uint16_t 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;
return lld_readX();
}
static __inline uint16_t 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;
return lld_readY();
}
uint8_t tpIRQ(void) {

View File

@ -4,6 +4,7 @@
#include "ch.h"
#include "hal.h"
#include "glcd.h"
#include "drivers/ads7843_lld.h"
#define CONVERSIONS 3