Forgot to commit the change to keyboard.c to make the line edit mode acctually work...
[kugel-rb.git] / bootloader / meizu_m3.c
blob2fb0b551a02285058fe32ddddfd1835702f2bde4
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 "backlight.h"
37 #include "backlight-target.h"
38 #include "button.h"
39 #include "panic.h"
40 #include "power.h"
41 #include "file.h"
42 #include "common.h"
43 #include "rbunicode.h"
44 #include "usb.h"
45 #include "qt1106.h"
46 #include "rockboxlogo.h"
49 #include <stdarg.h>
51 char version[] = APPSVERSION;
52 #define LONG_DELAY 200000
53 #define SHORT_DELAY 50000
54 #define PAUSE_DELAY 50000
56 static inline void delay(int duration)
58 volatile int i;
59 for(i=0;i<duration;i++);
63 void bl_debug(bool bit)
65 if (bit)
67 PDAT0 ^= (1 << 2); //Toggle backlight
68 delay(LONG_DELAY);
69 PDAT0 ^= (1 << 2); //Toggle backlight
70 delay(LONG_DELAY);
72 else
74 PDAT0 ^= (1 << 2); //Toggle backlight
75 delay(SHORT_DELAY);
76 PDAT0 ^= (1 << 2); //Toggle backlight
77 delay(SHORT_DELAY);
81 void bl_debug_count(unsigned int input)
83 unsigned int i;
84 delay(SHORT_DELAY*3);
85 for (i = 0; i < input; i++)
87 PDAT0 ^= (1 << 2); //Toggle backlight
88 delay(SHORT_DELAY);
89 PDAT0 ^= (1 << 2); //Toggle backlight
90 delay(2*SHORT_DELAY);
93 void bl_debug_int(unsigned int input,unsigned int count)
95 unsigned int i;
96 for (i = 0; i < count; i++)
98 bl_debug(input>>i & 1);
100 delay(SHORT_DELAY*6);
103 void main(void)
105 char mystring[64];
107 //Set backlight pin to output and enable
108 int oldval = PCON0;
109 PCON0 = ((oldval & ~(3 << 4)) | (1 << 4));
110 PDAT0 |= (1 << 2);
112 //power on
113 // oldval = PCON1;
114 // PCON1 = ((oldval & ~(0xf << 12)) | (1 << 12));
115 // PDAT1|=(1<<3);
117 //Set PLAY to EINT4
118 oldval = PCON1;
119 PCON1 = ((oldval & ~(0xf << 16)) | (2 << 16));
121 //Set MENU to EINT0
122 oldval = PCON1;
123 PCON1 = (oldval & ~(0xf)) | 2;
125 // enable external interrupts
126 EINTPOL = 0x11;
127 INTMSK = 0x11;
128 EINTMSK = 0x11;
129 asm volatile("msr cpsr_c, #0x13\n\t"); // enable interrupts
131 lcd_init();
132 lcd_update();
134 init_qt1106();
136 /* Calibrate the lot */
137 qt1106_io(QT1106_MODE_FREE | QT1106_MOD_INF | QT1106_DI \
138 | QT1106_SLD_SLIDER | QT1106_CAL_WHEEL | QT1106_CAL_KEYS | QT1106_RES_256);
140 lcd_clear_display();
141 lcd_bitmap(rockboxlogo, 0, 30, BMPWIDTH_rockboxlogo, BMPHEIGHT_rockboxlogo);
142 lcd_update();
144 /* Set to maximum sensitivity */
145 qt1106_io(QT1106_CT | (0x00 << 8) );
147 while(true)
149 qt1106_wait();
151 int slider = qt1106_io(QT1106_MODE_FREE | QT1106_MOD_INF \
152 | QT1106_DI | QT1106_SLD_SLIDER | QT1106_RES_256);
153 snprintf(mystring, 64, "%x %2.2x",(slider & 0x008000)>>15, slider&0xff);
154 lcd_puts(0,1,mystring);
155 lcd_update();
157 if(slider & 0x008000)
158 bl_debug_count(((slider&0xff)) + 1);
162 //power off
163 PDAT1&=~(1<<3);