diff options
author | Andrew Ryabinin <ryabinin.a.a@gmail.com> | 2011-11-03 11:53:02 +0000 |
---|---|---|
committer | Andrew Ryabinin <ryabinin.a.a@gmail.com> | 2011-11-03 11:53:02 +0000 |
commit | 2164aab9020bb37ec71a24461c4c42bc4e2eb2d3 (patch) | |
tree | dbf138f0f8d84789b335e6059508176a71fe0cde /firmware/target/arm/rk27xx/hm801 | |
parent | 50211e20548bf3a5f7781489269a297cad58713e (diff) | |
download | rockbox-2164aab9020bb37ec71a24461c4c42bc4e2eb2d3.tar.gz rockbox-2164aab9020bb37ec71a24461c4c42bc4e2eb2d3.zip |
Added HiFiMAN HM-801 target. FS#12355. This also renames tda1543.{ch} used by HM-60x to dummy_codec.{ch} as it works for PCM1704 used by HM-801.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30891 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/rk27xx/hm801')
-rw-r--r-- | firmware/target/arm/rk27xx/hm801/button-hm801.c | 68 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/hm801/button-target.h | 47 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/hm801/power-hm801.c | 49 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/hm801/powermgmt-hm801.c | 60 |
4 files changed, 224 insertions, 0 deletions
diff --git a/firmware/target/arm/rk27xx/hm801/button-hm801.c b/firmware/target/arm/rk27xx/hm801/button-hm801.c new file mode 100644 index 0000000000..8e3d46bf0d --- /dev/null +++ b/firmware/target/arm/rk27xx/hm801/button-hm801.c | |||
@@ -0,0 +1,68 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 Andrew Ryabinin | ||
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 "config.h" | ||
23 | #include "system.h" | ||
24 | #include "button.h" | ||
25 | #include "adc.h" | ||
26 | |||
27 | void button_init_device(void) { | ||
28 | /* setup button gpio as input */ | ||
29 | GPIO_PCCON &= ~(POWEROFF_BUTTON); | ||
30 | } | ||
31 | |||
32 | int button_read_device(void) { | ||
33 | int adc_val = adc_read(ADC_BUTTONS); | ||
34 | int button = 0; | ||
35 | |||
36 | if (adc_val < 480) { /* middle */ | ||
37 | if (adc_val < 200) { /* 200 - 0 */ | ||
38 | if (adc_val < 30) { | ||
39 | button = BUTTON_UP; | ||
40 | } else { | ||
41 | button = BUTTON_RIGHT; /* 30 - 200 */ | ||
42 | } | ||
43 | } else { /* 200 - 480 */ | ||
44 | if (adc_val < 370) { | ||
45 | button = BUTTON_SELECT; | ||
46 | } else { | ||
47 | button = BUTTON_DOWN; | ||
48 | } | ||
49 | } | ||
50 | } else { /* > 480 */ | ||
51 | if (adc_val < 690) { /* 480 - 690 */ | ||
52 | if (adc_val < 580) { | ||
53 | button = BUTTON_LEFT; | ||
54 | } else { | ||
55 | button = BUTTON_NEXT; | ||
56 | } | ||
57 | } else { /* > 680 */ | ||
58 | if (adc_val < 840) { | ||
59 | button = BUTTON_PREV; | ||
60 | } else { | ||
61 | if (adc_val < 920) { | ||
62 | button = BUTTON_PLAY; | ||
63 | } | ||
64 | } | ||
65 | } | ||
66 | } | ||
67 | return button | (GPIO_PCDR & POWEROFF_BUTTON); | ||
68 | } | ||
diff --git a/firmware/target/arm/rk27xx/hm801/button-target.h b/firmware/target/arm/rk27xx/hm801/button-target.h new file mode 100644 index 0000000000..4af054b07c --- /dev/null +++ b/firmware/target/arm/rk27xx/hm801/button-target.h | |||
@@ -0,0 +1,47 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 Andrew Ryabinin | ||
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 | #ifndef _BUTTON_TARGET_H_ | ||
22 | #define _BUTTON_TARGET_H_ | ||
23 | |||
24 | #include <stdbool.h> | ||
25 | #include "config.h" | ||
26 | |||
27 | void button_init_device(void); | ||
28 | int button_read_device(void); | ||
29 | |||
30 | |||
31 | #define BUTTON_UP 0x00000001 | ||
32 | #define BUTTON_DOWN 0x00000004 | ||
33 | #define BUTTON_LEFT 0x00000008 | ||
34 | #define BUTTON_RIGHT 0x00000010 | ||
35 | #define BUTTON_SELECT 0x00000020 | ||
36 | #define BUTTON_NEXT 0x00000040 | ||
37 | #define BUTTON_PREV 0x00000080 | ||
38 | #define BUTTON_PLAY 0x00000100 | ||
39 | |||
40 | |||
41 | #define BUTTON_REMOTE 0 | ||
42 | |||
43 | |||
44 | #define POWEROFF_BUTTON 0x02 | ||
45 | #define POWEROFF_COUNT 30 | ||
46 | |||
47 | #endif /* _BUTTON_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/rk27xx/hm801/power-hm801.c b/firmware/target/arm/rk27xx/hm801/power-hm801.c new file mode 100644 index 0000000000..18a0566a78 --- /dev/null +++ b/firmware/target/arm/rk27xx/hm801/power-hm801.c | |||
@@ -0,0 +1,49 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright © 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 | #include <stdbool.h> | ||
22 | #include "config.h" | ||
23 | #include "inttypes.h" | ||
24 | #include "power.h" | ||
25 | #include "panic.h" | ||
26 | #include "system.h" | ||
27 | #include "usb_core.h" /* for usb_charging_maxcurrent_change */ | ||
28 | |||
29 | void power_off(void) | ||
30 | { | ||
31 | GPIO_PCDR &= ~(1<<0); | ||
32 | while(1); | ||
33 | } | ||
34 | |||
35 | void power_init(void) | ||
36 | { | ||
37 | GPIO_PCDR |= (1<<0); | ||
38 | GPIO_PCCON |= (1<<0); | ||
39 | } | ||
40 | |||
41 | unsigned int power_input_status(void) | ||
42 | { | ||
43 | return (usb_detect() == USB_INSERTED) ? POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE; | ||
44 | } | ||
45 | |||
46 | bool charging_state(void) | ||
47 | { | ||
48 | return true; | ||
49 | } | ||
diff --git a/firmware/target/arm/rk27xx/hm801/powermgmt-hm801.c b/firmware/target/arm/rk27xx/hm801/powermgmt-hm801.c new file mode 100644 index 0000000000..a815d893b2 --- /dev/null +++ b/firmware/target/arm/rk27xx/hm801/powermgmt-hm801.c | |||
@@ -0,0 +1,60 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright © 2011 Andrew Ryabinin | ||
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 "config.h" | ||
23 | #include "adc.h" | ||
24 | #include "adc-target.h" | ||
25 | #include "powermgmt.h" | ||
26 | |||
27 | /* Battery voltage calculation and discharge/charge curves for the HiFiMAN HM-801. | ||
28 | |||
29 | I don't know how to calculate battery voltage, so all values represented here is just | ||
30 | values from adc battery channel, not millivolts. | ||
31 | Discharge and charge curves have not been calibrated yet. | ||
32 | */ | ||
33 | |||
34 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | ||
35 | { | ||
36 | /* OF power off device when this value reached */ | ||
37 | 430 | ||
38 | }; | ||
39 | |||
40 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | ||
41 | { | ||
42 | 425 | ||
43 | }; | ||
44 | |||
45 | /* adc values of 0%, 10%, ... 100% when charging disabled */ | ||
46 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = | ||
47 | { | ||
48 | /* TODO: simple uncalibrated curve */ | ||
49 | { 425, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520 } | ||
50 | }; | ||
51 | |||
52 | /* adc values of 0%, 10%, ... 100% when charging enabled */ | ||
53 | const unsigned short percent_to_volt_charge[11] = | ||
54 | /* TODO: simple uncalibrated curve */ | ||
55 | { 425, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520 }; | ||
56 | |||
57 | unsigned int battery_adc_voltage(void) | ||
58 | { | ||
59 | return adc_read(ADC_BATTERY); | ||
60 | } | ||