diff options
Diffstat (limited to 'bootloader/main.c')
-rw-r--r-- | bootloader/main.c | 39 |
1 files 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) | |||
183 | bool rc_on_button = false; | 183 | bool rc_on_button = false; |
184 | bool on_button = false; | 184 | bool on_button = false; |
185 | int data; | 185 | int data; |
186 | int adc_battery, battery_voltage, batt_int, batt_frac; | ||
186 | 187 | ||
187 | /* Read the buttons early */ | 188 | /* Read the buttons early */ |
188 | 189 | ||
@@ -197,6 +198,10 @@ void main(void) | |||
197 | if ((data & 0x40) == 0) | 198 | if ((data & 0x40) == 0) |
198 | rc_on_button = true; | 199 | rc_on_button = true; |
199 | 200 | ||
201 | /* Backlight ON */ | ||
202 | or_l(0x00020000, &GPIO1_ENABLE); | ||
203 | or_l(0x00020000, &GPIO1_FUNCTION); | ||
204 | |||
200 | power_init(); | 205 | power_init(); |
201 | system_init(); | 206 | system_init(); |
202 | kernel_init(); | 207 | kernel_init(); |
@@ -206,6 +211,13 @@ void main(void) | |||
206 | set_cpu_frequency(0); /* PLL off */ | 211 | set_cpu_frequency(0); /* PLL off */ |
207 | #endif | 212 | #endif |
208 | 213 | ||
214 | /* UDA1380 RESET */ | ||
215 | GPIO_OUT |= (1<<29); | ||
216 | GPIO_ENABLE |= (1<<29); | ||
217 | GPIO_FUNCTION |= (1<<29); | ||
218 | sleep(HZ/100); | ||
219 | GPIO_OUT &= ~(1<<29); | ||
220 | |||
209 | backlight_init(); | 221 | backlight_init(); |
210 | set_irq_level(0); | 222 | set_irq_level(0); |
211 | lcd_init(); | 223 | lcd_init(); |
@@ -215,8 +227,7 @@ void main(void) | |||
215 | 227 | ||
216 | lcd_setfont(FONT_SYSFIXED); | 228 | lcd_setfont(FONT_SYSFIXED); |
217 | 229 | ||
218 | snprintf(buf, 256, "Rockboot version 3"); | 230 | lcd_puts(0, line++, "Rockboot version CVS"); |
219 | lcd_puts(0, line++, buf); | ||
220 | lcd_update(); | 231 | lcd_update(); |
221 | 232 | ||
222 | sleep(HZ/50); /* Allow the button driver to check the buttons */ | 233 | sleep(HZ/50); /* Allow the button driver to check the buttons */ |
@@ -239,18 +250,34 @@ void main(void) | |||
239 | power_off(); | 250 | power_off(); |
240 | } | 251 | } |
241 | 252 | ||
253 | adc_battery = adc_read(ADC_BATTERY); | ||
254 | |||
255 | battery_voltage = (adc_battery * BATTERY_SCALE_FACTOR) / 10000; | ||
256 | batt_int = battery_voltage / 100; | ||
257 | batt_frac = battery_voltage % 100; | ||
258 | |||
259 | snprintf(buf, 32, "Batt: %d.%02dV", batt_int, batt_frac); | ||
260 | lcd_puts(0, line++, buf); | ||
261 | lcd_update(); | ||
262 | |||
263 | if(battery_voltage <= 300) { | ||
264 | line++; | ||
265 | lcd_puts(0, line++, "WARNING! BATTERY LOW!!"); | ||
266 | lcd_update(); | ||
267 | sleep(HZ*2); | ||
268 | } | ||
269 | |||
242 | rc = ata_init(); | 270 | rc = ata_init(); |
243 | if(rc) | 271 | if(rc) |
244 | { | 272 | { |
245 | #ifdef HAVE_LCD_BITMAP | ||
246 | char str[32]; | 273 | char str[32]; |
247 | lcd_clear_display(); | 274 | lcd_clear_display(); |
248 | snprintf(str, 31, "ATA error: %d", rc); | 275 | snprintf(str, 31, "ATA error: %d", rc); |
249 | lcd_puts(0, 1, str); | 276 | lcd_puts(0, line++, str); |
277 | lcd_puts(0, line++, "Insert USB cable and press"); | ||
278 | lcd_puts(0, line++, "a button"); | ||
250 | lcd_update(); | 279 | lcd_update(); |
251 | while(!(button_get(true) & BUTTON_REL)); | 280 | while(!(button_get(true) & BUTTON_REL)); |
252 | #endif | ||
253 | panicf("ata: %d", rc); | ||
254 | } | 281 | } |
255 | 282 | ||
256 | /* A hack to enter USB mode without using the USB thread */ | 283 | /* A hack to enter USB mode without using the USB thread */ |