diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2007-09-30 11:15:14 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2007-09-30 11:15:14 +0000 |
commit | e108964ec08f70a46e1db430288283d68a906c56 (patch) | |
tree | 22c789576822138974a2c171f7c648cc3a1d99b1 | |
parent | ef1c52fa4390075000db585e5833324b38329f40 (diff) | |
download | rockbox-e108964ec08f70a46e1db430288283d68a906c56.tar.gz rockbox-e108964ec08f70a46e1db430288283d68a906c56.zip |
IRQ driven touchpad driver, crude but working
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14914 a1c6a512-1295-4272-9138-f99709370657
-rwxr-xr-x | bootloader/mrobe500.c | 37 | ||||
-rw-r--r-- | firmware/export/button.h | 5 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c | 39 |
3 files changed, 61 insertions, 20 deletions
diff --git a/bootloader/mrobe500.c b/bootloader/mrobe500.c index ce1aa57224..b92096ada2 100755 --- a/bootloader/mrobe500.c +++ b/bootloader/mrobe500.c | |||
@@ -104,8 +104,6 @@ void main(void) | |||
104 | while(true) | 104 | while(true) |
105 | { | 105 | { |
106 | button = button_read_device(); | 106 | button = button_read_device(); |
107 | if (button) | ||
108 | printf("btn: %x", button); | ||
109 | if (button == BUTTON_POWER) | 107 | if (button == BUTTON_POWER) |
110 | { | 108 | { |
111 | printf("reset"); | 109 | printf("reset"); |
@@ -119,23 +117,28 @@ void main(void) | |||
119 | address+=0x1000; | 117 | address+=0x1000; |
120 | else if (button==BUTTON_RC_REW) | 118 | else if (button==BUTTON_RC_REW) |
121 | address-=0x1000; | 119 | address-=0x1000; |
122 | 120 | if (button&BUTTON_TOUCHPAD) | |
123 | // if ((IO_GIO_BITSET0&(1<<14) == 0) | ||
124 | { | 121 | { |
125 | short x,y,z1,z2, reg; | 122 | int touch = button_get_last_touch(); |
126 | extern int uart1count; | 123 | printf("x: %d, y: %d", (touch>>16), touch&0xffff); |
127 | tsc2100_read_values(&x, &y, &z1, &z2); | 124 | line--; |
128 | printf("x: %04x y: %04x z1: %04x z2: %04x", x, y, z1, z2); | ||
129 | printf("tsadc: %4x", tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS)&0xffff); | ||
130 | printf("current tick: %04x", current_tick); | ||
131 | printf("Address: 0x%08x Data: 0x%08x", address, *address); | ||
132 | printf("Address: 0x%08x Data: 0x%08x", address+1, *(address+1)); | ||
133 | printf("Address: 0x%08x Data: 0x%08x", address+2, *(address+2)); | ||
134 | printf("uart1count: %d", uart1count); | ||
135 | printf("%x %x", IO_UART1_RFCR & 0x3f, IO_UART1_DTRR & 0xff); | ||
136 | tsc2100_keyclick(); /* doesnt work :( */ | ||
137 | line -= 8; | ||
138 | } | 125 | } |
126 | // if ((IO_GIO_BITSET0&(1<<14) == 0) | ||
127 | // { | ||
128 | // short x,y,z1,z2, reg; | ||
129 | // extern int uart1count; | ||
130 | // tsc2100_read_values(&x, &y, &z1, &z2); | ||
131 | // printf("x: %04x y: %04x z1: %04x z2: %04x", x, y, z1, z2); | ||
132 | // printf("tsadc: %4x", tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS)&0xffff); | ||
133 | // printf("current tick: %04x", current_tick); | ||
134 | // printf("Address: 0x%08x Data: 0x%08x", address, *address); | ||
135 | // printf("Address: 0x%08x Data: 0x%08x", address+1, *(address+1)); | ||
136 | // printf("Address: 0x%08x Data: 0x%08x", address+2, *(address+2)); | ||
137 | // printf("uart1count: %d", uart1count); | ||
138 | // printf("%x %x", IO_UART1_RFCR & 0x3f, IO_UART1_DTRR & 0xff); | ||
139 | // tsc2100_keyclick(); /* doesnt work :( */ | ||
140 | // line -= 8; | ||
141 | // } | ||
139 | } | 142 | } |
140 | #endif | 143 | #endif |
141 | printf("ATA"); | 144 | printf("ATA"); |
diff --git a/firmware/export/button.h b/firmware/export/button.h index 8b8c966ddc..5322d814bf 100644 --- a/firmware/export/button.h +++ b/firmware/export/button.h | |||
@@ -57,7 +57,8 @@ int button_apply_acceleration(unsigned int data, unsigned int factor); | |||
57 | #define BUTTON_NONE 0x00000000 | 57 | #define BUTTON_NONE 0x00000000 |
58 | 58 | ||
59 | /* Button modifiers */ | 59 | /* Button modifiers */ |
60 | #define BUTTON_REL 0x02000000 | 60 | #define BUTTON_REL 0x02000000 |
61 | #define BUTTON_REPEAT 0x04000000 | 61 | #define BUTTON_REPEAT 0x04000000 |
62 | #define BUTTON_TOUCHPAD 0x08000000 | ||
62 | 63 | ||
63 | #endif /* _BUTTON_H_ */ | 64 | #endif /* _BUTTON_H_ */ |
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c index 1d0d2714a8..b57680afb4 100644 --- a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c +++ b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c | |||
@@ -17,6 +17,8 @@ | |||
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | 19 | ||
20 | /* this file also handles the touch screen driver interface */ | ||
21 | |||
20 | #include "config.h" | 22 | #include "config.h" |
21 | #include "cpu.h" | 23 | #include "cpu.h" |
22 | #include "system.h" | 24 | #include "system.h" |
@@ -27,23 +29,47 @@ | |||
27 | #include "system.h" | 29 | #include "system.h" |
28 | #include "backlight-target.h" | 30 | #include "backlight-target.h" |
29 | #include "uart-target.h" | 31 | #include "uart-target.h" |
32 | #include "tsc2100.h" | ||
30 | 33 | ||
31 | #define BUTTON_TIMEOUT 50 | 34 | #define BUTTON_TIMEOUT 50 |
32 | 35 | ||
33 | #define BUTTON_START_BYTE 0xF0 | 36 | #define BUTTON_START_BYTE 0xF0 |
34 | #define BUTTON_START_BYTE2 0xF4 /* not sure why, but sometimes you get F0 or F4, */ | 37 | #define BUTTON_START_BYTE2 0xF4 /* not sure why, but sometimes you get F0 or F4, */ |
35 | /* but always the same one for the session? */ | 38 | /* but always the same one for the session? */ |
36 | 39 | static short last_x, last_y, last_z1, last_z2; /* for the touch screen */ | |
40 | static int last_touch; | ||
37 | void button_init_device(void) | 41 | void button_init_device(void) |
38 | { | 42 | { |
43 | last_touch = 0; | ||
39 | /* GIO is the power button, set as input */ | 44 | /* GIO is the power button, set as input */ |
40 | IO_GIO_DIR0 |= 0x01; | 45 | IO_GIO_DIR0 |= 0x01; |
46 | |||
47 | |||
48 | /* Enable the touchscreen interrupt */ | ||
49 | IO_INTC_EINT2 |= (1<<3); /* IRQ_GIO14 */ | ||
50 | #if 0 | ||
51 | tsc2100_writereg(TSADC_PAGE, TSADC_ADDRESS, | ||
52 | TSADC_PSTCM| | ||
53 | (0x2<<TSADC_ADSCM_SHIFT)| /* scan x,y,z1,z2 */ | ||
54 | (0x1<<TSADC_RESOL_SHIFT) /* 8 bit resolution */ | ||
55 | ); | ||
56 | /* doesnt work for some reason... | ||
57 | setting to 8bit would probably be better than the 12bit currently */ | ||
58 | #endif | ||
41 | } | 59 | } |
42 | 60 | ||
43 | inline bool button_hold(void) | 61 | inline bool button_hold(void) |
44 | { | 62 | { |
45 | return false; | 63 | return false; |
46 | } | 64 | } |
65 | #ifdef BOOTLOADER | ||
66 | int button_get_last_touch(void) | ||
67 | { | ||
68 | int ret_val = last_touch; | ||
69 | last_touch = 0; | ||
70 | return ret_val; | ||
71 | } | ||
72 | #endif | ||
47 | 73 | ||
48 | int button_read_device(void) | 74 | int button_read_device(void) |
49 | { | 75 | { |
@@ -51,6 +77,9 @@ int button_read_device(void) | |||
51 | int i = 0; | 77 | int i = 0; |
52 | int btn = BUTTON_NONE; | 78 | int btn = BUTTON_NONE; |
53 | 79 | ||
80 | if (last_touch) | ||
81 | btn |= BUTTON_TOUCHPAD; | ||
82 | |||
54 | if ((IO_GIO_BITSET0&0x01) == 0) | 83 | if ((IO_GIO_BITSET0&0x01) == 0) |
55 | btn |= BUTTON_POWER; | 84 | btn |= BUTTON_POWER; |
56 | 85 | ||
@@ -94,3 +123,11 @@ int button_read_device(void) | |||
94 | } | 123 | } |
95 | return btn; | 124 | return btn; |
96 | } | 125 | } |
126 | |||
127 | void GIO14(void) | ||
128 | { | ||
129 | tsc2100_read_values(&last_x, &last_y, | ||
130 | &last_z1, &last_z2); | ||
131 | last_touch = (last_x<<16)|last_y; | ||
132 | IO_INTC_IRQ2 = (1<<3); | ||
133 | } | ||