display paths using the native delimiters on the main widget.
[Rockbox.git] / bootloader / telechips.c
blobf5669d0bbfc9c27a8e93afd1cf9cd391ba7e44ac
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
21 #include "config.h"
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <string.h>
26 #include "cpu.h"
27 #include "system.h"
28 #include "lcd.h"
29 #include "kernel.h"
30 #include "thread.h"
31 #include "ata.h"
32 #include "fat.h"
33 #include "disk.h"
34 #include "font.h"
35 #include "button.h"
36 #include "adc.h"
37 #include "adc-target.h"
38 #include "backlight-target.h"
39 #include "panic.h"
40 #include "power.h"
41 #include "file.h"
42 #include "common.h"
44 #if defined(COWON_D2)
45 #include "i2c.h"
46 #endif
48 char version[] = APPSVERSION;
50 extern int line;
52 void* main(void)
54 int button;
55 int power_count = 0;
56 int count = 0;
57 int i;
58 bool do_power_off = false;
60 system_init();
61 adc_init();
62 lcd_init();
63 font_init();
65 #if defined(COWON_D2)
66 lcd_enable(true);
67 #endif
69 _backlight_on();
71 #if defined(COWON_D2)
72 ata_init();
73 #endif
75 while(!do_power_off) {
76 line = 0;
77 printf("Hello World!");
79 button = button_read_device();
81 /* Power-off if POWER button has been held for a long time
82 This loop is currently running at about 100 iterations/second
84 if (button & POWEROFF_BUTTON) {
85 power_count++;
86 if (power_count > 200)
87 do_power_off = true;
88 } else {
89 power_count = 0;
92 printf("Btn: 0x%08x",button);
94 #if defined(COWON_D2)
95 printf("GPIOA: 0x%08x",GPIOA);
96 printf("GPIOB: 0x%08x",GPIOB);
97 printf("GPIOC: 0x%08x",GPIOC);
98 printf("GPIOD: 0x%08x",GPIOD);
99 printf("GPIOE: 0x%08x",GPIOE);
101 for (i = 0; i<4; i++)
103 printf("ADC%d: 0x%04x",i,adc_read(i));
106 /* TODO: Establish how the touchscreen driver is going to work.
107 Since it needs I2C read/write, it can't easily go on a tick task */
109 unsigned char buf[] = { 0x2f, (0xE<<1) | 1, /* ADC start for X+Y */
110 0, 0, 0 };
111 int x,y;
112 i2c_write(0x10, buf, 2);
113 i2c_readmem(0x10, 0x2e, buf, 5);
114 x = (buf[2] << 2) | (buf[3] & 3);
115 y = (buf[4] << 2) | ((buf[3] & 0xC) >> 2);
116 printf("X: 0x%03x Y: 0x%03x",x,y);
118 buf[0] = 0x2f;
119 buf[1] = (0xF<<1) | 1; /* ADC start for P1+P2 */
120 i2c_write(0x10, buf, 2);
121 i2c_readmem(0x10, 0x2e, buf, 5);
122 x = (buf[2] << 2) | (buf[3] & 3);
123 y = (buf[4] << 2) | ((buf[3] & 0xC) >> 2);
124 printf("P1: 0x%03x P2: 0x%03x",x,y);
126 #endif
128 count++;
129 printf("Count: %d",count);
132 lcd_clear_display();
133 line = 0;
134 printf("POWER-OFF");
136 #if defined(COWON_D2)
137 lcd_enable(false);
138 #endif
140 /* TODO: Power-off */
141 while(1);
143 return 0;
146 /* These functions are present in the firmware library, but we reimplement
147 them here because the originals do a lot more than we want */
148 void usb_acknowledge(void)
152 void usb_wait_for_disconnect(void)