summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/config/xduoox3.h1
-rw-r--r--firmware/target/mips/ingenic_jz47xx/debug-jz4760.c103
-rw-r--r--firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c4
3 files changed, 107 insertions, 1 deletions
diff --git a/firmware/export/config/xduoox3.h b/firmware/export/config/xduoox3.h
index 6a7f33c842..d4d6f2ee2f 100644
--- a/firmware/export/config/xduoox3.h
+++ b/firmware/export/config/xduoox3.h
@@ -163,6 +163,7 @@
163 163
164/* enable these for the experimental usb stack */ 164/* enable these for the experimental usb stack */
165#define HAVE_USBSTACK 165#define HAVE_USBSTACK
166#define HAVE_BOOTLOADER_USB_MODE
166 167
167/* Connect by events, not by tick polling */ 168/* Connect by events, not by tick polling */
168#define USB_STATUS_BY_EVENT 169#define USB_STATUS_BY_EVENT
diff --git a/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c b/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c
index 848fa5343e..ffd9faaf60 100644
--- a/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c
+++ b/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c
@@ -169,3 +169,106 @@ bool dbg_hw_info(void)
169 } 169 }
170 return true; 170 return true;
171} 171}
172
173#define CFG_UART_BASE UART1_BASE /* Base of the UART channel */
174
175void serial_putc (const char c)
176{
177 volatile u8 *uart_lsr = (volatile u8 *)(CFG_UART_BASE + OFF_LSR);
178 volatile u8 *uart_tdr = (volatile u8 *)(CFG_UART_BASE + OFF_TDR);
179
180 if (c == '\n') serial_putc ('\r');
181
182 /* Wait for fifo to shift out some bytes */
183 while ( !((*uart_lsr & (UARTLSR_TDRQ | UARTLSR_TEMT)) == 0x60) );
184
185 *uart_tdr = (u8)c;
186}
187
188void serial_puts (const char *s)
189{
190 while (*s) {
191 serial_putc (*s++);
192 }
193}
194
195void serial_putsf(const char *format, ...)
196{
197 static char printfbuf[256];
198 int len;
199 unsigned char *ptr;
200 va_list ap;
201 va_start(ap, format);
202
203 ptr = printfbuf;
204 len = vsnprintf(ptr, sizeof(printfbuf), format, ap);
205 va_end(ap);
206 (void)len;
207
208 serial_puts(ptr);
209 serial_putc('\n');
210}
211
212void serial_put_hex(unsigned int d)
213{
214 char c[12];
215 int i;
216 for(i = 0; i < 8;i++)
217 {
218 c[i] = (d >> ((7 - i) * 4)) & 0xf;
219 if(c[i] < 10)
220 c[i] += 0x30;
221 else
222 c[i] += (0x41 - 10);
223 }
224 c[8] = '\n';
225 c[9] = 0;
226 serial_puts(c);
227
228}
229void serial_put_dec(unsigned int d)
230{
231 char c[16];
232 int i;
233 int j = 0;
234 int x = d;
235
236 while (x /= 10)
237 j++;
238
239 for (i = j; i >= 0; i--) {
240 c[i] = d % 10;
241 c[i] += 0x30;
242 d /= 10;
243 }
244 c[j + 1] = '\n';
245 c[j + 2] = 0;
246 serial_puts(c);
247}
248
249void serial_dump_data(unsigned char* data, int len)
250{
251 int i;
252 for(i=0; i<len; i++)
253 {
254 unsigned char a = ((*data)>>4) & 0xf;
255 if(a < 10)
256 a += 0x30;
257 else
258 a += (0x41 - 10);
259 serial_putc( a );
260
261 a = (*data) & 0xf;
262 if(a < 10)
263 a += 0x30;
264 else
265 a += (0x41 - 10);
266 serial_putc( a );
267
268 serial_putc( ' ' );
269
270 data++;
271 }
272
273 serial_putc( '\n' );
274}
diff --git a/firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c
index 16d5aab782..be02167a5d 100644
--- a/firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c
+++ b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/sadc-xduoo_x3.c
@@ -18,7 +18,7 @@
18 * KIND, either express or implied. 18 * KIND, either express or implied.
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22#include "config.h" 22#include "config.h"
23#include "system.h" 23#include "system.h"
24#include "cpu.h" 24#include "cpu.h"
@@ -86,11 +86,13 @@ bool button_hold(void)
86 86
87int button_read_device(void) 87int button_read_device(void)
88{ 88{
89#ifndef BOOTLOADER
89 static bool hold_button = false; 90 static bool hold_button = false;
90 bool hold_button_old; 91 bool hold_button_old;
91 92
92 hold_button_old = hold_button; 93 hold_button_old = hold_button;
93 hold_button = (__gpio_get_pin(PIN_BTN_HOLD) ? true : false); 94 hold_button = (__gpio_get_pin(PIN_BTN_HOLD) ? true : false);
95#endif
94 96
95 int btn = BUTTON_NONE; 97 int btn = BUTTON_NONE;
96 bool gpio_btn = (__gpio_get_pin(PIN_BTN_POWER) ? false : true); 98 bool gpio_btn = (__gpio_get_pin(PIN_BTN_POWER) ? false : true);