Samsung YP-S3: update backlight brightness curve so backlight is still on at the...
[kugel-rb.git] / bootloader / meizu_m6sp.c
blob2240e9576827f8775a75af06c2a73b85cbca435f
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"
45 #include <stdarg.h>
47 char version[] = APPSVERSION;
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 // Wait for play to be pressed
111 while(!(PDAT1 & (1 << 4)));
112 // Wait for play to be released
113 while((PDAT1 & (1 << 4)));
114 PDAT0 ^= (1 << 2); //Toggle backlight
115 delay(LONG_DELAY);
117 //power off
118 PDAT1&=~(1<<3);