From e108964ec08f70a46e1db430288283d68a906c56 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Sun, 30 Sep 2007 11:15:14 +0000 Subject: IRQ driven touchpad driver, crude but working git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14914 a1c6a512-1295-4272-9138-f99709370657 --- bootloader/mrobe500.c | 37 ++++++++++---------- firmware/export/button.h | 5 +-- .../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 ce1aa57..b92096a 100755 --- a/bootloader/mrobe500.c +++ b/bootloader/mrobe500.c @@ -104,8 +104,6 @@ void main(void) while(true) { button = button_read_device(); - if (button) - printf("btn: %x", button); if (button == BUTTON_POWER) { printf("reset"); @@ -119,23 +117,28 @@ void main(void) address+=0x1000; else if (button==BUTTON_RC_REW) address-=0x1000; - - // if ((IO_GIO_BITSET0&(1<<14) == 0) + if (button&BUTTON_TOUCHPAD) { - short x,y,z1,z2, reg; - extern int uart1count; - tsc2100_read_values(&x, &y, &z1, &z2); - printf("x: %04x y: %04x z1: %04x z2: %04x", x, y, z1, z2); - printf("tsadc: %4x", tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS)&0xffff); - printf("current tick: %04x", current_tick); - printf("Address: 0x%08x Data: 0x%08x", address, *address); - printf("Address: 0x%08x Data: 0x%08x", address+1, *(address+1)); - printf("Address: 0x%08x Data: 0x%08x", address+2, *(address+2)); - printf("uart1count: %d", uart1count); - printf("%x %x", IO_UART1_RFCR & 0x3f, IO_UART1_DTRR & 0xff); - tsc2100_keyclick(); /* doesnt work :( */ - line -= 8; + int touch = button_get_last_touch(); + printf("x: %d, y: %d", (touch>>16), touch&0xffff); + line--; } +// if ((IO_GIO_BITSET0&(1<<14) == 0) +// { +// short x,y,z1,z2, reg; +// extern int uart1count; +// tsc2100_read_values(&x, &y, &z1, &z2); +// printf("x: %04x y: %04x z1: %04x z2: %04x", x, y, z1, z2); +// printf("tsadc: %4x", tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS)&0xffff); +// printf("current tick: %04x", current_tick); +// printf("Address: 0x%08x Data: 0x%08x", address, *address); +// printf("Address: 0x%08x Data: 0x%08x", address+1, *(address+1)); +// printf("Address: 0x%08x Data: 0x%08x", address+2, *(address+2)); +// printf("uart1count: %d", uart1count); +// printf("%x %x", IO_UART1_RFCR & 0x3f, IO_UART1_DTRR & 0xff); +// tsc2100_keyclick(); /* doesnt work :( */ +// line -= 8; +// } } #endif printf("ATA"); diff --git a/firmware/export/button.h b/firmware/export/button.h index 8b8c966..5322d81 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); #define BUTTON_NONE 0x00000000 /* Button modifiers */ -#define BUTTON_REL 0x02000000 -#define BUTTON_REPEAT 0x04000000 +#define BUTTON_REL 0x02000000 +#define BUTTON_REPEAT 0x04000000 +#define BUTTON_TOUCHPAD 0x08000000 #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 1d0d271..b57680a 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 @@ * ****************************************************************************/ +/* this file also handles the touch screen driver interface */ + #include "config.h" #include "cpu.h" #include "system.h" @@ -27,23 +29,47 @@ #include "system.h" #include "backlight-target.h" #include "uart-target.h" +#include "tsc2100.h" #define BUTTON_TIMEOUT 50 #define BUTTON_START_BYTE 0xF0 #define BUTTON_START_BYTE2 0xF4 /* not sure why, but sometimes you get F0 or F4, */ /* but always the same one for the session? */ - +static short last_x, last_y, last_z1, last_z2; /* for the touch screen */ +static int last_touch; void button_init_device(void) { + last_touch = 0; /* GIO is the power button, set as input */ IO_GIO_DIR0 |= 0x01; + + + /* Enable the touchscreen interrupt */ + IO_INTC_EINT2 |= (1<<3); /* IRQ_GIO14 */ +#if 0 + tsc2100_writereg(TSADC_PAGE, TSADC_ADDRESS, + TSADC_PSTCM| + (0x2<