Button driver for Logik DAX, plus some changes to the debug info displayed in the bootloader build.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15396 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dave Chapman 2007-11-01 23:38:57 +00:00
parent 80e4d671d2
commit a4d48d0c0d
5 changed files with 135 additions and 30 deletions

View file

@ -32,6 +32,7 @@
#include "fat.h"
#include "disk.h"
#include "font.h"
#include "button.h"
#include "adc.h"
#include "adc-target.h"
#include "backlight-target.h"
@ -46,8 +47,10 @@ extern int line;
void* main(void)
{
unsigned short button;
int gpioa;
int button;
int power_count = 0;
int count = 0;
bool do_power_off = false;
system_init();
adc_init();
@ -56,17 +59,36 @@ void* main(void)
__backlight_on();
while(1) {
while(!do_power_off) {
line = 0;
printf("Hello World!");
gpioa = GPIOA;
printf("GPIOA: 0x%08x",gpioa);
button = button_read_device();
button = adc_read(ADC_BUTTONS);
printf("ADC[0]: 0x%04x",button);
/* Power-off if POWER button has been held for a long time
This loop is currently running at about 100 iterations/second
*/
if (button & BUTTON_POWERPLAY) {
power_count++;
if (power_count > 200)
do_power_off = true;
} else {
power_count = 0;
}
printf("Btn: 0x%08x",button);
count++;
printf("Count: %d",count);
}
lcd_clear_display();
line = 0;
printf("POWER-OFF");
/* TODO: Power-off */
while(1);
return 0;
}

View file

@ -821,6 +821,7 @@ target/arm/pnx0101/pcm-pnx0101.c
target/arm/tcc77x/adc-tcc77x.c
target/arm/tcc77x/ata-nand-tcc77x.c
target/arm/tcc77x/system-tcc77x.c
target/arm/tcc77x/logikdax/button-logikdax.c
target/arm/tcc77x/logikdax/lcd-logikdax.c
target/arm/tcc77x/logikdax/power-logikdax.c
#endif /* SIMULATOR */

View file

@ -49,6 +49,9 @@
/* define this if you have RTC RAM available for settings */
//#define HAVE_RTC_RAM
/* Define this if you have a software controlled poweroff */
#define HAVE_SW_POWEROFF
/* The number of bytes reserved for loadable plugins */
#define PLUGIN_BUFFER_SIZE 0x8000

View file

@ -0,0 +1,98 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 by Dave Chapman
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "config.h"
#include "cpu.h"
#include "button.h"
#include "adc.h"
/*
Results of button testing:
HOLD: GPIOA & 0x0002 (0=pressed, 0x0002 = released)
POWER: GPIOA & 0x8000 (0=pressed, 0x8000 = released)
ADC[0]: (approx values)
RIGHT - 0x37
LEFT - 0x7f
JOYSTICK PRESS - 0xc7
UP - 0x11e
DOWN - 0x184
MODE - 0x1f0/0x1ff
PRESET - 0x268/0x269
REC - 0x2dd
Values of ADC[0] tested in OF disassembly: 0x50, 0x96, 0xdc, 0x208, 0x384
*/
void button_init_device(void)
{
/* Nothing to do */
}
int button_read_device(void)
{
int btn = BUTTON_NONE;
int adc;
adc = adc_read(ADC_BUTTONS);
if (adc < 0x384) {
if (adc < 0x140) {
if (adc < 0x96) {
if (adc < 0x50) {
btn |= BUTTON_RIGHT; /* 0x00..0x4f */
} else {
btn |= BUTTON_LEFT; /* 0x50..0x95 */
}
} else {
if (adc < 0xe0) {
btn |= BUTTON_SELECT; /* 0x96..0xdf */
} else {
btn |= BUTTON_UP; /* 0xe0..0x13f */
}
}
} else {
if (adc < 0x208) {
if (adc < 0x1b0) {
btn |= BUTTON_DOWN; /* 0x140..0x1af */
} else {
btn |= BUTTON_MODE; /* 0x1b0..0x207 */
}
} else {
if (adc < 0x290) {
btn |= BUTTON_PRESET; /* 0x208..0x28f */
} else {
btn |= BUTTON_REC; /* 0x290..0x383 */
}
}
}
}
if (!(GPIOA & 0x2))
btn |= BUTTON_HOLD;
if (!(GPIOA & 0x8000))
btn |= BUTTON_POWERPLAY;
return btn;
}

View file

@ -23,29 +23,6 @@
#include <stdbool.h>
#include "config.h"
/*
Results of button testing:
HOLD: GPIOA & 0x0002 (0=pressed, 0x0002 = released)
POWER: GPIOA & 0x8000 (0=pressed, 0x8000 = released)
ADC[0]: (approx values)
RIGHT - 0x37
LEFT - 0x7f
JOYSTICK PRESS - 0xc7
UP - 0x11e
DOWN - 0x184
MODE - 0x1f0/0x1ff
PRESET - 0x268/0x269
TIMESHIFT - 0x2dd
Values of ADC[0] tested in OF disassembly: 0x50, 0x96, 0xdc, 0x208, 0x384
*/
void button_init_device(void);
int button_read_device(void);
@ -66,5 +43,9 @@ int button_read_device(void);
|BUTTON_RIGHT|BUTTON_UP|BUTTON_DOWN|BUTTON_SELECT)
#define BUTTON_REMOTE 0
/* Software power-off */
#define POWEROFF_BUTTON BUTTON_POWERPLAY
#define POWEROFF_COUNT 40
#endif /* _BUTTON_TARGET_H_ */