Turn off automatically after a number of backlight toggles.
[kugel-rb.git] / bootloader / meizu_m6sl.c
blob3ee88120b514cd992bedd285b2822e1fc1e2ae48
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 "ata.h"
33 #include "fat.h"
34 #include "disk.h"
35 #include "font.h"
36 #include "adc.h"
37 #include "backlight.h"
38 #include "backlight-target.h"
39 #include "button.h"
40 #include "panic.h"
41 #include "power.h"
42 #include "file.h"
43 #include "common.h"
44 #include "rbunicode.h"
45 #include "usb.h"
47 #include <stdarg.h>
49 char version[] = APPSVERSION;
51 void main(void)
53 int counter=0;
54 //Set backlight pin to output and enable
55 int oldval = PCON0;
56 PCON0 = ((oldval & ~(3 << 4)) | (1 << 4));
57 PDAT0 |= (1 << 2);
59 //Set PLAY to input
60 oldval = PCON1;
61 PCON1 = ((oldval & ~(0xf << 16)) | (0 << 16));
63 //Set the piezo pins to output
64 oldval = PCON5;
65 PCON5 = ((oldval & ~((0xf << 4) | (0xf << 8))) | ((1 << 0) | (1 << 4)));
66 PDAT5 &= ~((1 << 1) | (1 << 2)); //should not be needed
68 PDAT5 |= (1 << 1); //Toggle piezo +
70 //toggle backlight on PLAY
71 while(counter<20)
73 // Wait for play to be pressed
74 while(!(PDAT1 & (1 << 4)))
78 PDAT5 ^= (1 << 1); //Toggle piezo +
79 PDAT0 ^= (1 << 2); //Toggle backlight
80 counter++;
82 // Wait for play to be released
83 while(PDAT1 & (1 << 4))
87 //toggle a few times to warn that we're done
88 for(counter=0;counter<10;counter++)
90 volatile int i;
91 for(i=0;i<50000;i++);
92 PDAT0 ^= (1 << 2); //Toggle backlight
94 PDAT1&=~(1<<3);