diff options
author | Dave Chapman <dave@dchapman.com> | 2007-11-01 23:38:57 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2007-11-01 23:38:57 +0000 |
commit | a4d48d0c0dabb3e78e6b1dc31c023627ce924ce1 (patch) | |
tree | 23210360f876d7c962368a85f81c909824e2a7e1 | |
parent | 80e4d671d2271c8a6a3ec463c277fcf7b3fa3ab9 (diff) | |
download | rockbox-a4d48d0c0dabb3e78e6b1dc31c023627ce924ce1.tar.gz rockbox-a4d48d0c0dabb3e78e6b1dc31c023627ce924ce1.zip |
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
-rw-r--r-- | bootloader/telechips.c | 36 | ||||
-rw-r--r-- | firmware/SOURCES | 1 | ||||
-rw-r--r-- | firmware/export/config-logikdax.h | 3 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/logikdax/button-logikdax.c | 98 | ||||
-rw-r--r-- | firmware/target/arm/tcc77x/logikdax/button-target.h | 27 |
5 files changed, 135 insertions, 30 deletions
diff --git a/bootloader/telechips.c b/bootloader/telechips.c index c1dcda0dae..83dad704da 100644 --- a/bootloader/telechips.c +++ b/bootloader/telechips.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include "fat.h" | 32 | #include "fat.h" |
33 | #include "disk.h" | 33 | #include "disk.h" |
34 | #include "font.h" | 34 | #include "font.h" |
35 | #include "button.h" | ||
35 | #include "adc.h" | 36 | #include "adc.h" |
36 | #include "adc-target.h" | 37 | #include "adc-target.h" |
37 | #include "backlight-target.h" | 38 | #include "backlight-target.h" |
@@ -46,8 +47,10 @@ extern int line; | |||
46 | 47 | ||
47 | void* main(void) | 48 | void* main(void) |
48 | { | 49 | { |
49 | unsigned short button; | 50 | int button; |
50 | int gpioa; | 51 | int power_count = 0; |
52 | int count = 0; | ||
53 | bool do_power_off = false; | ||
51 | 54 | ||
52 | system_init(); | 55 | system_init(); |
53 | adc_init(); | 56 | adc_init(); |
@@ -56,17 +59,36 @@ void* main(void) | |||
56 | 59 | ||
57 | __backlight_on(); | 60 | __backlight_on(); |
58 | 61 | ||
59 | while(1) { | 62 | while(!do_power_off) { |
60 | line = 0; | 63 | line = 0; |
61 | printf("Hello World!"); | 64 | printf("Hello World!"); |
62 | 65 | ||
63 | gpioa = GPIOA; | 66 | button = button_read_device(); |
64 | printf("GPIOA: 0x%08x",gpioa); | ||
65 | 67 | ||
66 | button = adc_read(ADC_BUTTONS); | 68 | /* Power-off if POWER button has been held for a long time |
67 | printf("ADC[0]: 0x%04x",button); | 69 | This loop is currently running at about 100 iterations/second |
70 | */ | ||
71 | if (button & BUTTON_POWERPLAY) { | ||
72 | power_count++; | ||
73 | if (power_count > 200) | ||
74 | do_power_off = true; | ||
75 | } else { | ||
76 | power_count = 0; | ||
77 | } | ||
78 | |||
79 | printf("Btn: 0x%08x",button); | ||
80 | |||
81 | count++; | ||
82 | printf("Count: %d",count); | ||
68 | } | 83 | } |
69 | 84 | ||
85 | lcd_clear_display(); | ||
86 | line = 0; | ||
87 | printf("POWER-OFF"); | ||
88 | |||
89 | /* TODO: Power-off */ | ||
90 | while(1); | ||
91 | |||
70 | return 0; | 92 | return 0; |
71 | } | 93 | } |
72 | 94 | ||
diff --git a/firmware/SOURCES b/firmware/SOURCES index 5061ac7370..94b98979ce 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -821,6 +821,7 @@ target/arm/pnx0101/pcm-pnx0101.c | |||
821 | target/arm/tcc77x/adc-tcc77x.c | 821 | target/arm/tcc77x/adc-tcc77x.c |
822 | target/arm/tcc77x/ata-nand-tcc77x.c | 822 | target/arm/tcc77x/ata-nand-tcc77x.c |
823 | target/arm/tcc77x/system-tcc77x.c | 823 | target/arm/tcc77x/system-tcc77x.c |
824 | target/arm/tcc77x/logikdax/button-logikdax.c | ||
824 | target/arm/tcc77x/logikdax/lcd-logikdax.c | 825 | target/arm/tcc77x/logikdax/lcd-logikdax.c |
825 | target/arm/tcc77x/logikdax/power-logikdax.c | 826 | target/arm/tcc77x/logikdax/power-logikdax.c |
826 | #endif /* SIMULATOR */ | 827 | #endif /* SIMULATOR */ |
diff --git a/firmware/export/config-logikdax.h b/firmware/export/config-logikdax.h index 384dac4e11..8c6509cdaf 100644 --- a/firmware/export/config-logikdax.h +++ b/firmware/export/config-logikdax.h | |||
@@ -49,6 +49,9 @@ | |||
49 | /* define this if you have RTC RAM available for settings */ | 49 | /* define this if you have RTC RAM available for settings */ |
50 | //#define HAVE_RTC_RAM | 50 | //#define HAVE_RTC_RAM |
51 | 51 | ||
52 | /* Define this if you have a software controlled poweroff */ | ||
53 | #define HAVE_SW_POWEROFF | ||
54 | |||
52 | /* The number of bytes reserved for loadable plugins */ | 55 | /* The number of bytes reserved for loadable plugins */ |
53 | #define PLUGIN_BUFFER_SIZE 0x8000 | 56 | #define PLUGIN_BUFFER_SIZE 0x8000 |
54 | 57 | ||
diff --git a/firmware/target/arm/tcc77x/logikdax/button-logikdax.c b/firmware/target/arm/tcc77x/logikdax/button-logikdax.c new file mode 100644 index 0000000000..8e4279b699 --- /dev/null +++ b/firmware/target/arm/tcc77x/logikdax/button-logikdax.c | |||
@@ -0,0 +1,98 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Dave Chapman | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "config.h" | ||
21 | #include "cpu.h" | ||
22 | #include "button.h" | ||
23 | #include "adc.h" | ||
24 | |||
25 | /* | ||
26 | |||
27 | Results of button testing: | ||
28 | |||
29 | HOLD: GPIOA & 0x0002 (0=pressed, 0x0002 = released) | ||
30 | POWER: GPIOA & 0x8000 (0=pressed, 0x8000 = released) | ||
31 | |||
32 | ADC[0]: (approx values) | ||
33 | |||
34 | RIGHT - 0x37 | ||
35 | LEFT - 0x7f | ||
36 | JOYSTICK PRESS - 0xc7 | ||
37 | UP - 0x11e | ||
38 | DOWN - 0x184 | ||
39 | MODE - 0x1f0/0x1ff | ||
40 | PRESET - 0x268/0x269 | ||
41 | REC - 0x2dd | ||
42 | |||
43 | Values of ADC[0] tested in OF disassembly: 0x50, 0x96, 0xdc, 0x208, 0x384 | ||
44 | |||
45 | */ | ||
46 | |||
47 | void button_init_device(void) | ||
48 | { | ||
49 | /* Nothing to do */ | ||
50 | } | ||
51 | |||
52 | int button_read_device(void) | ||
53 | { | ||
54 | int btn = BUTTON_NONE; | ||
55 | int adc; | ||
56 | |||
57 | adc = adc_read(ADC_BUTTONS); | ||
58 | |||
59 | if (adc < 0x384) { | ||
60 | if (adc < 0x140) { | ||
61 | if (adc < 0x96) { | ||
62 | if (adc < 0x50) { | ||
63 | btn |= BUTTON_RIGHT; /* 0x00..0x4f */ | ||
64 | } else { | ||
65 | btn |= BUTTON_LEFT; /* 0x50..0x95 */ | ||
66 | } | ||
67 | } else { | ||
68 | if (adc < 0xe0) { | ||
69 | btn |= BUTTON_SELECT; /* 0x96..0xdf */ | ||
70 | } else { | ||
71 | btn |= BUTTON_UP; /* 0xe0..0x13f */ | ||
72 | } | ||
73 | } | ||
74 | } else { | ||
75 | if (adc < 0x208) { | ||
76 | if (adc < 0x1b0) { | ||
77 | btn |= BUTTON_DOWN; /* 0x140..0x1af */ | ||
78 | } else { | ||
79 | btn |= BUTTON_MODE; /* 0x1b0..0x207 */ | ||
80 | } | ||
81 | } else { | ||
82 | if (adc < 0x290) { | ||
83 | btn |= BUTTON_PRESET; /* 0x208..0x28f */ | ||
84 | } else { | ||
85 | btn |= BUTTON_REC; /* 0x290..0x383 */ | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | |||
91 | if (!(GPIOA & 0x2)) | ||
92 | btn |= BUTTON_HOLD; | ||
93 | |||
94 | if (!(GPIOA & 0x8000)) | ||
95 | btn |= BUTTON_POWERPLAY; | ||
96 | |||
97 | return btn; | ||
98 | } | ||
diff --git a/firmware/target/arm/tcc77x/logikdax/button-target.h b/firmware/target/arm/tcc77x/logikdax/button-target.h index 2925a423b6..46997fc5d0 100644 --- a/firmware/target/arm/tcc77x/logikdax/button-target.h +++ b/firmware/target/arm/tcc77x/logikdax/button-target.h | |||
@@ -23,29 +23,6 @@ | |||
23 | #include <stdbool.h> | 23 | #include <stdbool.h> |
24 | #include "config.h" | 24 | #include "config.h" |
25 | 25 | ||
26 | /* | ||
27 | |||
28 | Results of button testing: | ||
29 | |||
30 | HOLD: GPIOA & 0x0002 (0=pressed, 0x0002 = released) | ||
31 | POWER: GPIOA & 0x8000 (0=pressed, 0x8000 = released) | ||
32 | |||
33 | ADC[0]: (approx values) | ||
34 | |||
35 | RIGHT - 0x37 | ||
36 | LEFT - 0x7f | ||
37 | JOYSTICK PRESS - 0xc7 | ||
38 | UP - 0x11e | ||
39 | DOWN - 0x184 | ||
40 | MODE - 0x1f0/0x1ff | ||
41 | PRESET - 0x268/0x269 | ||
42 | TIMESHIFT - 0x2dd | ||
43 | |||
44 | Values of ADC[0] tested in OF disassembly: 0x50, 0x96, 0xdc, 0x208, 0x384 | ||
45 | |||
46 | */ | ||
47 | |||
48 | |||
49 | void button_init_device(void); | 26 | void button_init_device(void); |
50 | int button_read_device(void); | 27 | int button_read_device(void); |
51 | 28 | ||
@@ -66,5 +43,9 @@ int button_read_device(void); | |||
66 | |BUTTON_RIGHT|BUTTON_UP|BUTTON_DOWN|BUTTON_SELECT) | 43 | |BUTTON_RIGHT|BUTTON_UP|BUTTON_DOWN|BUTTON_SELECT) |
67 | 44 | ||
68 | #define BUTTON_REMOTE 0 | 45 | #define BUTTON_REMOTE 0 |
46 | |||
47 | /* Software power-off */ | ||
48 | #define POWEROFF_BUTTON BUTTON_POWERPLAY | ||
49 | #define POWEROFF_COUNT 40 | ||
69 | 50 | ||
70 | #endif /* _BUTTON_TARGET_H_ */ | 51 | #endif /* _BUTTON_TARGET_H_ */ |