blob: b7ce7330c0d2db3778ee9f702e11a480a4820502 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: button-e200v2.c 19035 2008-11-07 05:31:05Z jdgordon $
*
* Copyright (C) 2006 by Barry Wardell
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "system.h"
#include "button-target.h"
#include "button.h"
#include "backlight.h"
#include "powermgmt.h"
static unsigned short _dbop_din = 0xFFFF;
/* in the lcd driver */
extern unsigned short int lcd_dbop_input(void);
static bool hold_button = false;
#ifndef BOOTLOADER
static bool hold_button_old = false;
#endif
/* for the debug menu */
unsigned short button_dbop_data(void)
{
return _dbop_din;
}
void button_init_device(void)
{
GPIOA_DIR &= ~(1<<3);
}
bool button_hold(void)
{
return hold_button;
}
/*
* Get button pressed from hardware
*/
int button_read_device(void)
{
int btn = BUTTON_NONE;
_dbop_din = lcd_dbop_input();
/* hold button handling */
hold_button = ((_dbop_din & (1<<12)) == 0);
#ifndef BOOTLOADER
/* light handling */
if (hold_button != hold_button_old)
{
hold_button_old = hold_button;
backlight_hold_changed(hold_button);
}
#endif /* BOOTLOADER */
if (hold_button) {
return 0;
}
/* direct GPIO connections */
if (GPIOA_PIN(3))
btn |= BUTTON_POWER;
/* DBOP buttons */
if(!(_dbop_din & (1<<2)))
btn |= BUTTON_LEFT;
if(!(_dbop_din & (1<<3)))
btn |= BUTTON_DOWN;
if(!(_dbop_din & (1<<4)))
btn |= BUTTON_SELECT;
if(!(_dbop_din & (1<<5)))
btn |= BUTTON_UP;
if(!(_dbop_din & (1<<6)))
btn |= BUTTON_RIGHT;
if(!(_dbop_din & (1<<13)))
btn |= BUTTON_VOL_UP;
if(!(_dbop_din & (1<<14)))
btn |= BUTTON_VOL_DOWN;
if(!(_dbop_din & (1<<15)))
btn |= BUTTON_REC;
return btn;
}
|