2002-05-16 12:53:40 +00:00
|
|
|
|
/***************************************************************************
|
|
|
|
|
* __________ __ ___.
|
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2002 by Bj<EFBFBD>rn Stenberg
|
|
|
|
|
*
|
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
|
*
|
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
|
* KIND, either express or implied.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
2002-05-17 19:50:37 +00:00
|
|
|
|
#include "ata.h"
|
|
|
|
|
#include "disk.h"
|
|
|
|
|
#include "fat.h"
|
|
|
|
|
#include "lcd.h"
|
2002-06-24 13:51:40 +00:00
|
|
|
|
#include "rtc.h"
|
2002-05-17 19:50:37 +00:00
|
|
|
|
#include "debug.h"
|
|
|
|
|
#include "led.h"
|
|
|
|
|
#include "kernel.h"
|
|
|
|
|
#include "button.h"
|
2002-05-16 12:53:40 +00:00
|
|
|
|
#include "tree.h"
|
2002-05-21 14:28:10 +00:00
|
|
|
|
#include "panic.h"
|
|
|
|
|
#include "menu.h"
|
2002-05-29 09:14:38 +00:00
|
|
|
|
#include "system.h"
|
2002-06-30 13:24:29 +00:00
|
|
|
|
#include "usb.h"
|
2002-08-06 10:52:51 +00:00
|
|
|
|
#include "powermgmt.h"
|
2002-06-30 20:25:37 +00:00
|
|
|
|
#include "adc.h"
|
2002-07-02 21:40:12 +00:00
|
|
|
|
#include "i2c.h"
|
2002-08-12 12:44:18 +00:00
|
|
|
|
#ifndef DEBUG
|
|
|
|
|
#include "serial.h"
|
|
|
|
|
#endif
|
2002-05-24 15:40:14 +00:00
|
|
|
|
#include "mpeg.h"
|
2002-05-24 15:51:39 +00:00
|
|
|
|
#include "main_menu.h"
|
2002-06-12 15:31:35 +00:00
|
|
|
|
#include "thread.h"
|
2002-06-20 08:59:54 +00:00
|
|
|
|
#include "settings.h"
|
2002-06-24 13:51:40 +00:00
|
|
|
|
#include "backlight.h"
|
2002-07-22 22:44:03 +00:00
|
|
|
|
#include "status.h"
|
2002-07-15 11:02:12 +00:00
|
|
|
|
#include "debug_menu.h"
|
2002-05-29 10:05:27 +00:00
|
|
|
|
#include "version.h"
|
2002-06-30 13:24:29 +00:00
|
|
|
|
#include "sprintf.h"
|
2002-09-12 13:33:59 +00:00
|
|
|
|
#include "font.h"
|
2002-09-25 11:42:10 +00:00
|
|
|
|
#include "language.h"
|
2002-10-08 15:42:40 +00:00
|
|
|
|
#include "wps-display.h"
|
2002-08-12 12:44:18 +00:00
|
|
|
|
|
2002-08-16 14:14:37 +00:00
|
|
|
|
char appsversion[]=APPSVERSION;
|
2002-05-29 10:05:27 +00:00
|
|
|
|
|
2002-06-12 15:31:35 +00:00
|
|
|
|
void init(void);
|
2002-06-10 12:42:23 +00:00
|
|
|
|
|
2002-05-21 14:28:10 +00:00
|
|
|
|
void app_main(void)
|
|
|
|
|
{
|
2002-06-10 12:42:23 +00:00
|
|
|
|
init();
|
2002-05-21 14:28:10 +00:00
|
|
|
|
browse_root();
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-10 12:42:23 +00:00
|
|
|
|
#ifdef SIMULATOR
|
|
|
|
|
|
2002-06-12 15:31:35 +00:00
|
|
|
|
void init(void)
|
2002-06-10 12:42:23 +00:00
|
|
|
|
{
|
|
|
|
|
init_threads();
|
|
|
|
|
lcd_init();
|
2002-10-28 19:52:22 +00:00
|
|
|
|
font_init();
|
2002-06-10 12:42:23 +00:00
|
|
|
|
show_logo();
|
2002-07-15 11:02:12 +00:00
|
|
|
|
settings_reset();
|
2002-08-13 17:16:09 +00:00
|
|
|
|
settings_load();
|
2002-06-10 12:42:23 +00:00
|
|
|
|
sleep(HZ/2);
|
2003-01-10 09:19:56 +00:00
|
|
|
|
mpeg_init( global_settings.volume,
|
|
|
|
|
global_settings.bass,
|
|
|
|
|
global_settings.treble,
|
|
|
|
|
global_settings.balance,
|
|
|
|
|
global_settings.loudness,
|
|
|
|
|
global_settings.bass_boost,
|
|
|
|
|
global_settings.avc );
|
2003-01-13 12:54:59 +00:00
|
|
|
|
while (button_get(false) != 0)
|
|
|
|
|
; /* Empty the keyboard buffer */
|
2002-06-10 12:42:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#else
|
2002-05-24 15:40:14 +00:00
|
|
|
|
|
|
|
|
|
/* defined in linker script */
|
|
|
|
|
extern int poolstart[];
|
|
|
|
|
extern int poolend[];
|
|
|
|
|
|
2002-06-12 18:00:32 +00:00
|
|
|
|
void init(void)
|
2002-05-17 19:50:37 +00:00
|
|
|
|
{
|
2002-07-15 15:06:45 +00:00
|
|
|
|
int rc, i;
|
2002-05-30 19:41:35 +00:00
|
|
|
|
struct partinfo* pinfo;
|
2002-05-24 15:40:14 +00:00
|
|
|
|
|
2002-05-29 09:14:38 +00:00
|
|
|
|
system_init();
|
2002-06-10 14:44:15 +00:00
|
|
|
|
kernel_init();
|
2002-06-20 08:59:54 +00:00
|
|
|
|
|
2002-07-15 11:02:12 +00:00
|
|
|
|
settings_reset();
|
2002-05-29 09:14:38 +00:00
|
|
|
|
|
2002-05-29 09:12:21 +00:00
|
|
|
|
lcd_init();
|
2002-05-24 15:40:14 +00:00
|
|
|
|
|
2002-09-20 08:07:51 +00:00
|
|
|
|
font_init();
|
2002-06-11 08:24:33 +00:00
|
|
|
|
show_logo();
|
|
|
|
|
|
2002-05-27 09:53:28 +00:00
|
|
|
|
#ifdef DEBUG
|
2002-05-17 19:50:37 +00:00
|
|
|
|
debug_init();
|
2002-08-12 12:44:18 +00:00
|
|
|
|
#else
|
|
|
|
|
serial_setup();
|
2002-05-27 09:53:28 +00:00
|
|
|
|
#endif
|
2002-05-17 19:50:37 +00:00
|
|
|
|
set_irq_level(0);
|
|
|
|
|
|
2002-07-02 21:40:12 +00:00
|
|
|
|
i2c_init();
|
2002-08-06 08:14:08 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_RTC
|
|
|
|
|
rtc_init();
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-06-30 20:25:37 +00:00
|
|
|
|
adc_init();
|
|
|
|
|
|
2002-06-30 13:24:29 +00:00
|
|
|
|
usb_init();
|
|
|
|
|
|
2002-07-02 17:59:10 +00:00
|
|
|
|
backlight_init();
|
|
|
|
|
|
|
|
|
|
button_init();
|
2002-05-17 19:50:37 +00:00
|
|
|
|
|
2002-07-02 17:59:10 +00:00
|
|
|
|
rc = ata_init();
|
2002-07-02 18:01:31 +00:00
|
|
|
|
if(rc)
|
2002-07-02 17:59:10 +00:00
|
|
|
|
{
|
2002-08-08 20:44:25 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-07-02 17:59:10 +00:00
|
|
|
|
char str[32];
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
snprintf(str, 31, "ATA error: %d", rc);
|
|
|
|
|
lcd_puts(0, 1, str);
|
|
|
|
|
lcd_puts(0, 3, "Press ON to debug");
|
|
|
|
|
lcd_update();
|
2002-07-15 11:02:12 +00:00
|
|
|
|
while(button_get(true) != BUTTON_ON);
|
2002-07-02 17:59:10 +00:00
|
|
|
|
dbg_ports();
|
|
|
|
|
#endif
|
|
|
|
|
panicf("ata: %d", rc);
|
|
|
|
|
}
|
2002-07-15 11:02:12 +00:00
|
|
|
|
|
2002-05-30 19:41:35 +00:00
|
|
|
|
pinfo = disk_init();
|
|
|
|
|
if (!pinfo)
|
|
|
|
|
panicf("disk: NULL");
|
2002-07-15 15:06:45 +00:00
|
|
|
|
|
|
|
|
|
for ( i=0; i<4; i++ ) {
|
2002-08-09 15:23:32 +00:00
|
|
|
|
if (!fat_mount(pinfo[i].start))
|
2002-07-15 18:52:35 +00:00
|
|
|
|
break;
|
2002-07-15 15:06:45 +00:00
|
|
|
|
}
|
|
|
|
|
if ( i==4 ) {
|
2002-07-15 19:55:32 +00:00
|
|
|
|
DEBUGF("No partition found, trying to mount sector 0.\n");
|
|
|
|
|
rc = fat_mount(0);
|
2002-10-10 12:01:58 +00:00
|
|
|
|
if(rc) {
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
lcd_puts(0,0,"No FAT32");
|
|
|
|
|
lcd_puts(0,1,"partition!");
|
|
|
|
|
lcd_update();
|
|
|
|
|
sleep(HZ);
|
|
|
|
|
while(1)
|
|
|
|
|
dbg_partitions();
|
|
|
|
|
}
|
2002-07-15 15:06:45 +00:00
|
|
|
|
}
|
2002-07-02 17:59:10 +00:00
|
|
|
|
|
2002-07-15 11:02:12 +00:00
|
|
|
|
settings_load();
|
|
|
|
|
|
2002-06-28 15:09:11 +00:00
|
|
|
|
mpeg_init( global_settings.volume,
|
|
|
|
|
global_settings.bass,
|
2002-07-22 16:39:17 +00:00
|
|
|
|
global_settings.treble,
|
2002-08-14 21:30:06 +00:00
|
|
|
|
global_settings.balance,
|
2002-07-22 16:39:17 +00:00
|
|
|
|
global_settings.loudness,
|
2002-07-25 15:55:22 +00:00
|
|
|
|
global_settings.bass_boost,
|
2003-02-14 01:49:50 +00:00
|
|
|
|
global_settings.avc,
|
|
|
|
|
global_settings.channel_config );
|
2002-06-30 13:24:29 +00:00
|
|
|
|
|
2002-07-22 22:44:03 +00:00
|
|
|
|
status_init();
|
2002-06-30 13:24:29 +00:00
|
|
|
|
usb_start_monitoring();
|
2002-08-06 10:52:51 +00:00
|
|
|
|
power_init();
|
2002-05-17 19:50:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-05-16 12:53:40 +00:00
|
|
|
|
int main(void)
|
|
|
|
|
{
|
2002-05-21 14:28:10 +00:00
|
|
|
|
app_main();
|
2002-05-17 19:50:37 +00:00
|
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
|
led(true); sleep(HZ/10);
|
|
|
|
|
led(false); sleep(HZ/10);
|
|
|
|
|
}
|
2002-05-16 12:53:40 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
2002-05-21 14:28:10 +00:00
|
|
|
|
#endif
|