summaryrefslogtreecommitdiff
path: root/firmware/target/arm/s5l8700/ipodnano2g/button-nano2g.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/s5l8700/ipodnano2g/button-nano2g.c')
-rw-r--r--firmware/target/arm/s5l8700/ipodnano2g/button-nano2g.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/button-nano2g.c b/firmware/target/arm/s5l8700/ipodnano2g/button-nano2g.c
index 8049028a59..739b48b511 100644
--- a/firmware/target/arm/s5l8700/ipodnano2g/button-nano2g.c
+++ b/firmware/target/arm/s5l8700/ipodnano2g/button-nano2g.c
@@ -25,16 +25,58 @@
25#include "s5l8700.h" 25#include "s5l8700.h"
26#include "button-target.h" 26#include "button-target.h"
27 27
28#define CLICKWHEEL00 (*(volatile unsigned long*)(0x3c200000))
29#define CLICKWHEEL10 (*(volatile unsigned long*)(0x3c200010))
30#define CLICKWHEELINT (*(volatile unsigned long*)(0x3c200014))
31#define CLICKWHEEL_DATA (*(volatile unsigned long*)(0x3c200018))
32
33static int buttons = 0;
34
35void INT_SPI(void)
36{
37 int clickwheel_events;
38 int btn =0;
39 int status;
40
41 clickwheel_events = CLICKWHEELINT;
42
43 if (clickwheel_events & 4) CLICKWHEELINT = 4;
44 if (clickwheel_events & 2) CLICKWHEELINT = 2;
45 if (clickwheel_events & 1) CLICKWHEELINT = 1;
46
47 status = CLICKWHEEL_DATA;
48 if ((status & 0x800000ff) == 0x8000001a)
49 {
50 if (status & 0x00000100)
51 btn |= BUTTON_SELECT;
52 if (status & 0x00000200)
53 btn |= BUTTON_RIGHT;
54 if (status & 0x00000400)
55 btn |= BUTTON_LEFT;
56 if (status & 0x00000800)
57 btn |= BUTTON_PLAY;
58 if (status & 0x00001000)
59 btn |= BUTTON_MENU;
60 }
61
62 buttons = btn;
63}
64
28void button_init_device(void) 65void button_init_device(void)
29{ 66{
67 CLICKWHEEL00 = 0x280000;
68 CLICKWHEEL10 = 3;
69 INTMOD = 0;
70 INTMSK |= (1<<26);
71 PCON10 &= ~0xF00;
30} 72}
31 73
32int button_read_device(void) 74int button_read_device(void)
33{ 75{
76 return buttons;
34} 77}
35 78
36bool button_hold(void) 79bool button_hold(void)
37{ 80{
38 return ((PDAT14 & (1 << 6)) == 0); 81 return ((PDAT14 & (1 << 6)) == 0);
39} 82}
40