1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 by Dave Chapman
12 * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
14 * All files in this archive are subject to the GNU General Public License.
15 * See the file COPYING in the source tree root for full license agreement.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
37 #include "adc-target.h"
38 #include "backlight-target.h"
48 char version
[] = APPSVERSION
;
57 bool do_power_off
= false;
61 int* buf
= (int*)0x21000000; /* Unused DRAM */
77 lcd_setfont(FONT_SYSFIXED
);
91 rc
= disk_mount_all();
98 printf("opening test file...");
100 fd
= open("/test.bin", O_RDONLY
);
101 if (fd
< 0) panicf("could not open test file");
104 printf("Length: %x", len
);
106 lseek(fd
, 0, SEEK_SET
);
110 printf("testing contents...");
113 while (buf
[i
] == i
&& i
<(len
/4)) { i
++; }
117 printf("mismatch at %x [0x%x]", i
, buf
[i
]);
123 while (!button_read_device()) {};
124 while (button_read_device()) {};
128 while(!do_power_off
) {
130 printf("Hello World!");
132 button
= button_read_device();
134 /* Power-off if POWER button has been held for a long time
135 This loop is currently running at about 100 iterations/second
137 if (button
& POWEROFF_BUTTON
) {
139 if (power_count
> 200)
145 printf("Btn: 0x%08x",button
);
147 #if defined(COWON_D2)
148 printf("GPIOA: 0x%08x",GPIOA
);
149 printf("GPIOB: 0x%08x",GPIOB
);
150 printf("GPIOC: 0x%08x",GPIOC
);
151 printf("GPIOD: 0x%08x",GPIOD
);
152 printf("GPIOE: 0x%08x",GPIOE
);
154 for (i
= 0; i
<4; i
++)
156 printf("ADC%d: 0x%04x",i
,adc_read(i
));
159 /* TODO: Move this stuff out to a touchscreen driver and establish
160 how such a beast is going to work. Since it needs I2C read/write,
161 it can't easily go on an interrupt-based tick task. */
163 unsigned char buf
[] = { 0x2f, (0xE<<1) | 1, /* ADC start for X+Y */
166 i2c_write(0x10, buf
, 2);
167 i2c_readmem(0x10, 0x2e, buf
, 5);
168 x
= (buf
[2] << 2) | (buf
[3] & 3);
169 y
= (buf
[4] << 2) | ((buf
[3] & 0xC) >> 2);
170 printf("X: 0x%03x Y: 0x%03x",x
,y
);
172 x
= (x
*LCD_WIDTH
) / 1024;
173 y
= (y
*LCD_HEIGHT
) / 1024;
174 lcd_hline(x
-5, x
+5, y
);
175 lcd_vline(x
, y
-5, y
+5);
178 buf
[1] = (0xF<<1) | 1; /* ADC start for P1+P2 */
179 i2c_write(0x10, buf
, 2);
180 i2c_readmem(0x10, 0x2e, buf
, 5);
181 x
= (buf
[2] << 2) | (buf
[3] & 3);
182 y
= (buf
[4] << 2) | ((buf
[3] & 0xC) >> 2);
183 printf("P1: 0x%03x P2: 0x%03x",x
,y
);
188 printf("Count: %d",count
);
201 /* These functions are present in the firmware library, but we reimplement
202 them here because the originals do a lot more than we want */
203 void usb_acknowledge(void)
207 void usb_wait_for_disconnect(void)