From d3d0b26421bea28acc3f844a5b630d928083e9ec Mon Sep 17 00:00:00 2001 From: Karl Kurbjun Date: Thu, 15 Nov 2007 06:44:35 +0000 Subject: Work in progress fixes to the remote button handling. Now the remote can be unplugged and then plugged in and it will work. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15628 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/tms320dm320/debug-dm320.c | 12 +++- .../arm/tms320dm320/mrobe-500/button-mr500.c | 66 ++++++++++++---------- firmware/target/arm/tms320dm320/uart-dm320.c | 55 +++++++++++------- firmware/target/arm/tms320dm320/uart-target.h | 7 +-- 4 files changed, 82 insertions(+), 58 deletions(-) (limited to 'firmware/target/arm') diff --git a/firmware/target/arm/tms320dm320/debug-dm320.c b/firmware/target/arm/tms320dm320/debug-dm320.c index e12d86a03d..1a987b4dda 100755 --- a/firmware/target/arm/tms320dm320/debug-dm320.c +++ b/firmware/target/arm/tms320dm320/debug-dm320.c @@ -33,20 +33,22 @@ bool __dbg_ports(void) return false; } +extern char r_buffer[5]; +extern int r_button; bool __dbg_hw_info(void) { int line = 0, button, oldline; int *address=0x0; bool done=false; char buf[100]; - + lcd_setmargins(0, 0); lcd_setfont(FONT_SYSFIXED); lcd_clear_display(); - + /* Put all the static text befor the while loop */ lcd_puts(0, line++, "[Hardware info]"); - + lcd_puts(0, line++, "Clock info:"); snprintf(buf, sizeof(buf), "IO_CLK_PLLA: 0x%04x IO_CLK_PLLB: 0x%04x IO_CLK_SEL0: 0x%04x IO_CLK_SEL1: 0x%04x", IO_CLK_PLLA, IO_CLK_PLLB, IO_CLK_SEL0, IO_CLK_SEL1); lcd_puts(0, line++, buf); @@ -75,6 +77,10 @@ bool __dbg_hw_info(void) else if (button==BUTTON_RC_REW) address-=0x800; + snprintf(buf, sizeof(buf), "Buffer: 0x%02x%02x%02x%02x%02x", + r_buffer[0], r_buffer[1], r_buffer[2], r_buffer[3],r_buffer[4] ); lcd_puts(0, line++, buf); + snprintf(buf, sizeof(buf), "Button: 0x%08x, HWread: 0x%08x", + (unsigned int)button, r_button); lcd_puts(0, line++, buf); snprintf(buf, sizeof(buf), "current tick: %08x Seconds running: %08d", (unsigned int)current_tick, (unsigned int)current_tick/100); lcd_puts(0, line++, buf); snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x", diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c index 8d719eca81..0eb1c07e74 100644 --- a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c +++ b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c @@ -41,11 +41,7 @@ static short last_x, last_y, last_z1, last_z2; /* for the touch screen */ static bool touch_available = false; static struct touch_calibration_point topleft, bottomright; -static bool using_calibration = false; -void use_calibration(bool enable) -{ - using_calibration = enable; -} + /* Jd's tests.. These will hopefully work for everyone so we dont have to * create a calibration screen. * Portait: @@ -55,12 +51,6 @@ void use_calibration(bool enable) * (0,0) = 200, 270 * (640,480) = 3880, 3900 */ -void set_calibration_points(struct touch_calibration_point *tl, - struct touch_calibration_point *br) -{ - memcpy(&topleft, tl, sizeof(struct touch_calibration_point)); - memcpy(&bottomright, br, sizeof(struct touch_calibration_point)); -} static int touch_to_pixels(short val_x, short val_y) { @@ -74,16 +64,20 @@ static int touch_to_pixels(short val_x, short val_y) y=val_x; #endif - if (!using_calibration) - return (val_x<<16)|val_y; - x = (x-topleft.val_x)*(bottomright.px_x - topleft.px_x) / (bottomright.val_x - topleft.val_x) + topleft.px_x; y = (y-topleft.val_y)*(bottomright.px_y - topleft.px_y) / (bottomright.val_y - topleft.val_y) + topleft.px_y; if (x < 0) x = 0; + else if (x>=LCD_WIDTH) + x=LCD_WIDTH-1; + if (y < 0) y = 0; + else if (y>=LCD_HEIGHT) + y=LCD_HEIGHT-1; + + return (x<<16)|y; } @@ -107,14 +101,12 @@ void button_init_device(void) bottomright.val_y = 3880; #endif - topleft.px_x = 0; + topleft.px_x = 0; topleft.px_y = 0; - - bottomright.px_x = LCD_WIDTH; + + bottomright.px_x = LCD_WIDTH; bottomright.px_y = LCD_HEIGHT; - using_calibration = true; - /* Enable the touchscreen interrupt */ IO_INTC_EINT2 |= (1<<3); /* IRQ_GIO14 */ #if 0 @@ -136,15 +128,18 @@ inline bool button_hold(void) static void remote_heartbeat(void) { char data[5] = {0x11, 0x30, 0x11^0x30, 0x11+0x30, '\0'}; - uart1_puts(data); + uart1_puts(data, 5); } #define TOUCH_MARGIN 8 +char r_buffer[5]; +int r_button = BUTTON_NONE; int button_read_device(int *data) { - char buffer[5]; - int button = BUTTON_NONE, retval; + int retval, calbuf; static int oldbutton = BUTTON_NONE; + + r_button=BUTTON_NONE; *data = 0; if (touch_available) @@ -170,7 +165,7 @@ int button_read_device(int *data) last_x = x; last_y = y; *data = touch_to_pixels(x, y); - button |= BUTTON_TOUCHPAD; + r_button |= BUTTON_TOUCHPAD; } last_touch = current_tick; touch_available = false; @@ -178,23 +173,34 @@ int button_read_device(int *data) remote_heartbeat(); if ((IO_GIO_BITSET0&0x01) == 0) - button |= BUTTON_POWER; + { + r_button |= BUTTON_POWER; + oldbutton=r_button; + } - retval=uart1_gets_queue(buffer, 5); + retval=uart1_gets_queue(r_buffer, 5); do { + for(calbuf=0;calbuf<4;calbuf++) + { + if((r_buffer[calbuf]&0xF0)==0xF0 && (r_buffer[calbuf+1]&0xF0)!=0xF0) + break; + } + calbuf++; + if(calbuf==5) + calbuf=0; if(retval>=0) { - button |= buffer[1]; - oldbutton=button; + r_button |= r_buffer[calbuf]; + oldbutton=r_button; } else { - button=oldbutton; + r_button=oldbutton; } - } while((retval=uart1_gets_queue(buffer, 5))>=5); + } while((retval=uart1_gets_queue(r_buffer, 5))>=5); - return button; + return r_button; } /* Touchpad data available interupt */ diff --git a/firmware/target/arm/tms320dm320/uart-dm320.c b/firmware/target/arm/tms320dm320/uart-dm320.c index 5671e47a9f..151ad2921c 100644 --- a/firmware/target/arm/tms320dm320/uart-dm320.c +++ b/firmware/target/arm/tms320dm320/uart-dm320.c @@ -62,39 +62,53 @@ void uart1_putc(char ch) IO_UART1_DTRR=ch; } -void uart1_puts(const char *str) +void uart1_puts(const char *str, int size) { - char ch; - while ((ch = *str++) != '\0') { - uart1_putc(ch); + int count=0; + while (count