Trim down peak calculation a bit.
[kugel-rb.git] / firmware / target / arm / s5l8700 / meizu-m6sp / button-m6sp.c
blobcb052a119af59c0f34929cbcc5ce41942086cf66
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2009 Bertrik Sikken
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 ****************************************************************************/
22 #include <stdbool.h>
23 #include "config.h"
25 #include "inttypes.h"
26 #include "s5l8700.h"
27 #include "button-target.h"
29 /* Button driver for the meizu M6SP
31 Future improvements:
32 * touch strip support
33 * left/right buttons (probably read out with ADC0)
34 * unify with m3/m6sl button driver if possible
39 void button_init_device(void)
41 PCON0 &= ~(0x3 << 10); /* P0.5 hold switch */
42 PCON0 &= ~(0x3 << 14); /* P0.7 enter button */
43 PCON1 &= ~(0xF << 16); /* P1.4 play/power button */
46 int button_read_device(void)
48 int buttons = 0;
50 if (button_hold()) {
51 return 0;
54 if ((PDAT1 & (1 << 4)) == 0) {
55 buttons |= BUTTON_PLAY;
57 if ((PDAT0 & (1 << 7)) == 0) {
58 buttons |= BUTTON_ENTER;
61 return buttons;
64 bool button_hold(void)
66 return ((PDAT0 & (1 << 5)) != 0);