From bee99e496f816792014d02f4eca3a33d3ed8db2b Mon Sep 17 00:00:00 2001 From: Karl Kurbjun Date: Tue, 28 Apr 2009 05:20:31 +0000 Subject: M:Robe 500: Fix red, commit missing work, reduce lcd wakeup time. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20819 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/tsc2100.c | 60 +++++++++++++++++++--- .../target/arm/tms320dm320/mrobe-500/lcd-mr500.c | 5 +- 2 files changed, 54 insertions(+), 11 deletions(-) diff --git a/firmware/drivers/tsc2100.c b/firmware/drivers/tsc2100.c index 88402fe3ad..14b56b76c9 100644 --- a/firmware/drivers/tsc2100.c +++ b/firmware/drivers/tsc2100.c @@ -25,20 +25,64 @@ #include "spi.h" #include "tsc2100.h" -/* Read X, Y, Z1, Z2 touchscreen coordinates. */ -void tsc2100_read_values(short *x, short* y, short *z1, short *z2) +/* adc_data contains the last readings from the tsc2100 */ +static short adc_data[10]; + +void tsc2100_read_data(void) { int page = 0, address = 0; + unsigned int i; unsigned short command = 0x8000|(page << 11)|(address << 5); unsigned char out[] = {command >> 8, command & 0xff}; - unsigned char in[8]; + unsigned char *p_adc_data=(unsigned char *)&adc_data; + spi_block_transfer(SPI_target_TSC2100, - out, sizeof(out), in, sizeof(in)); + out, sizeof(out), (char *)adc_data, sizeof(adc_data)); + + for(i=0; i>1]=(short)(p_adc_data[i]<<8|p_adc_data[i+1]); +} + +/* Read X, Y, Z1, Z2 touchscreen coordinates. */ +void tsc2100_read_touch(short *x, short* y, short *z1, short *z2) +{ + *x = adc_data[0]; + *y = adc_data[1]; + *z1 = adc_data[2]; + *z2 = adc_data[3]; +} - *x = (in[0]<<8)|in[1]; - *y = (in[2]<<8)|in[3]; - *z1 = (in[4]<<8)|in[5]; - *z2 = (in[6]<<8)|in[7]; +void tsc2100_read_volt(short *bat1, short *bat2, short *aux) +{ + *bat1 = adc_data[5]; + *bat2 = adc_data[6]; + *aux = adc_data[7]; +} + +void tsc2100_set_mode(unsigned char scan_mode) +{ + short tsadc=(scan_mode<