summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorKarl Kurbjun <kkurbjun@gmail.com>2009-12-12 18:36:52 +0000
committerKarl Kurbjun <kkurbjun@gmail.com>2009-12-12 18:36:52 +0000
commite087751b107982eeaa001e92c2dd1f24f1af6809 (patch)
tree05b984cc09e7e268d1885d9ee06c7274fbc4b4e2 /firmware/drivers
parentde159ceb3d1b852ee97be15ae707056ec995bf2d (diff)
downloadrockbox-e087751b107982eeaa001e92c2dd1f24f1af6809.tar.gz
rockbox-e087751b107982eeaa001e92c2dd1f24f1af6809.zip
M:Robe 500: Fix FIQ's and make the audio DMA a FIQ, simplify the ADC code and make it more reliable. Fix ADC problems on initial boot.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23948 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/tsc2100.c19
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 */
29static short adc_data[10]; 29static short adc_data[10];
30static short adc_status; 30static short adc_status;
31static long adc_last_read=0;
32static long adc_last_touch_read=0;
33static long adc_last_volt_read=0;
34 31
35void tsc2100_read_data(void) 32void 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. */
55bool tsc2100_read_touch(short *x, short* y, short *z1, short *z2) 50bool 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
77bool tsc2100_read_volt(short *bat1, short *bat2, short *aux) 66bool 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)
110void tsc2100_adc_init(void) 98void 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
136void tsc2100_writereg(int page, int address, short value) 123void 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);