diff options
Diffstat (limited to 'firmware/target/arm')
-rw-r--r-- | firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c | 39 |
1 files changed, 38 insertions, 1 deletions
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 @@ * ****************************************************************************/ +/* 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<<TSADC_ADSCM_SHIFT)| /* scan x,y,z1,z2 */ + (0x1<<TSADC_RESOL_SHIFT) /* 8 bit resolution */ + ); + /* doesnt work for some reason... + setting to 8bit would probably be better than the 12bit currently */ +#endif } inline bool button_hold(void) { return false; } +#ifdef BOOTLOADER +int button_get_last_touch(void) +{ + int ret_val = last_touch; + last_touch = 0; + return ret_val; +} +#endif int button_read_device(void) { @@ -51,6 +77,9 @@ int button_read_device(void) int i = 0; int btn = BUTTON_NONE; + if (last_touch) + btn |= BUTTON_TOUCHPAD; + if ((IO_GIO_BITSET0&0x01) == 0) btn |= BUTTON_POWER; @@ -94,3 +123,11 @@ int button_read_device(void) } return btn; } + +void GIO14(void) +{ + tsc2100_read_values(&last_x, &last_y, + &last_z1, &last_z2); + last_touch = (last_x<<16)|last_y; + IO_INTC_IRQ2 = (1<<3); +} |