summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm')
-rwxr-xr-xfirmware/target/arm/tms320dm320/debug-dm320.c12
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c66
-rw-r--r--firmware/target/arm/tms320dm320/uart-dm320.c55
-rw-r--r--firmware/target/arm/tms320dm320/uart-target.h7
4 files changed, 82 insertions, 58 deletions
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)
33 return false; 33 return false;
34} 34}
35 35
36extern char r_buffer[5];
37extern int r_button;
36bool __dbg_hw_info(void) 38bool __dbg_hw_info(void)
37{ 39{
38 int line = 0, button, oldline; 40 int line = 0, button, oldline;
39 int *address=0x0; 41 int *address=0x0;
40 bool done=false; 42 bool done=false;
41 char buf[100]; 43 char buf[100];
42 44
43 lcd_setmargins(0, 0); 45 lcd_setmargins(0, 0);
44 lcd_setfont(FONT_SYSFIXED); 46 lcd_setfont(FONT_SYSFIXED);
45 lcd_clear_display(); 47 lcd_clear_display();
46 48
47 /* Put all the static text befor the while loop */ 49 /* Put all the static text befor the while loop */
48 lcd_puts(0, line++, "[Hardware info]"); 50 lcd_puts(0, line++, "[Hardware info]");
49 51
50 lcd_puts(0, line++, "Clock info:"); 52 lcd_puts(0, line++, "Clock info:");
51 snprintf(buf, sizeof(buf), "IO_CLK_PLLA: 0x%04x IO_CLK_PLLB: 0x%04x IO_CLK_SEL0: 0x%04x IO_CLK_SEL1: 0x%04x", 53 snprintf(buf, sizeof(buf), "IO_CLK_PLLA: 0x%04x IO_CLK_PLLB: 0x%04x IO_CLK_SEL0: 0x%04x IO_CLK_SEL1: 0x%04x",
52 IO_CLK_PLLA, IO_CLK_PLLB, IO_CLK_SEL0, IO_CLK_SEL1); lcd_puts(0, line++, buf); 54 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)
75 else if (button==BUTTON_RC_REW) 77 else if (button==BUTTON_RC_REW)
76 address-=0x800; 78 address-=0x800;
77 79
80 snprintf(buf, sizeof(buf), "Buffer: 0x%02x%02x%02x%02x%02x",
81 r_buffer[0], r_buffer[1], r_buffer[2], r_buffer[3],r_buffer[4] ); lcd_puts(0, line++, buf);
82 snprintf(buf, sizeof(buf), "Button: 0x%08x, HWread: 0x%08x",
83 (unsigned int)button, r_button); lcd_puts(0, line++, buf);
78 snprintf(buf, sizeof(buf), "current tick: %08x Seconds running: %08d", 84 snprintf(buf, sizeof(buf), "current tick: %08x Seconds running: %08d",
79 (unsigned int)current_tick, (unsigned int)current_tick/100); lcd_puts(0, line++, buf); 85 (unsigned int)current_tick, (unsigned int)current_tick/100); lcd_puts(0, line++, buf);
80 snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x", 86 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 */
41static bool touch_available = false; 41static bool touch_available = false;
42 42
43static struct touch_calibration_point topleft, bottomright; 43static struct touch_calibration_point topleft, bottomright;
44static bool using_calibration = false; 44
45void use_calibration(bool enable)
46{
47 using_calibration = enable;
48}
49/* Jd's tests.. These will hopefully work for everyone so we dont have to 45/* Jd's tests.. These will hopefully work for everyone so we dont have to
50 * create a calibration screen. 46 * create a calibration screen.
51 * Portait: 47 * Portait:
@@ -55,12 +51,6 @@ void use_calibration(bool enable)
55 * (0,0) = 200, 270 51 * (0,0) = 200, 270
56 * (640,480) = 3880, 3900 52 * (640,480) = 3880, 3900
57*/ 53*/
58void set_calibration_points(struct touch_calibration_point *tl,
59 struct touch_calibration_point *br)
60{
61 memcpy(&topleft, tl, sizeof(struct touch_calibration_point));
62 memcpy(&bottomright, br, sizeof(struct touch_calibration_point));
63}
64 54
65static int touch_to_pixels(short val_x, short val_y) 55static int touch_to_pixels(short val_x, short val_y)
66{ 56{
@@ -74,16 +64,20 @@ static int touch_to_pixels(short val_x, short val_y)
74 y=val_x; 64 y=val_x;
75#endif 65#endif
76 66
77 if (!using_calibration)
78 return (val_x<<16)|val_y;
79
80 x = (x-topleft.val_x)*(bottomright.px_x - topleft.px_x) / (bottomright.val_x - topleft.val_x) + topleft.px_x; 67 x = (x-topleft.val_x)*(bottomright.px_x - topleft.px_x) / (bottomright.val_x - topleft.val_x) + topleft.px_x;
81 y = (y-topleft.val_y)*(bottomright.px_y - topleft.px_y) / (bottomright.val_y - topleft.val_y) + topleft.px_y; 68 y = (y-topleft.val_y)*(bottomright.px_y - topleft.px_y) / (bottomright.val_y - topleft.val_y) + topleft.px_y;
82 69
83 if (x < 0) 70 if (x < 0)
84 x = 0; 71 x = 0;
72 else if (x>=LCD_WIDTH)
73 x=LCD_WIDTH-1;
74
85 if (y < 0) 75 if (y < 0)
86 y = 0; 76 y = 0;
77 else if (y>=LCD_HEIGHT)
78 y=LCD_HEIGHT-1;
79
80
87 return (x<<16)|y; 81 return (x<<16)|y;
88} 82}
89 83
@@ -107,14 +101,12 @@ void button_init_device(void)
107 bottomright.val_y = 3880; 101 bottomright.val_y = 3880;
108#endif 102#endif
109 103
110 topleft.px_x = 0; 104 topleft.px_x = 0;
111 topleft.px_y = 0; 105 topleft.px_y = 0;
112 106
113 bottomright.px_x = LCD_WIDTH; 107 bottomright.px_x = LCD_WIDTH;
114 bottomright.px_y = LCD_HEIGHT; 108 bottomright.px_y = LCD_HEIGHT;
115 109
116 using_calibration = true;
117
118 /* Enable the touchscreen interrupt */ 110 /* Enable the touchscreen interrupt */
119 IO_INTC_EINT2 |= (1<<3); /* IRQ_GIO14 */ 111 IO_INTC_EINT2 |= (1<<3); /* IRQ_GIO14 */
120#if 0 112#if 0
@@ -136,15 +128,18 @@ inline bool button_hold(void)
136static void remote_heartbeat(void) 128static void remote_heartbeat(void)
137{ 129{
138 char data[5] = {0x11, 0x30, 0x11^0x30, 0x11+0x30, '\0'}; 130 char data[5] = {0x11, 0x30, 0x11^0x30, 0x11+0x30, '\0'};
139 uart1_puts(data); 131 uart1_puts(data, 5);
140} 132}
141 133
142#define TOUCH_MARGIN 8 134#define TOUCH_MARGIN 8
135char r_buffer[5];
136int r_button = BUTTON_NONE;
143int button_read_device(int *data) 137int button_read_device(int *data)
144{ 138{
145 char buffer[5]; 139 int retval, calbuf;
146 int button = BUTTON_NONE, retval;
147 static int oldbutton = BUTTON_NONE; 140 static int oldbutton = BUTTON_NONE;
141
142 r_button=BUTTON_NONE;
148 *data = 0; 143 *data = 0;
149 144
150 if (touch_available) 145 if (touch_available)
@@ -170,7 +165,7 @@ int button_read_device(int *data)
170 last_x = x; 165 last_x = x;
171 last_y = y; 166 last_y = y;
172 *data = touch_to_pixels(x, y); 167 *data = touch_to_pixels(x, y);
173 button |= BUTTON_TOUCHPAD; 168 r_button |= BUTTON_TOUCHPAD;
174 } 169 }
175 last_touch = current_tick; 170 last_touch = current_tick;
176 touch_available = false; 171 touch_available = false;
@@ -178,23 +173,34 @@ int button_read_device(int *data)
178 remote_heartbeat(); 173 remote_heartbeat();
179 174
180 if ((IO_GIO_BITSET0&0x01) == 0) 175 if ((IO_GIO_BITSET0&0x01) == 0)
181 button |= BUTTON_POWER; 176 {
177 r_button |= BUTTON_POWER;
178 oldbutton=r_button;
179 }
182 180
183 retval=uart1_gets_queue(buffer, 5); 181 retval=uart1_gets_queue(r_buffer, 5);
184 do 182 do
185 { 183 {
184 for(calbuf=0;calbuf<4;calbuf++)
185 {
186 if((r_buffer[calbuf]&0xF0)==0xF0 && (r_buffer[calbuf+1]&0xF0)!=0xF0)
187 break;
188 }
189 calbuf++;
190 if(calbuf==5)
191 calbuf=0;
186 if(retval>=0) 192 if(retval>=0)
187 { 193 {
188 button |= buffer[1]; 194 r_button |= r_buffer[calbuf];
189 oldbutton=button; 195 oldbutton=r_button;
190 } 196 }
191 else 197 else
192 { 198 {
193 button=oldbutton; 199 r_button=oldbutton;
194 } 200 }
195 } while((retval=uart1_gets_queue(buffer, 5))>=5); 201 } while((retval=uart1_gets_queue(r_buffer, 5))>=5);
196 202
197 return button; 203 return r_button;
198} 204}
199 205
200/* Touchpad data available interupt */ 206/* 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)
62 IO_UART1_DTRR=ch; 62 IO_UART1_DTRR=ch;
63} 63}
64 64
65void uart1_puts(const char *str) 65void uart1_puts(const char *str, int size)
66{ 66{
67 char ch; 67 int count=0;
68 while ((ch = *str++) != '\0') { 68 while (count<size)
69 uart1_putc(ch); 69 {
70 uart1_putc(str[count]);
71 count++;
70 } 72 }
71} 73}
72 74
73/* This function returns the number of bytes left in the queue after a read is done (negative if fail)*/ 75/* This function returns the number of bytes left in the queue after a read is done (negative if fail)*/
74int uart1_gets_queue(char *str, unsigned int size) 76int uart1_gets_queue(char *str, unsigned int size)
75{ 77{
78 IO_INTC_EINT0 &= ~(1<<IRQ_UART1);
79 int retval;
80
76 if(uart1_recieve_count<size) 81 if(uart1_recieve_count<size)
77 return -uart1_recieve_count;
78
79 if(uart1_recieve_read+size<RECIEVE_RING_SIZE)
80 { 82 {
81 memcpy(str,uart1_recieve_buffer_ring+uart1_recieve_read,size); 83 retval= -1;
82 } 84 }
83 else 85 else
84 { 86 {
85 int tempcount=(RECIEVE_RING_SIZE-uart1_recieve_read); 87 if(uart1_recieve_read+size<RECIEVE_RING_SIZE)
86 memcpy(str,uart1_recieve_buffer_ring+uart1_recieve_read,tempcount); 88 {
87 memcpy(str+tempcount,uart1_recieve_buffer_ring,size-tempcount); 89 memcpy(str,uart1_recieve_buffer_ring+uart1_recieve_read,size);
90 }
91 else
92 {
93 int tempcount=(RECIEVE_RING_SIZE-uart1_recieve_read);
94 memcpy(str,uart1_recieve_buffer_ring+uart1_recieve_read,tempcount);
95 memcpy(str+tempcount,uart1_recieve_buffer_ring,size-tempcount);
96 }
97
98 uart1_recieve_count-=size;
99
100 if(uart1_recieve_read+size<RECIEVE_RING_SIZE)
101 uart1_recieve_read+=size;
102 else
103 uart1_recieve_read=size-(RECIEVE_RING_SIZE-uart1_recieve_read);
104
105 retval=uart1_recieve_count;
88 } 106 }
89 107
90 uart1_recieve_count-=size; 108 /* Enable the interrupt */
91 109 IO_INTC_EINT0 |= (1<<IRQ_UART1);
92 if(uart1_recieve_read+size<RECIEVE_RING_SIZE)
93 uart1_recieve_read+=size;
94 else
95 uart1_recieve_read=size-(RECIEVE_RING_SIZE-uart1_recieve_read);
96 110
97 return uart1_recieve_count; 111 return retval;
98} 112}
99 113
100/* UART1 receive interupt handler */ 114/* UART1 receive interupt handler */
@@ -109,7 +123,8 @@ void UART1(void)
109 if(uart1_recieve_write==RECIEVE_RING_SIZE) 123 if(uart1_recieve_write==RECIEVE_RING_SIZE)
110 uart1_recieve_write=0; 124 uart1_recieve_write=0;
111 125
112 uart1_recieve_buffer_ring[uart1_recieve_write++] = IO_UART1_DTRR & 0xff; 126 uart1_recieve_buffer_ring[uart1_recieve_write] = IO_UART1_DTRR & 0xff;
127 uart1_recieve_write++;
113 uart1_recieve_count++; 128 uart1_recieve_count++;
114 } 129 }
115 } 130 }
diff --git a/firmware/target/arm/tms320dm320/uart-target.h b/firmware/target/arm/tms320dm320/uart-target.h
index e94dd9d31c..68145b8358 100644
--- a/firmware/target/arm/tms320dm320/uart-target.h
+++ b/firmware/target/arm/tms320dm320/uart-target.h
@@ -21,15 +21,12 @@
21#define UART_H 21#define UART_H
22 22
23void uart_init(void); 23void uart_init(void);
24bool uart1_getch(char *c);
25void uart1_heartbeat(void);
26bool uart1_available(void); 24bool uart1_available(void);
27 25
28int uart1_gets_queue(char *, unsigned int); 26int uart1_gets_queue(char *, unsigned int);
29void uart1_puts(const char *str); 27void uart1_puts(const char *str, int size);
30void uart1_gets(char *str, unsigned int size); 28void uart1_gets(char *str, unsigned int size);
31int uart1_pollch(unsigned int ticks);
32void uart1_putc(char ch); 29void uart1_putc(char ch);
33void uart1_putHex(unsigned int n); 30
34 31
35#endif 32#endif