summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBertrik Sikken <bertrik@sikken.nl>2009-07-11 20:00:07 +0000
committerBertrik Sikken <bertrik@sikken.nl>2009-07-11 20:00:07 +0000
commit5db8098bfdca71afe261c81ac3552e4a29c5906e (patch)
tree3224539de234f1c0ed2441c335a0ca8fae095a12
parenta5e25cc2a8f9661c11845a36e4be715efe4fc5c5 (diff)
downloadrockbox-5db8098bfdca71afe261c81ac3552e4a29c5906e.tar.gz
rockbox-5db8098bfdca71afe261c81ac3552e4a29c5906e.zip
Meizu M3: implement rudimentary button driver
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21787 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/s5l8700/meizu-m3/button-m3.c69
-rw-r--r--firmware/target/arm/s5l8700/meizu-m3/button-target.h25
2 files changed, 79 insertions, 15 deletions
diff --git a/firmware/target/arm/s5l8700/meizu-m3/button-m3.c b/firmware/target/arm/s5l8700/meizu-m3/button-m3.c
new file mode 100644
index 0000000000..a99a99ec82
--- /dev/null
+++ b/firmware/target/arm/s5l8700/meizu-m3/button-m3.c
@@ -0,0 +1,69 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2009 Bertrik Sikken
11 *
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.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdbool.h>
23#include "config.h"
24
25#include "inttypes.h"
26#include "s5l8700.h"
27#include "button-target.h"
28
29/* Button driver for the meizu M3
30
31 TODO: implement buttons based on on touch strip events, for example
32 short touch (select), slide up and down, touching the <> button, etc.
33 */
34
35
36void button_init_device(void)
37{
38 PCON0 &= ~(3 << 10); /* P0.5 hold switch */
39 PCON1 &= ~(0xF << 0); /* P1.0 menu button */
40 PCON1 &= ~(0xF << 16); /* P1.4 play button */
41 PCON3 &= ~(0xF << 12); /* P3.3 <> button */
42}
43
44int button_read_device(void)
45{
46 int buttons = 0;
47
48 if (button_hold()) {
49 return 0;
50 }
51
52 if ((PDAT1 & (1 << 0)) == 0) {
53 buttons |= BUTTON_MENU;
54 }
55 if ((PDAT1 & (1 << 4)) == 0) {
56 buttons |= BUTTON_PLAY;
57 }
58 if ((PDAT3 & (1 << 3)) == 0) {
59 buttons |= BUTTON_PREVNEXT;
60 }
61
62 return buttons;
63}
64
65bool button_hold(void)
66{
67 return ((PDAT0 & (1 << 5)) != 0);
68}
69
diff --git a/firmware/target/arm/s5l8700/meizu-m3/button-target.h b/firmware/target/arm/s5l8700/meizu-m3/button-target.h
index 7fab9c4d64..8aaca17a54 100644
--- a/firmware/target/arm/s5l8700/meizu-m3/button-target.h
+++ b/firmware/target/arm/s5l8700/meizu-m3/button-target.h
@@ -22,7 +22,6 @@
22#define _BUTTON_TARGET_H_ 22#define _BUTTON_TARGET_H_
23 23
24#include <stdbool.h> 24#include <stdbool.h>
25#include "config.h"
26 25
27#define HAS_BUTTON_HOLD 26#define HAS_BUTTON_HOLD
28 27
@@ -30,25 +29,21 @@ bool button_hold(void);
30void button_init_device(void); 29void button_init_device(void);
31int button_read_device(void); 30int button_read_device(void);
32 31
33/* Toshiba Gigabeat specific button codes */ 32/* Meizu M3 specific button codes */
33#define BUTTON_PREVNEXT 0x00000001
34#define BUTTON_MENU 0x00000002
35#define BUTTON_PLAY 0x00000004
34 36
35#define BUTTON_LEFT 0x00000001 37/* there are no LEFT/RIGHT buttons, but other parts of the code expect them */
36#define BUTTON_RIGHT 0x00000002 38#define BUTTON_LEFT 0
37#define BUTTON_UP 0x00000004 39#define BUTTON_RIGHT 0
38#define BUTTON_DOWN 0x00000008
39 40
40#define BUTTON_SELECT 0x00000010 41#define BUTTON_MAIN (BUTTON_PREVNEXT|BUTTON_MENU|BUTTON_PLAY)
41 42
42#define BUTTON_MENU 0x00000020 43#define BUTTON_REMOTE 0
43#define BUTTON_PLAY 0x00000040
44
45
46#define BUTTON_MAIN (BUTTON_MENU|BUTTON_LEFT|BUTTON_RIGHT\
47 |BUTTON_UP|BUTTON_DOWN|BUTTON_SELECT|BUTTON_PLAY)
48
49#define BUTTON_REMOTE 0
50 44
51#define POWEROFF_BUTTON BUTTON_PLAY 45#define POWEROFF_BUTTON BUTTON_PLAY
52#define POWEROFF_COUNT 10 46#define POWEROFF_COUNT 10
53 47
54#endif /* _BUTTON_TARGET_H_ */ 48#endif /* _BUTTON_TARGET_H_ */
49