summaryrefslogtreecommitdiff
path: root/bootloader/telechips.c
diff options
context:
space:
mode:
Diffstat (limited to 'bootloader/telechips.c')
-rw-r--r--bootloader/telechips.c74
1 files changed, 69 insertions, 5 deletions
diff --git a/bootloader/telechips.c b/bootloader/telechips.c
index f5669d0bbf..1918465aa2 100644
--- a/bootloader/telechips.c
+++ b/bootloader/telechips.c
@@ -54,14 +54,29 @@ void* main(void)
54 int button; 54 int button;
55 int power_count = 0; 55 int power_count = 0;
56 int count = 0; 56 int count = 0;
57 int i;
58 bool do_power_off = false; 57 bool do_power_off = false;
58
59#if defined(COWON_D2)
60 int i,rc,fd,len;
61 int* buf = (int*)0x21000000; /* Unused DRAM */
62#endif
59 63
64 power_init();
65 lcd_init();
60 system_init(); 66 system_init();
67
68#if defined(COWON_D2)
69 kernel_init();
70#endif
71
61 adc_init(); 72 adc_init();
62 lcd_init(); 73 button_init();
74 backlight_init();
75
63 font_init(); 76 font_init();
64 77
78 lcd_setfont(FONT_SYSFIXED);
79
65#if defined(COWON_D2) 80#if defined(COWON_D2)
66 lcd_enable(true); 81 lcd_enable(true);
67#endif 82#endif
@@ -69,7 +84,50 @@ void* main(void)
69 _backlight_on(); 84 _backlight_on();
70 85
71#if defined(COWON_D2) 86#if defined(COWON_D2)
72 ata_init(); 87 printf("ATA");
88 rc = ata_init();
89 if(rc)
90 {
91 reset_screen();
92 error(EATA, rc);
93 }
94
95 printf("mount");
96 rc = disk_mount_all();
97 if (rc<=0)
98 {
99 error(EDISK,rc);
100 }
101
102#if 0
103 printf("opening test file...");
104
105 fd = open("/test.bin", O_RDONLY);
106 if (fd < 0) panicf("could not open test file");
107
108 len = filesize(fd);
109 printf("Length: %x", len);
110
111 lseek(fd, 0, SEEK_SET);
112 read(fd, buf, len);
113 close(fd);
114
115 printf("testing contents...");
116
117 i = 0;
118 while (buf[i] == i && i<(len/4)) { i++; }
119
120 if (i < len/4)
121 {
122 printf("mismatch at %x [0x%x]", i, buf[i]);
123 }
124 else
125 {
126 printf("passed!");
127 }
128 while (!button_read_device()) {};
129 while (button_read_device()) {};
130#endif
73#endif 131#endif
74 132
75 while(!do_power_off) { 133 while(!do_power_off) {
@@ -103,8 +161,9 @@ void* main(void)
103 printf("ADC%d: 0x%04x",i,adc_read(i)); 161 printf("ADC%d: 0x%04x",i,adc_read(i));
104 } 162 }
105 163
106 /* TODO: Establish how the touchscreen driver is going to work. 164 /* TODO: Move this stuff out to a touchscreen driver and establish
107 Since it needs I2C read/write, it can't easily go on a tick task */ 165 how such a beast is going to work. Since it needs I2C read/write,
166 it can't easily go on an interrupt-based tick task. */
108 { 167 {
109 unsigned char buf[] = { 0x2f, (0xE<<1) | 1, /* ADC start for X+Y */ 168 unsigned char buf[] = { 0x2f, (0xE<<1) | 1, /* ADC start for X+Y */
110 0, 0, 0 }; 169 0, 0, 0 };
@@ -115,6 +174,11 @@ void* main(void)
115 y = (buf[4] << 2) | ((buf[3] & 0xC) >> 2); 174 y = (buf[4] << 2) | ((buf[3] & 0xC) >> 2);
116 printf("X: 0x%03x Y: 0x%03x",x,y); 175 printf("X: 0x%03x Y: 0x%03x",x,y);
117 176
177 x = (x*LCD_WIDTH) / 1024;
178 y = (y*LCD_HEIGHT) / 1024;
179 lcd_hline(x-5, x+5, y);
180 lcd_vline(x, y-5, y+5);
181
118 buf[0] = 0x2f; 182 buf[0] = 0x2f;
119 buf[1] = (0xF<<1) | 1; /* ADC start for P1+P2 */ 183 buf[1] = (0xF<<1) | 1; /* ADC start for P1+P2 */
120 i2c_write(0x10, buf, 2); 184 i2c_write(0x10, buf, 2);