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.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
2004-10-15 02:16:31 +00:00
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
#ifdef IRIVER_H100
|
|
|
|
|
#include "thread.h"
|
|
|
|
|
#include "cpu.h"
|
|
|
|
|
|
|
|
|
|
unsigned long test_thread_stack[0x1000];
|
|
|
|
|
|
|
|
|
|
void yield(void)
|
|
|
|
|
{
|
|
|
|
|
switch_thread();
|
|
|
|
|
wake_up_thread();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_thread(void)
|
|
|
|
|
{
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
GPIO1_OUT ^= 0x00020000;
|
|
|
|
|
yield();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
init_threads();
|
|
|
|
|
|
|
|
|
|
create_thread(test_thread, test_thread_stack,
|
|
|
|
|
sizeof(test_thread_stack), "Test thread");
|
|
|
|
|
|
|
|
|
|
GPIO1_FUNCTION |= 0x00020000;
|
|
|
|
|
GPIO1_ENABLE |= 0x00020000;
|
|
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
|
for(i = 0;i < 10000;i++) {}
|
|
|
|
|
yield();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#else
|
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"
|
2004-01-05 20:42:51 +00:00
|
|
|
|
#include "mp3_playback.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"
|
2003-04-24 17:31:36 +00:00
|
|
|
|
#include "playlist.h"
|
2003-05-09 16:01:21 +00:00
|
|
|
|
#include "buffer.h"
|
2003-07-03 22:13:39 +00:00
|
|
|
|
#include "rolo.h"
|
2003-07-17 20:29:51 +00:00
|
|
|
|
#include "screens.h"
|
|
|
|
|
#include "power.h"
|
2004-03-14 21:33:53 +00:00
|
|
|
|
#include "talk.h"
|
2004-06-19 15:50:02 +00:00
|
|
|
|
#include "plugin.h"
|
|
|
|
|
|
|
|
|
|
/*#define AUTOROCK*/ /* define this to check for "autostart.rock" on boot */
|
2002-08-12 12:44:18 +00:00
|
|
|
|
|
2004-08-01 21:50:57 +00:00
|
|
|
|
const 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();
|
2003-05-09 16:01:21 +00:00
|
|
|
|
buffer_init();
|
2002-06-10 12:42:23 +00:00
|
|
|
|
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();
|
2004-09-28 18:09:10 +00:00
|
|
|
|
settings_calc_config_sector();
|
2004-06-19 15:50:02 +00:00
|
|
|
|
settings_load(SETTINGS_ALL);
|
|
|
|
|
settings_apply();
|
2002-06-10 12:42:23 +00:00
|
|
|
|
sleep(HZ/2);
|
2003-05-14 06:38:17 +00:00
|
|
|
|
tree_init();
|
2003-05-17 22:25:52 +00:00
|
|
|
|
playlist_init();
|
2004-01-05 20:42:51 +00:00
|
|
|
|
mp3_init( global_settings.volume,
|
|
|
|
|
global_settings.bass,
|
|
|
|
|
global_settings.treble,
|
|
|
|
|
global_settings.balance,
|
|
|
|
|
global_settings.loudness,
|
|
|
|
|
global_settings.avc,
|
2004-07-06 12:17:14 +00:00
|
|
|
|
global_settings.channel_config,
|
|
|
|
|
global_settings.mdb_strength,
|
|
|
|
|
global_settings.mdb_harmonics,
|
|
|
|
|
global_settings.mdb_center,
|
|
|
|
|
global_settings.mdb_shape,
|
|
|
|
|
global_settings.mdb_enable,
|
|
|
|
|
global_settings.superbass);
|
2004-01-05 20:42:51 +00:00
|
|
|
|
mpeg_init();
|
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
|
|
|
|
|
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;
|
2003-07-17 20:29:51 +00:00
|
|
|
|
/* if nobody initialized ATA before, I consider this a cold start */
|
|
|
|
|
bool coldstart = (PACR2 & 0x4000) != 0; /* starting from Flash */
|
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
|
|
|
|
|
2003-05-09 16:01:21 +00:00
|
|
|
|
buffer_init();
|
|
|
|
|
|
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();
|
|
|
|
|
|
2003-02-14 09:44:34 +00:00
|
|
|
|
set_irq_level(0);
|
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
|
2004-09-20 22:15:35 +00:00
|
|
|
|
#ifndef HAVE_MMC /* FIXME: This is also necessary for debug builds
|
|
|
|
|
* (do debug builds on the Ondio make sense?) */
|
2002-08-12 12:44:18 +00:00
|
|
|
|
serial_setup();
|
2004-09-20 22:15:35 +00:00
|
|
|
|
#endif
|
2002-05-27 09:53:28 +00:00
|
|
|
|
#endif
|
2002-05-17 19:50:37 +00:00
|
|
|
|
|
2002-07-02 21:40:12 +00:00
|
|
|
|
i2c_init();
|
2002-08-06 08:14:08 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_RTC
|
|
|
|
|
rtc_init();
|
2004-06-19 15:50:02 +00:00
|
|
|
|
settings_load(SETTINGS_RTC); /* early load parts of global_settings */
|
2002-08-06 08:14:08 +00:00
|
|
|
|
#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
|
|
|
|
|
2003-08-25 08:57:49 +00:00
|
|
|
|
powermgmt_init();
|
2003-07-18 21:58:28 +00:00
|
|
|
|
|
2004-10-10 01:25:32 +00:00
|
|
|
|
#ifdef HAVE_CHARGING
|
2004-06-19 15:50:02 +00:00
|
|
|
|
if (coldstart && charger_inserted() && !global_settings.car_adapter_mode)
|
2003-07-17 20:29:51 +00:00
|
|
|
|
{
|
|
|
|
|
rc = charging_screen(); /* display a "charging" screen */
|
|
|
|
|
if (rc == 1 || rc == 2) /* charger removed or "Off/Stop" pressed */
|
|
|
|
|
power_off();
|
|
|
|
|
/* "On" pressed or USB connected: proceed */
|
|
|
|
|
}
|
2003-12-15 11:45:14 +00:00
|
|
|
|
#else
|
|
|
|
|
(void)coldstart;
|
2003-12-12 13:34:27 +00:00
|
|
|
|
#endif
|
2003-07-03 22:13:39 +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();
|
2004-09-19 21:58:37 +00:00
|
|
|
|
while(!(button_get(true) & BUTTON_REL));
|
2002-07-02 17:59:10 +00:00
|
|
|
|
dbg_ports();
|
|
|
|
|
#endif
|
|
|
|
|
panicf("ata: %d", rc);
|
|
|
|
|
}
|
2004-09-20 22:15:35 +00:00
|
|
|
|
|
2004-05-21 21:49:04 +00:00
|
|
|
|
usb_start_monitoring();
|
|
|
|
|
|
2002-05-30 19:41:35 +00:00
|
|
|
|
pinfo = disk_init();
|
|
|
|
|
if (!pinfo)
|
2004-07-05 22:13:20 +00:00
|
|
|
|
{
|
|
|
|
|
lcd_clear_display();
|
|
|
|
|
lcd_puts(0, 0, "No partition");
|
|
|
|
|
lcd_puts(0, 1, "table.");
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
lcd_puts(0, 2, "Insert USB cable");
|
|
|
|
|
lcd_puts(0, 3, "and fix it.");
|
|
|
|
|
lcd_update();
|
|
|
|
|
#endif
|
|
|
|
|
while(button_get(true) != SYS_USB_CONNECTED) {};
|
|
|
|
|
usb_screen();
|
|
|
|
|
system_reboot();
|
|
|
|
|
}
|
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
|
|
|
|
}
|
2004-03-25 12:29:34 +00:00
|
|
|
|
|
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);
|
2004-03-25 12:29:34 +00:00
|
|
|
|
/* Don't leave until we have been in USB mode */
|
|
|
|
|
while(!dbg_partitions());
|
|
|
|
|
|
|
|
|
|
/* The USB thread will panic if the drive still can't be mounted */
|
2002-10-10 12:01:58 +00:00
|
|
|
|
}
|
2002-07-15 15:06:45 +00:00
|
|
|
|
}
|
2003-07-03 22:13:39 +00:00
|
|
|
|
|
2004-09-28 18:09:10 +00:00
|
|
|
|
settings_calc_config_sector();
|
2004-06-19 15:50:02 +00:00
|
|
|
|
settings_load(SETTINGS_ALL);
|
|
|
|
|
settings_apply();
|
2004-09-28 18:09:10 +00:00
|
|
|
|
|
2003-05-09 16:01:21 +00:00
|
|
|
|
status_init();
|
2004-09-29 21:41:10 +00:00
|
|
|
|
playlist_init();
|
2003-05-09 16:01:21 +00:00
|
|
|
|
tree_init();
|
|
|
|
|
|
2003-05-17 20:38:38 +00:00
|
|
|
|
/* No buffer allocation (see buffer.c) may take place after the call to
|
|
|
|
|
mpeg_init() since the mpeg thread takes the rest of the buffer space */
|
2004-01-05 20:42:51 +00:00
|
|
|
|
mp3_init( global_settings.volume,
|
|
|
|
|
global_settings.bass,
|
|
|
|
|
global_settings.treble,
|
|
|
|
|
global_settings.balance,
|
|
|
|
|
global_settings.loudness,
|
|
|
|
|
global_settings.avc,
|
2004-07-06 12:17:14 +00:00
|
|
|
|
global_settings.channel_config,
|
|
|
|
|
global_settings.mdb_strength,
|
|
|
|
|
global_settings.mdb_harmonics,
|
|
|
|
|
global_settings.mdb_center,
|
|
|
|
|
global_settings.mdb_shape,
|
|
|
|
|
global_settings.mdb_enable,
|
|
|
|
|
global_settings.superbass);
|
2004-01-05 20:42:51 +00:00
|
|
|
|
mpeg_init();
|
2004-03-14 21:33:53 +00:00
|
|
|
|
talk_init();
|
2003-05-17 20:38:38 +00:00
|
|
|
|
|
2004-06-19 15:50:02 +00:00
|
|
|
|
#ifdef AUTOROCK
|
|
|
|
|
if (!usb_detect())
|
|
|
|
|
{
|
2003-07-03 22:13:39 +00:00
|
|
|
|
int fd;
|
2004-06-19 15:50:02 +00:00
|
|
|
|
static const char filename[] = PLUGIN_DIR "/autostart.rock";
|
|
|
|
|
|
2003-07-03 22:13:39 +00:00
|
|
|
|
fd = open(filename, O_RDONLY);
|
|
|
|
|
if(fd >= 0) /* no complaint if it doesn't exit */
|
|
|
|
|
{
|
|
|
|
|
close(fd);
|
2004-06-19 15:50:02 +00:00
|
|
|
|
plugin_load((char*)filename, NULL); /* start if it does */
|
2003-07-03 22:13:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2004-06-19 15:50:02 +00:00
|
|
|
|
#endif /* #ifdef AUTOROCK */
|
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
|
2004-10-15 02:16:31 +00:00
|
|
|
|
#endif
|