diff options
Diffstat (limited to 'firmware/drivers/tsc2100.c')
-rw-r--r-- | firmware/drivers/tsc2100.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/firmware/drivers/tsc2100.c b/firmware/drivers/tsc2100.c index 09017996dc..b8edb7d52d 100644 --- a/firmware/drivers/tsc2100.c +++ b/firmware/drivers/tsc2100.c | |||
@@ -28,9 +28,6 @@ | |||
28 | /* adc_data contains the last readings from the tsc2100 */ | 28 | /* adc_data contains the last readings from the tsc2100 */ |
29 | static short adc_data[10]; | 29 | static short adc_data[10]; |
30 | static short adc_status; | 30 | static short adc_status; |
31 | static long adc_last_read=0; | ||
32 | static long adc_last_touch_read=0; | ||
33 | static long adc_last_volt_read=0; | ||
34 | 31 | ||
35 | void tsc2100_read_data(void) | 32 | void tsc2100_read_data(void) |
36 | { | 33 | { |
@@ -42,8 +39,6 @@ void tsc2100_read_data(void) | |||
42 | 39 | ||
43 | adc_status|=tsc2100_readreg(TSSTAT_PAGE, TSSTAT_ADDRESS); | 40 | adc_status|=tsc2100_readreg(TSSTAT_PAGE, TSSTAT_ADDRESS); |
44 | 41 | ||
45 | adc_last_read=current_tick; | ||
46 | |||
47 | spi_block_transfer(SPI_target_TSC2100, | 42 | spi_block_transfer(SPI_target_TSC2100, |
48 | out, sizeof(out), (char *)adc_data, sizeof(adc_data)); | 43 | out, sizeof(out), (char *)adc_data, sizeof(adc_data)); |
49 | 44 | ||
@@ -54,11 +49,7 @@ void tsc2100_read_data(void) | |||
54 | /* Read X, Y, Z1, Z2 touchscreen coordinates. */ | 49 | /* Read X, Y, Z1, Z2 touchscreen coordinates. */ |
55 | bool tsc2100_read_touch(short *x, short* y, short *z1, short *z2) | 50 | bool tsc2100_read_touch(short *x, short* y, short *z1, short *z2) |
56 | { | 51 | { |
57 | /* Note: This could cause problems if the current tick is not reset in ~1.3 | 52 | if( adc_status&(3<<9) ) { |
58 | * years. Noting this in the event that a suspend/resume function | ||
59 | * is added. | ||
60 | */ | ||
61 | if( (adc_status&(3<<9)) && (adc_last_read - adc_last_touch_read>=0) ) { | ||
62 | *x = adc_data[0]; | 53 | *x = adc_data[0]; |
63 | *y = adc_data[1]; | 54 | *y = adc_data[1]; |
64 | *z1 = adc_data[2]; | 55 | *z1 = adc_data[2]; |
@@ -66,8 +57,6 @@ bool tsc2100_read_touch(short *x, short* y, short *z1, short *z2) | |||
66 | 57 | ||
67 | adc_status&=~(3<<9); | 58 | adc_status&=~(3<<9); |
68 | 59 | ||
69 | adc_last_touch_read=current_tick; | ||
70 | |||
71 | return true; | 60 | return true; |
72 | } else { | 61 | } else { |
73 | return false; | 62 | return false; |
@@ -76,13 +65,12 @@ bool tsc2100_read_touch(short *x, short* y, short *z1, short *z2) | |||
76 | 65 | ||
77 | bool tsc2100_read_volt(short *bat1, short *bat2, short *aux) | 66 | bool tsc2100_read_volt(short *bat1, short *bat2, short *aux) |
78 | { | 67 | { |
79 | if( (adc_status&(7<<4)) && TIME_BEFORE(adc_last_volt_read, adc_last_read)) { | 68 | if( adc_status&(7<<4) ) { |
80 | *bat1 = adc_data[5]; | 69 | *bat1 = adc_data[5]; |
81 | *bat2 = adc_data[6]; | 70 | *bat2 = adc_data[6]; |
82 | *aux = adc_data[7]; | 71 | *aux = adc_data[7]; |
83 | 72 | ||
84 | adc_status&=~(7<<4); | 73 | adc_status&=~(7<<4); |
85 | adc_last_volt_read=current_tick; | ||
86 | return true; | 74 | return true; |
87 | } else { | 75 | } else { |
88 | return false; | 76 | return false; |
@@ -110,7 +98,7 @@ void tsc2100_set_mode(bool poweron, unsigned char scan_mode) | |||
110 | void tsc2100_adc_init(void) | 98 | void tsc2100_adc_init(void) |
111 | { | 99 | { |
112 | /* Set the TSC2100 to read touchscreen */ | 100 | /* Set the TSC2100 to read touchscreen */ |
113 | tsc2100_set_mode(true, 0x01); | 101 | tsc2100_set_mode(true, 0x02); |
114 | 102 | ||
115 | tsc2100_writereg(TSSTAT_PAGE, TSSTAT_ADDRESS, | 103 | tsc2100_writereg(TSSTAT_PAGE, TSSTAT_ADDRESS, |
116 | (0x1<<TSSTAT_PINTDAV_SHIFT) /* Data available only */ | 104 | (0x1<<TSSTAT_PINTDAV_SHIFT) /* Data available only */ |
@@ -132,7 +120,6 @@ short tsc2100_readreg(int page, int address) | |||
132 | return (in[0]<<8)|in[1]; | 120 | return (in[0]<<8)|in[1]; |
133 | } | 121 | } |
134 | 122 | ||
135 | |||
136 | void tsc2100_writereg(int page, int address, short value) | 123 | void tsc2100_writereg(int page, int address, short value) |
137 | { | 124 | { |
138 | unsigned short command = (page << 11)|(address << 5); | 125 | unsigned short command = (page << 11)|(address << 5); |