Fix for FS#8082:
[Rockbox.git] / bootloader / telechips.c
blob83dad704dafb2d533deb02e6e3c0f8b94bb74955
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 char version[] = APPSVERSION;
46 extern int line;
48 void* main(void)
50 int button;
51 int power_count = 0;
52 int count = 0;
53 bool do_power_off = false;
55 system_init();
56 adc_init();
57 lcd_init();
58 font_init();
60 __backlight_on();
62 while(!do_power_off) {
63 line = 0;
64 printf("Hello World!");
66 button = button_read_device();
68 /* Power-off if POWER button has been held for a long time
69 This loop is currently running at about 100 iterations/second
71 if (button & BUTTON_POWERPLAY) {
72 power_count++;
73 if (power_count > 200)
74 do_power_off = true;
75 } else {
76 power_count = 0;
79 printf("Btn: 0x%08x",button);
81 count++;
82 printf("Count: %d",count);
85 lcd_clear_display();
86 line = 0;
87 printf("POWER-OFF");
89 /* TODO: Power-off */
90 while(1);
92 return 0;
95 /* These functions are present in the firmware library, but we reimplement
96 them here because the originals do a lot more than we want */
97 void usb_acknowledge(void)
101 void usb_wait_for_disconnect(void)