diff options
author | Karl Kurbjun <kkurbjun@gmail.com> | 2007-11-10 22:12:54 +0000 |
---|---|---|
committer | Karl Kurbjun <kkurbjun@gmail.com> | 2007-11-10 22:12:54 +0000 |
commit | d3c0a7f1692fd0b367a915a8f3a7144aaebb44a7 (patch) | |
tree | 0c5335fd08dda6c0e33ac42ca4feb0184290af21 | |
parent | a5e4cc9e68640ed9ee82c02e7b9796c8511cfccf (diff) | |
download | rockbox-d3c0a7f1692fd0b367a915a8f3a7144aaebb44a7.tar.gz rockbox-d3c0a7f1692fd0b367a915a8f3a7144aaebb44a7.zip |
Change the way the UART recieves data and how buttons pressed are processed. Also move some of the debug menu into the target tree and allow rockblox to build when the screen is rotated.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15560 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/debug_menu.c | 46 | ||||
-rw-r--r-- | apps/plugins/rockblox.c | 18 | ||||
-rw-r--r-- | firmware/SOURCES | 1 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c | 56 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/mrobe-500/button-target.h | 20 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/uart-dm320.c | 120 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/uart-target.h | 1 |
7 files changed, 96 insertions, 166 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 918a969a95..576d01d336 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -88,6 +88,10 @@ | |||
88 | #endif | 88 | #endif |
89 | #include "hwcompat.h" | 89 | #include "hwcompat.h" |
90 | 90 | ||
91 | #if CONFIG_CPU == DM320 | ||
92 | #include "debug-target.h" | ||
93 | #endif | ||
94 | |||
91 | /*---------------------------------------------------*/ | 95 | /*---------------------------------------------------*/ |
92 | /* SPECIAL DEBUG STUFF */ | 96 | /* SPECIAL DEBUG STUFF */ |
93 | /*---------------------------------------------------*/ | 97 | /*---------------------------------------------------*/ |
@@ -656,45 +660,9 @@ static bool dbg_hw_info(void) | |||
656 | lcd_update(); | 660 | lcd_update(); |
657 | 661 | ||
658 | while (!(action_userabort(TIMEOUT_BLOCK))); | 662 | while (!(action_userabort(TIMEOUT_BLOCK))); |
659 | #elif CONFIG_CPU == DM320 | 663 | #else |
660 | int line = 0, button; | 664 | /* Define this function in your target tree */ |
661 | int *address=0x0; | 665 | return __dbg_hw_info(); |
662 | bool done=false; | ||
663 | char buf[100]; | ||
664 | |||
665 | lcd_setmargins(0, 0); | ||
666 | lcd_setfont(FONT_SYSFIXED); | ||
667 | lcd_clear_display(); | ||
668 | lcd_puts(0, line++, "[Hardware info]"); | ||
669 | |||
670 | while(!done) | ||
671 | { | ||
672 | button = button_get(false); | ||
673 | button&=~BUTTON_REPEAT; | ||
674 | if (button == BUTTON_POWER) | ||
675 | done=true; | ||
676 | if(button==BUTTON_RC_PLAY) | ||
677 | address+=0x01; | ||
678 | else if (button==BUTTON_RC_DOWN) | ||
679 | address-=0x01; | ||
680 | else if (button==BUTTON_RC_FF) | ||
681 | address+=0x800; | ||
682 | else if (button==BUTTON_RC_REW) | ||
683 | address-=0x800; | ||
684 | { | ||
685 | snprintf(buf, sizeof(buf), "current tick: %04x", (unsigned int)current_tick); | ||
686 | lcd_puts(0, line++, buf); | ||
687 | snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x", (unsigned int)address, *address); | ||
688 | lcd_puts(0, line++, buf); | ||
689 | snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x", (unsigned int)(address+1), *(address+1)); | ||
690 | lcd_puts(0, line++, buf); | ||
691 | snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x", (unsigned int)(address+2), *(address+2)); | ||
692 | lcd_puts(0, line++, buf); | ||
693 | line -= 4; | ||
694 | } | ||
695 | lcd_update(); | ||
696 | } | ||
697 | |||
698 | #endif /* CONFIG_CPU */ | 666 | #endif /* CONFIG_CPU */ |
699 | return false; | 667 | return false; |
700 | } | 668 | } |
diff --git a/apps/plugins/rockblox.c b/apps/plugins/rockblox.c index 45f3c4f14e..dc1b25e6ec 100644 --- a/apps/plugins/rockblox.c +++ b/apps/plugins/rockblox.c | |||
@@ -188,7 +188,23 @@ PLUGIN_HEADER | |||
188 | 188 | ||
189 | #define BOARD_HEIGHT 20 | 189 | #define BOARD_HEIGHT 20 |
190 | 190 | ||
191 | #if (LCD_WIDTH == 480) && (LCD_HEIGHT == 640) | 191 | #if (LCD_WIDTH == 640) && (LCD_HEIGHT == 480) |
192 | |||
193 | #define BLOCK_WIDTH 30 | ||
194 | #define BLOCK_HEIGHT 30 | ||
195 | #define BOARD_X 14 | ||
196 | #define BOARD_Y 2 | ||
197 | #define PREVIEW_X 342 | ||
198 | #define PREVIEW_Y 482 | ||
199 | #define LABEL_X 344 | ||
200 | #define SCORE_Y 58 | ||
201 | #define LEVEL_Y 142 | ||
202 | #define LINES_Y 218 | ||
203 | #define HIGH_LABEL_X 344 | ||
204 | #define HIGH_SCORE_Y 326 | ||
205 | #define HIGH_LEVEL_Y 344 | ||
206 | |||
207 | #elif (LCD_WIDTH == 480) && (LCD_HEIGHT == 640) | ||
192 | 208 | ||
193 | #define BLOCK_WIDTH 30 | 209 | #define BLOCK_WIDTH 30 |
194 | #define BLOCK_HEIGHT 30 | 210 | #define BLOCK_HEIGHT 30 |
diff --git a/firmware/SOURCES b/firmware/SOURCES index 24a6db9fa6..29e30804b5 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -647,6 +647,7 @@ target/arm/tms320dm320/mrobe-500/pcm-mr500.c | |||
647 | target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c | 647 | target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c |
648 | target/arm/tms320dm320/mrobe-500/power-mr500.c | 648 | target/arm/tms320dm320/mrobe-500/power-mr500.c |
649 | target/arm/tms320dm320/mrobe-500/usb-mr500.c | 649 | target/arm/tms320dm320/mrobe-500/usb-mr500.c |
650 | target/arm/tms320dm320/debug-dm320.c | ||
650 | target/arm/tms320dm320/i2c-dm320.c | 651 | target/arm/tms320dm320/i2c-dm320.c |
651 | target/arm/tms320dm320/kernel-dm320.c | 652 | target/arm/tms320dm320/kernel-dm320.c |
652 | target/arm/tms320dm320/spi-dm320.c | 653 | target/arm/tms320dm320/spi-dm320.c |
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c index 10587a485f..837677250f 100644 --- a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c +++ b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c | |||
@@ -113,13 +113,11 @@ static void remote_heartbeat(void) | |||
113 | #define TOUCH_MARGIN 8 | 113 | #define TOUCH_MARGIN 8 |
114 | int button_read_device(int *data) | 114 | int button_read_device(int *data) |
115 | { | 115 | { |
116 | char c; | 116 | char buffer[5]; |
117 | int i = 0; | 117 | int button = BUTTON_NONE, retval; |
118 | int btn = BUTTON_NONE; | 118 | static int oldbutton = BUTTON_NONE; |
119 | *data = 0; | 119 | *data = 0; |
120 | 120 | ||
121 | if ((IO_GIO_BITSET0&0x01) == 0) | ||
122 | btn |= BUTTON_POWER; | ||
123 | if (touch_available) | 121 | if (touch_available) |
124 | { | 122 | { |
125 | short x,y; | 123 | short x,y; |
@@ -143,47 +141,31 @@ int button_read_device(int *data) | |||
143 | last_x = x; | 141 | last_x = x; |
144 | last_y = y; | 142 | last_y = y; |
145 | *data = touch_to_pixels(x, y); | 143 | *data = touch_to_pixels(x, y); |
146 | btn |= BUTTON_TOUCHPAD; | 144 | button |= BUTTON_TOUCHPAD; |
147 | } | 145 | } |
148 | last_touch = current_tick; | 146 | last_touch = current_tick; |
149 | touch_available = false; | 147 | touch_available = false; |
150 | } | 148 | } |
151 | remote_heartbeat(); | 149 | remote_heartbeat(); |
152 | while (uart1_getch(&c)) | 150 | |
151 | if ((IO_GIO_BITSET0&0x01) == 0) | ||
152 | button |= BUTTON_POWER; | ||
153 | |||
154 | retval=uart1_gets_queue(buffer, 5); | ||
155 | do | ||
153 | { | 156 | { |
154 | if (i==0 && (c == BUTTON_START_BYTE || c == BUTTON_START_BYTE2) ) | 157 | if(retval>=0) |
155 | { | 158 | { |
156 | i++; | 159 | button |= buffer[1]; |
160 | oldbutton=button; | ||
157 | } | 161 | } |
158 | else if (i) | 162 | else |
159 | { | 163 | { |
160 | i++; | 164 | button=oldbutton; |
161 | if(i==2) | ||
162 | { | ||
163 | if (c& (1<<7)) | ||
164 | btn |= BUTTON_RC_HEART; | ||
165 | if (c& (1<<6)) | ||
166 | btn |= BUTTON_RC_MODE; | ||
167 | if (c& (1<<5)) | ||
168 | btn |= BUTTON_RC_VOL_DOWN; | ||
169 | if (c& (1<<4)) | ||
170 | btn |= BUTTON_RC_VOL_UP; | ||
171 | if (c& (1<<3)) | ||
172 | btn |= BUTTON_RC_REW; | ||
173 | if (c& (1<<2)) | ||
174 | btn |= BUTTON_RC_FF; | ||
175 | if (c& (1<<1)) | ||
176 | btn |= BUTTON_RC_DOWN; | ||
177 | if (c& (1<<0)) | ||
178 | btn |= BUTTON_RC_PLAY; | ||
179 | } | ||
180 | else if(i==5) | ||
181 | { | ||
182 | i=0; | ||
183 | } | ||
184 | } | 165 | } |
185 | } | 166 | } while((retval=uart1_gets_queue(buffer, 5))>=5); |
186 | return btn; | 167 | |
168 | return button; | ||
187 | } | 169 | } |
188 | 170 | ||
189 | /* Touchpad data available interupt */ | 171 | /* Touchpad data available interupt */ |
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-target.h b/firmware/target/arm/tms320dm320/mrobe-500/button-target.h index aa4768c05b..1f17f3f3c8 100644 --- a/firmware/target/arm/tms320dm320/mrobe-500/button-target.h +++ b/firmware/target/arm/tms320dm320/mrobe-500/button-target.h | |||
@@ -20,7 +20,6 @@ | |||
20 | #ifndef _BUTTON_TARGET_H_ | 20 | #ifndef _BUTTON_TARGET_H_ |
21 | #define _BUTTON_TARGET_H_ | 21 | #define _BUTTON_TARGET_H_ |
22 | 22 | ||
23 | #include <stdbool.h> | ||
24 | #include "config.h" | 23 | #include "config.h" |
25 | 24 | ||
26 | #define HAS_BUTTON_HOLD | 25 | #define HAS_BUTTON_HOLD |
@@ -37,22 +36,21 @@ struct touch_calibration_point { | |||
37 | }; | 36 | }; |
38 | void use_calibration(bool enable); | 37 | void use_calibration(bool enable); |
39 | 38 | ||
40 | /* m:robe 500 specific button codes */ | 39 | /* M:Robe 500 specific button codes */ |
41 | 40 | ||
42 | #define BUTTON_POWER 0x00000001 | 41 | #define BUTTON_POWER 0x00000100 |
43 | 42 | ||
44 | /* Remote control buttons */ | 43 | /* Remote control buttons */ |
45 | 44 | ||
46 | #define BUTTON_RC_HEART 0x00000002 | 45 | #define BUTTON_RC_PLAY 0x00000001 |
47 | #define BUTTON_RC_MODE 0x00000004 | 46 | #define BUTTON_RC_DOWN 0x00000002 |
48 | #define BUTTON_RC_VOL_DOWN 0x00000008 | 47 | #define BUTTON_RC_FF 0x00000004 |
48 | #define BUTTON_RC_REW 0x00000008 | ||
49 | #define BUTTON_RC_VOL_UP 0x00000010 | 49 | #define BUTTON_RC_VOL_UP 0x00000010 |
50 | #define BUTTON_RC_VOL_DOWN 0x00000020 | ||
51 | #define BUTTON_RC_MODE 0x00000040 | ||
52 | #define BUTTON_RC_HEART 0x00000080 | ||
50 | 53 | ||
51 | |||
52 | #define BUTTON_RC_PLAY 0x00000020 | ||
53 | #define BUTTON_RC_REW 0x00000040 | ||
54 | #define BUTTON_RC_FF 0x00000080 | ||
55 | #define BUTTON_RC_DOWN 0x00000100 | ||
56 | #define BUTTON_TOUCH 0x00000200 | 54 | #define BUTTON_TOUCH 0x00000200 |
57 | 55 | ||
58 | /* compatibility hacks */ | 56 | /* compatibility hacks */ |
diff --git a/firmware/target/arm/tms320dm320/uart-dm320.c b/firmware/target/arm/tms320dm320/uart-dm320.c index 38600e3c90..5671e47a9f 100644 --- a/firmware/target/arm/tms320dm320/uart-dm320.c +++ b/firmware/target/arm/tms320dm320/uart-dm320.c | |||
@@ -19,34 +19,25 @@ | |||
19 | #include "config.h" | 19 | #include "config.h" |
20 | #include "cpu.h" | 20 | #include "cpu.h" |
21 | #include "system.h" | 21 | #include "system.h" |
22 | #include "string.h" | ||
23 | #include "panic.h" | ||
22 | 24 | ||
23 | /* UART 0/1 */ | ||
24 | |||
25 | #define CONFIG_UART_BRSR 87 | ||
26 | #define MAX_UART_BUFFER 31 | 25 | #define MAX_UART_BUFFER 31 |
27 | static unsigned char uart1buffer[MAX_UART_BUFFER], uart1_send_buffer_ring[512]; | 26 | #define SEND_RING_SIZE 256 |
28 | int uart1_send_count=0,uart1_send_point=0; | 27 | #define RECIEVE_RING_SIZE 20 |
29 | int uart1read = 0, uart1write = 0, uart1count = 0; | ||
30 | 28 | ||
31 | /* | 29 | char |
32 | static void do_checksums(char *data, int len, char *xor, char *add) | 30 | // uart1_send_buffer_ring[SEND_RING_SIZE], |
33 | { | 31 | uart1_recieve_buffer_ring[RECIEVE_RING_SIZE]; |
34 | int i; | 32 | |
35 | *xor = data[0]; | 33 | //static unsigned int uart1_send_count, uart1_send_read, uart1_send_write; |
36 | *add = data[0]; | 34 | static unsigned int uart1_recieve_count, uart1_recieve_read, uart1_recieve_write; |
37 | for(i=1;i<len;i++) | ||
38 | { | ||
39 | *xor ^= data[i]; | ||
40 | *add += data[i]; | ||
41 | } | ||
42 | } | ||
43 | */ | ||
44 | 35 | ||
45 | void uart_init(void) | 36 | void uart_init(void) |
46 | { | 37 | { |
47 | // 8-N-1 | 38 | // 8-N-1 |
48 | IO_UART1_MSR=0x8000; | 39 | IO_UART1_MSR=0x8000; |
49 | IO_UART1_BRSR=CONFIG_UART_BRSR; | 40 | IO_UART1_BRSR=0x0057; |
50 | IO_UART1_RFCR = 0x8010; /* Trigger later */ | 41 | IO_UART1_RFCR = 0x8010; /* Trigger later */ |
51 | /* gio 27 is input, uart1 rx | 42 | /* gio 27 is input, uart1 rx |
52 | gio 28 is output, uart1 tx */ | 43 | gio 28 is output, uart1 tx */ |
@@ -54,10 +45,10 @@ void uart_init(void) | |||
54 | IO_GIO_DIR1 &= ~(1<<12); /* gio 28 */ | 45 | IO_GIO_DIR1 &= ~(1<<12); /* gio 28 */ |
55 | 46 | ||
56 | /* init the recieve buffer */ | 47 | /* init the recieve buffer */ |
57 | uart1read = 0; | 48 | uart1_recieve_count=0; |
58 | uart1write = 0; | 49 | uart1_recieve_read=0; |
59 | uart1count = 0; | 50 | uart1_recieve_write=0; |
60 | 51 | ||
61 | /* Enable the interrupt */ | 52 | /* Enable the interrupt */ |
62 | IO_INTC_EINT0 |= (1<<IRQ_UART1); | 53 | IO_INTC_EINT0 |= (1<<IRQ_UART1); |
63 | } | 54 | } |
@@ -71,18 +62,6 @@ void uart1_putc(char ch) | |||
71 | IO_UART1_DTRR=ch; | 62 | IO_UART1_DTRR=ch; |
72 | } | 63 | } |
73 | 64 | ||
74 | /* Unsigned integer to ASCII hexadecimal conversion */ | ||
75 | void uart1_putHex(unsigned int n) | ||
76 | { | ||
77 | unsigned int i; | ||
78 | |||
79 | for (i = 8; i != 0; i--) { | ||
80 | unsigned int digit = n >> 28; | ||
81 | uart1_putc(digit >= 10 ? digit - 10 + 'A' : digit + '0'); | ||
82 | n <<= 4; | ||
83 | } | ||
84 | } | ||
85 | |||
86 | void uart1_puts(const char *str) | 65 | void uart1_puts(const char *str) |
87 | { | 66 | { |
88 | char ch; | 67 | char ch; |
@@ -91,62 +70,47 @@ void uart1_puts(const char *str) | |||
91 | } | 70 | } |
92 | } | 71 | } |
93 | 72 | ||
94 | void uart1_gets(char *str, unsigned int size) | 73 | /* This function returns the number of bytes left in the queue after a read is done (negative if fail)*/ |
74 | int uart1_gets_queue(char *str, unsigned int size) | ||
95 | { | 75 | { |
96 | for (;;) { | 76 | if(uart1_recieve_count<size) |
97 | char ch; | 77 | return -uart1_recieve_count; |
98 | |||
99 | /* Wait for FIFO to contain something */ | ||
100 | while ((IO_UART1_RFCR & 0x3f) == 0); | ||
101 | |||
102 | /* Read character */ | ||
103 | ch = (char)IO_UART1_DTRR; | ||
104 | |||
105 | /* If CR, also echo LF, null-terminate, and return */ | ||
106 | if (ch == '\r') { | ||
107 | IO_UART1_DTRR='\n'; | ||
108 | if (size) { | ||
109 | *str++ = '\0'; | ||
110 | } | ||
111 | return; | ||
112 | } | ||
113 | |||
114 | /* Append to buffer */ | ||
115 | if (size) { | ||
116 | *str++ = ch; | ||
117 | --size; | ||
118 | } | ||
119 | } | ||
120 | } | ||
121 | 78 | ||
122 | bool uart1_getch(char *c) | 79 | if(uart1_recieve_read+size<RECIEVE_RING_SIZE) |
123 | { | ||
124 | if (uart1count > 0) | ||
125 | { | 80 | { |
126 | if(uart1read>MAX_UART_BUFFER) | 81 | memcpy(str,uart1_recieve_buffer_ring+uart1_recieve_read,size); |
127 | uart1read=0; | 82 | } |
128 | 83 | else | |
129 | *c = uart1buffer[uart1read++]; | 84 | { |
130 | uart1count--; | 85 | int tempcount=(RECIEVE_RING_SIZE-uart1_recieve_read); |
131 | return true; | 86 | memcpy(str,uart1_recieve_buffer_ring+uart1_recieve_read,tempcount); |
87 | memcpy(str+tempcount,uart1_recieve_buffer_ring,size-tempcount); | ||
132 | } | 88 | } |
133 | return false; | 89 | |
90 | uart1_recieve_count-=size; | ||
91 | |||
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 | |||
97 | return uart1_recieve_count; | ||
134 | } | 98 | } |
135 | 99 | ||
136 | /* UART1 receive intterupt handler */ | 100 | /* UART1 receive interupt handler */ |
137 | void UART1(void) | 101 | void UART1(void) |
138 | { | 102 | { |
139 | while (IO_UART1_RFCR & 0x3f) | 103 | while (IO_UART1_RFCR & 0x3f) |
140 | { | 104 | { |
141 | if (uart1count > MAX_UART_BUFFER) | 105 | if (uart1_recieve_count > RECIEVE_RING_SIZE) |
142 | panicf("UART1 buffer overflow"); | 106 | panicf("UART1 buffer overflow"); |
143 | else | 107 | else |
144 | { | 108 | { |
145 | if(uart1write>MAX_UART_BUFFER) | 109 | if(uart1_recieve_write==RECIEVE_RING_SIZE) |
146 | uart1write=0; | 110 | uart1_recieve_write=0; |
147 | 111 | ||
148 | uart1buffer[uart1write++] = IO_UART1_DTRR & 0xff; | 112 | uart1_recieve_buffer_ring[uart1_recieve_write++] = IO_UART1_DTRR & 0xff; |
149 | uart1count++; | 113 | uart1_recieve_count++; |
150 | } | 114 | } |
151 | } | 115 | } |
152 | 116 | ||
diff --git a/firmware/target/arm/tms320dm320/uart-target.h b/firmware/target/arm/tms320dm320/uart-target.h index 70210c9f52..e94dd9d31c 100644 --- a/firmware/target/arm/tms320dm320/uart-target.h +++ b/firmware/target/arm/tms320dm320/uart-target.h | |||
@@ -25,6 +25,7 @@ bool uart1_getch(char *c); | |||
25 | void uart1_heartbeat(void); | 25 | void uart1_heartbeat(void); |
26 | bool uart1_available(void); | 26 | bool uart1_available(void); |
27 | 27 | ||
28 | int uart1_gets_queue(char *, unsigned int); | ||
28 | void uart1_puts(const char *str); | 29 | void uart1_puts(const char *str); |
29 | void uart1_gets(char *str, unsigned int size); | 30 | void uart1_gets(char *str, unsigned int size); |
30 | int uart1_pollch(unsigned int ticks); | 31 | int uart1_pollch(unsigned int ticks); |