summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfirmware/target/arm/tms320dm320/debug-dm320.c52
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c98
2 files changed, 41 insertions, 109 deletions
diff --git a/firmware/target/arm/tms320dm320/debug-dm320.c b/firmware/target/arm/tms320dm320/debug-dm320.c
index 5dfe9bbae7..53acd3f655 100755
--- a/firmware/target/arm/tms320dm320/debug-dm320.c
+++ b/firmware/target/arm/tms320dm320/debug-dm320.c
@@ -35,58 +35,11 @@
35#include "tsc2100.h" 35#include "tsc2100.h"
36#endif 36#endif
37 37
38#if defined(PCM_TEST)
39/* Leaving this in for potential debugging for other targets */
40#include "pcm.h"
41#include "debug-target.h"
42#include "dsp-target.h"
43#include "dsp/ipc.h"
44#define ARM_BUFFER_SIZE (PCM_SIZE)
45
46static signed short *the_rover = (signed short *)0x1900000;
47static unsigned int index_rover = 0;
48
49void pcmtest_get_more(unsigned char** start, size_t* size)
50{
51 unsigned long sdem_addr;
52 sdem_addr = (unsigned long)the_rover + index_rover;
53
54 *start = (unsigned char*)(sdem_addr);
55 *size = ARM_BUFFER_SIZE;
56
57 index_rover += ARM_BUFFER_SIZE;
58 if (index_rover >= 4*1024*1024)
59 {
60 index_rover = 0;
61 }
62
63 DEBUGF("pcm_sdram at 0x%08lx, sdem_addr 0x%08lx",
64 (unsigned long)the_rover, (unsigned long)sdem_addr);
65}
66#endif
67
68bool __dbg_ports(void) 38bool __dbg_ports(void)
69{ 39{
70#if defined(PCM_TEST)
71 int fd;
72 int bytes;
73
74 fd = open("/test.raw", O_RDONLY);
75 bytes = read(fd, the_rover, 4*1024*1024);
76 close(fd);
77
78 DEBUGF("read %d rover bytes", bytes);
79
80 pcm_play_data(&pcmtest_get_more,(unsigned char*)the_rover, ARM_BUFFER_SIZE);
81#endif
82
83 return false; 40 return false;
84} 41}
85 42
86#ifndef CREATIVE_ZVx
87extern char r_buffer[5];
88extern int r_button;
89#endif
90bool __dbg_hw_info(void) 43bool __dbg_hw_info(void)
91{ 44{
92 int line = 0, oldline; 45 int line = 0, oldline;
@@ -171,11 +124,6 @@ bool __dbg_hw_info(void)
171 address+=0x800; 124 address+=0x800;
172 else if (button==BUTTON_RC_REW) 125 else if (button==BUTTON_RC_REW)
173 address-=0x800; 126 address-=0x800;
174
175 snprintf(buf, sizeof(buf), "Buffer: 0x%02x%02x%02x%02x%02x",
176 r_buffer[0], r_buffer[1], r_buffer[2], r_buffer[3],r_buffer[4] ); lcd_puts(0, line++, buf);
177 snprintf(buf, sizeof(buf), "Button: 0x%08x, HWread: 0x%08x",
178 (unsigned int)button, r_button); lcd_puts(0, line++, buf);
179#else 127#else
180 button = button_get(false); 128 button = button_get(false);
181 if(button & BUTTON_POWER) 129 if(button & BUTTON_POWER)
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
index daa53f794f..036f777340 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
@@ -35,12 +35,6 @@
35#include "string.h" 35#include "string.h"
36#include "touchscreen.h" 36#include "touchscreen.h"
37 37
38#define BUTTON_TIMEOUT 50
39
40#define BUTTON_START_BYTE 0xF0
41#define BUTTON_START_BYTE2 0xF4 /* not sure why, but sometimes you get F0 or F4, */
42 /* but always the same one for the session? */
43static short last_x, last_y, last_z1, last_z2; /* for the touch screen */
44static bool touch_available = false; 38static bool touch_available = false;
45static bool hold_button = false; 39static bool hold_button = false;
46 40
@@ -129,93 +123,83 @@ inline bool button_hold(void)
129 return hold_button; 123 return hold_button;
130} 124}
131 125
132#define TOUCH_MARGIN 8
133char r_buffer[5];
134int r_button = BUTTON_NONE;
135int button_read_device(int *data) 126int button_read_device(int *data)
136{ 127{
137 int retval, button1_location, button2_location; 128 char r_buffer[5];
129 int r_button = BUTTON_NONE;
130
138 static int oldbutton = BUTTON_NONE; 131 static int oldbutton = BUTTON_NONE;
139 static bool oldhold = false; 132 static bool oldhold = false;
140
141 static long last_touch = 0; 133 static long last_touch = 0;
142 134
143 r_button=BUTTON_NONE;
144 *data = 0; 135 *data = 0;
145 136
137 /* Handle touchscreen */
146 if (touch_available) 138 if (touch_available)
147 { 139 {
148 short x,y; 140 short x,y;
149 bool send_touch = false; 141 short last_z1, last_z2;
142
150 tsc2100_read_values(&x, &y, &last_z1, &last_z2); 143 tsc2100_read_values(&x, &y, &last_z1, &last_z2);
151 if (TIME_BEFORE(last_touch + HZ/5, current_tick)) 144
152 { 145 *data = touch_to_pixels(x, y);
153 if ((x > last_x + TOUCH_MARGIN) || 146 r_button |= touchscreen_to_pixels((*data&0xffff0000)>>16,
154 (x < last_x - TOUCH_MARGIN) || 147 *data&0x0000ffff, data);
155 (y > last_y + TOUCH_MARGIN) || 148 oldbutton = r_button;
156 (y < last_y - TOUCH_MARGIN)) 149
157 {
158 send_touch = true;
159 }
160 }
161 else
162 send_touch = true;
163 if (send_touch)
164 {
165 last_x = x;
166 last_y = y;
167 *data = touch_to_pixels(x, y);
168 r_button |= touchscreen_to_pixels((*data&0xffff0000)>>16,
169 *data&0x0000ffff, data);
170 oldbutton = r_button;
171 }
172 last_touch = current_tick;
173 touch_available = false; 150 touch_available = false;
151 last_touch=current_tick;
174 } 152 }
175 else 153 else
176 { 154 {
177 /* Touch hasn't happened in a while, clear the bits */ 155 /* Touch hasn't happened in a while, clear the bits */
178 if(last_touch+3>current_tick) 156 if(last_touch+3>current_tick)
179 {
180 oldbutton&=(0xFF); 157 oldbutton&=(0xFF);
181 }
182 } 158 }
183 159
160 /* Handle power button */
184 if ((IO_GIO_BITSET0&0x01) == 0) 161 if ((IO_GIO_BITSET0&0x01) == 0)
185 { 162 {
186 r_button |= BUTTON_POWER; 163 r_button |= BUTTON_POWER;
187 oldbutton=r_button; 164 oldbutton=r_button;
188 } 165 }
166 else
167 oldbutton&=~BUTTON_POWER;
189 168
190 retval=uart1_gets_queue(r_buffer, 5); 169 /* Handle remote buttons */
191 170 if(uart1_gets_queue(r_buffer, 5)>=0)
192 for(button1_location=0;button1_location<4;button1_location++)
193 { 171 {
194 if((r_buffer[button1_location]&0xF0)==0xF0 172 int button_location;
195 && (r_buffer[button1_location+1]&0xF0)!=0xF0)
196 break;
197 }
198 button1_location++;
199 if(button1_location==5)
200 button1_location=0;
201 173
202 if(button1_location==4) 174 for(button_location=0;button_location<4;button_location++)
203 button2_location=0; 175 {
204 else 176 if((r_buffer[button_location]&0xF0)==0xF0
205 button2_location=button1_location+1; 177 && (r_buffer[button_location+1]&0xF0)!=0xF0)
178 break;
179 }
180
181 if(button_location==4)
182 button_location=0;
183
184 button_location++;
185
186 r_button |= r_buffer[button_location];
187
188 /* Find the hold status location */
189 if(button_location==4)
190 button_location=0;
191 else
192 button_location++;
193
194 hold_button=((r_buffer[button_location]&0x80)?true:false);
206 195
207 if(retval>=0)
208 {
209 uart1_clear_queue(); 196 uart1_clear_queue();
210 r_button |= r_buffer[button1_location];
211 oldbutton=r_button; 197 oldbutton=r_button;
212 hold_button=((r_buffer[button2_location]&0x80)?true:false);
213 } 198 }
214 else 199 else
215 {
216 r_button=oldbutton; 200 r_button=oldbutton;
217 }
218 201
202 /* Take care of hold notices */
219#ifndef BOOTLOADER 203#ifndef BOOTLOADER
220 /* give BL notice if HB state chaged */ 204 /* give BL notice if HB state chaged */
221 if (hold_button != oldhold) 205 if (hold_button != oldhold)