Cleanup the C200 keymap a bit, fixes the time settings screen for now.
[Rockbox.git] / bootloader / mrobe500.c
blob50c2acb9bde32a1491ebc321db882b93e6c50fe9
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: $
10 * Copyright (C) 2007 by Karl Kurbjun
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "inttypes.h"
21 #include "string.h"
22 #include "cpu.h"
23 #include "system.h"
24 #include "lcd.h"
25 #include "kernel.h"
26 #include "thread.h"
27 #include "ata.h"
28 #include "fat.h"
29 #include "disk.h"
30 #include "font.h"
31 #include "adc.h"
32 #include "backlight.h"
33 #include "backlight-target.h"
34 #include "button.h"
35 #include "panic.h"
36 #include "power.h"
37 #include "file.h"
38 #include "common.h"
39 #include "rbunicode.h"
40 #include "usb.h"
41 #include "spi-target.h"
42 #include "uart-target.h"
44 void main(void)
46 unsigned char* loadbuffer;
47 int buffer_size;
48 int rc;
49 int(*kernel_entry)(void);
51 power_init();
52 system_init();
53 kernel_init();
54 adc_init();
55 button_init();
56 backlight_init();
57 uartSetup();
58 lcd_init();
59 font_init();
60 dm320_spi_init();
62 lcd_setfont(FONT_SYSFIXED);
64 /* Show debug messages if button is pressed */
65 // if(button_read_device())
66 verbose = true;
68 printf("Rockbox boot loader");
69 printf("Version %s", APPSVERSION);
71 usb_init();
73 #if 0
74 /* Enter USB mode without USB thread */
75 if(usb_detect())
77 const char msg[] = "Bootloader USB mode";
78 reset_screen();
79 lcd_putsxy( (LCD_WIDTH - (SYSFONT_WIDTH * strlen(msg))) / 2,
80 (LCD_HEIGHT - SYSFONT_HEIGHT) / 2, msg);
81 lcd_update();
83 ide_power_enable(true);
84 ata_enable(false);
85 sleep(HZ/20);
86 usb_enable(true);
88 while (usb_detect())
90 ata_spin(); /* Prevent the drive from spinning down */
91 sleep(HZ);
94 usb_enable(false);
96 reset_screen();
97 lcd_update();
99 #endif
101 printf("ATA");
103 outw(inw(IO_GIO_DIR1)&~(1<<10), IO_GIO_DIR1); // set GIO26 to output
104 while(true)
106 if (button_read_device() == BUTTON_POWER)
108 printf("reset");
109 outw(1<<10, IO_GIO_BITSET1);
112 // Read X, Y, Z1, Z2 touchscreen coordinates.
113 int page = 0, address = 0;
114 unsigned short command = 0x8000|(page << 11)|(address << 5);
115 unsigned char out[] = {command >> 8, command & 0xff};
116 unsigned char in[8];
117 dm320_spi_block_transfer(out, sizeof(out), in, sizeof(in));
119 printf("%02x%02x %02x%02x %02x%02x %02x%02x\n",
120 in[0], in[1],
121 in[2], in[3],
122 in[4], in[5],
123 in[6], in[7]);
125 #if 0
126 rc = ata_init();
127 if(rc)
129 reset_screen();
130 error(EATA, rc);
133 printf("disk");
134 disk_init();
136 printf("mount");
137 rc = disk_mount_all();
138 if (rc<=0)
140 error(EDISK,rc);
143 printf("Loading firmware");
145 loadbuffer = (unsigned char*) 0x00900000;
146 buffer_size = (unsigned char*)0x00100000 - loadbuffer;
148 rc = load_firmware(loadbuffer, BOOTFILE, buffer_size);
149 if(rc < 0)
150 error(EBOOTFILE, rc);
152 if (rc == EOK)
154 kernel_entry = (void*) loadbuffer;
155 rc = kernel_entry();
157 #endif