Fix r29053 red and a leftover use of 'usb' variable as a bool rather than int in...
[kugel-rb.git] / bootloader / meizu_m6sp.c
blobc57fe91b2222a560ebabe7b03d4f9d8051d0ab6e
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2006 by Greg White
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
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 "inttypes.h"
26 #include "string.h"
27 #include "cpu.h"
28 #include "system.h"
29 #include "lcd.h"
30 #include "kernel.h"
31 #include "thread.h"
32 #include "storage.h"
33 #include "fat.h"
34 #include "disk.h"
35 #include "font.h"
36 #include "button.h"
37 #include "panic.h"
38 #include "power.h"
39 #include "file.h"
40 #include "common.h"
41 #include "rbunicode.h"
42 #include "usb.h"
43 #include "qt1106.h"
44 #include "bitmaps/rockboxlogo.h"
46 #include <stdarg.h>
48 #define LONG_DELAY 200000
49 #define SHORT_DELAY 50000
50 #define PAUSE_DELAY 50000
52 static inline void delay(int duration)
54 volatile int i;
55 for(i=0;i<duration;i++);
59 void bl_debug(bool bit)
61 if (bit)
63 PDAT0 ^= (1 << 2); //Toggle backlight
64 delay(LONG_DELAY);
65 PDAT0 ^= (1 << 2); //Toggle backlight
66 delay(LONG_DELAY);
68 else
70 PDAT0 ^= (1 << 2); //Toggle backlight
71 delay(SHORT_DELAY);
72 PDAT0 ^= (1 << 2); //Toggle backlight
73 delay(SHORT_DELAY);
77 void bl_debug_count(unsigned int input)
79 unsigned int i;
80 delay(SHORT_DELAY*3);
81 for (i = 0; i < input; i++)
83 PDAT0 ^= (1 << 2); //Toggle backlight
84 delay(SHORT_DELAY);
85 PDAT0 ^= (1 << 2); //Toggle backlight
86 delay(2*SHORT_DELAY);
89 void bl_debug_int(unsigned int input,unsigned int count)
91 unsigned int i;
92 for (i = 0; i < count; i++)
94 bl_debug(input>>i & 1);
96 delay(SHORT_DELAY*6);
99 void main(void)
101 //Set backlight pin to output and enable
102 int oldval = PCON0;
103 PCON0 = ((oldval & ~(3 << 4)) | (1 << 4));
104 PDAT0 |= (1 << 2);
106 //Set PLAY to input
107 oldval = PCON1;
108 PCON1 = ((oldval & ~(0xf << 16)) | (0 << 16));
110 lcd_bitmap(rockboxlogo, 0, 0, BMPWIDTH_rockboxlogo, BMPHEIGHT_rockboxlogo);
111 lcd_init_device();
113 // Wait for play to be pressed
114 while(!(PDAT1 & (1 << 4)));
115 // Wait for play to be released
116 while((PDAT1 & (1 << 4)));
117 PDAT0 ^= (1 << 2); //Toggle backlight
118 delay(LONG_DELAY);
120 //power off
121 PDAT1&=~(1<<3);