From dfa8ecbe609ca8ea194d08560a44fb9a92e94b4b Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Mon, 11 Jul 2005 14:01:45 +0000 Subject: iriver bootloader: enable backlight at boot, reset uda1380, warning when low battery, let the user try with USB when the ATA init fails git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7100 a1c6a512-1295-4272-9138-f99709370657 --- bootloader/main.c | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/bootloader/main.c b/bootloader/main.c index 22053d25d4..a7985cda40 100644 --- a/bootloader/main.c +++ b/bootloader/main.c @@ -183,6 +183,7 @@ void main(void) bool rc_on_button = false; bool on_button = false; int data; + int adc_battery, battery_voltage, batt_int, batt_frac; /* Read the buttons early */ @@ -197,6 +198,10 @@ void main(void) if ((data & 0x40) == 0) rc_on_button = true; + /* Backlight ON */ + or_l(0x00020000, &GPIO1_ENABLE); + or_l(0x00020000, &GPIO1_FUNCTION); + power_init(); system_init(); kernel_init(); @@ -206,6 +211,13 @@ void main(void) set_cpu_frequency(0); /* PLL off */ #endif + /* UDA1380 RESET */ + GPIO_OUT |= (1<<29); + GPIO_ENABLE |= (1<<29); + GPIO_FUNCTION |= (1<<29); + sleep(HZ/100); + GPIO_OUT &= ~(1<<29); + backlight_init(); set_irq_level(0); lcd_init(); @@ -215,8 +227,7 @@ void main(void) lcd_setfont(FONT_SYSFIXED); - snprintf(buf, 256, "Rockboot version 3"); - lcd_puts(0, line++, buf); + lcd_puts(0, line++, "Rockboot version CVS"); lcd_update(); sleep(HZ/50); /* Allow the button driver to check the buttons */ @@ -239,18 +250,34 @@ void main(void) power_off(); } + adc_battery = adc_read(ADC_BATTERY); + + battery_voltage = (adc_battery * BATTERY_SCALE_FACTOR) / 10000; + batt_int = battery_voltage / 100; + batt_frac = battery_voltage % 100; + + snprintf(buf, 32, "Batt: %d.%02dV", batt_int, batt_frac); + lcd_puts(0, line++, buf); + lcd_update(); + + if(battery_voltage <= 300) { + line++; + lcd_puts(0, line++, "WARNING! BATTERY LOW!!"); + lcd_update(); + sleep(HZ*2); + } + rc = ata_init(); if(rc) { -#ifdef HAVE_LCD_BITMAP char str[32]; lcd_clear_display(); snprintf(str, 31, "ATA error: %d", rc); - lcd_puts(0, 1, str); + lcd_puts(0, line++, str); + lcd_puts(0, line++, "Insert USB cable and press"); + lcd_puts(0, line++, "a button"); lcd_update(); while(!(button_get(true) & BUTTON_REL)); -#endif - panicf("ata: %d", rc); } /* A hack to enter USB mode without using the USB thread */ -- cgit v1.2.3