summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/button.c4
-rw-r--r--firmware/drivers/power.c28
2 files changed, 20 insertions, 12 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 6513fb4a3a..216c51ea15 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -490,7 +490,7 @@ static void button_tick(void)
490 || btn == BUTTON_RC_STOP 490 || btn == BUTTON_RC_STOP
491#endif 491#endif
492 ) && 492 ) &&
493#if defined(HAVE_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING) 493#if defined(CONFIG_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING)
494 !charger_inserted() && 494 !charger_inserted() &&
495#endif 495#endif
496 repeat_count > POWEROFF_COUNT) 496 repeat_count > POWEROFF_COUNT)
@@ -1248,7 +1248,7 @@ static int button_read(void)
1248 backlight_on(); 1248 backlight_on();
1249 } 1249 }
1250 /* TODO: add light handling for the remote */ 1250 /* TODO: add light handling for the remote */
1251 1251
1252 hold_button = button_hold(); 1252 hold_button = button_hold();
1253 remote_hold_button = remote_button_hold(); 1253 remote_hold_button = remote_button_hold();
1254 1254
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c
index c4b9fb5b7d..bda03b0f8b 100644
--- a/firmware/drivers/power.c
+++ b/firmware/drivers/power.c
@@ -29,7 +29,7 @@
29#include "pcf50606.h" 29#include "pcf50606.h"
30#include "usb.h" 30#include "usb.h"
31 31
32#ifdef HAVE_CHARGE_CTRL 32#if CONFIG_CHARGING == CHARGING_CONTROL
33bool charger_enabled; 33bool charger_enabled;
34#endif 34#endif
35 35
@@ -92,7 +92,7 @@ void power_init(void)
92 or_b(0x20, &PBIORL); 92 or_b(0x20, &PBIORL);
93 or_b(0x20, &PBDRL); /* hold power */ 93 or_b(0x20, &PBDRL); /* hold power */
94#endif 94#endif
95#ifdef HAVE_CHARGE_CTRL 95#if CONFIG_CHARGING == CHARGING_CONTROL
96 PBCR2 &= ~0x0c00; /* GPIO for PB5 */ 96 PBCR2 &= ~0x0c00; /* GPIO for PB5 */
97 or_b(0x20, &PBIORL); /* Set charging control bit to output */ 97 or_b(0x20, &PBIORL); /* Set charging control bit to output */
98 charger_enable(false); /* Default to charger OFF */ 98 charger_enable(false); /* Default to charger OFF */
@@ -106,7 +106,7 @@ void power_init(void)
106} 106}
107 107
108 108
109#ifdef HAVE_CHARGING 109#ifdef CONFIG_CHARGING
110bool charger_inserted(void) 110bool charger_inserted(void)
111{ 111{
112#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) 112#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
@@ -115,7 +115,7 @@ bool charger_inserted(void)
115 return (P7 & 0x80) == 0; 115 return (P7 & 0x80) == 0;
116#elif defined(IAUDIO_X5) 116#elif defined(IAUDIO_X5)
117 return (GPIO1_READ & 0x01000000)?true:false; 117 return (GPIO1_READ & 0x01000000)?true:false;
118#elif defined(HAVE_CHARGE_CTRL) 118#elif CONFIG_CHARGING == CHARGING_CONTROL
119 /* Recorder */ 119 /* Recorder */
120 return adc_read(ADC_EXT_POWER) > 0x100; 120 return adc_read(ADC_EXT_POWER) > 0x100;
121#elif defined (HAVE_FMADC) 121#elif defined (HAVE_FMADC)
@@ -133,9 +133,9 @@ bool charger_inserted(void)
133 return (PADR & 1) == 0; 133 return (PADR & 1) == 0;
134#endif 134#endif
135} 135}
136#endif /* HAVE_CHARGING */ 136#endif /* CONFIG_CHARGING */
137 137
138#ifdef HAVE_CHARGE_CTRL 138#if CONFIG_CHARGING == CHARGING_CONTROL
139void charger_enable(bool on) 139void charger_enable(bool on)
140{ 140{
141 if(on) 141 if(on)
@@ -151,14 +151,22 @@ void charger_enable(bool on)
151} 151}
152#endif 152#endif
153 153
154#ifdef HAVE_CHARGE_STATE 154#if CONFIG_CHARGING == CHARGING_MONITOR
155/* Returns true if the unit is charging the batteries. */ 155/* Returns true if the unit is charging the batteries. */
156bool charging_state(void) { 156bool charging_state(void) {
157#if defined(IRIVER_H100_SERIES) 157#if CONFIG_BATTERY == BATT_LIION2200
158 /* We use the information from the ADC_EXT_POWER ADC channel, which
159 tells us the charging current from the LTC1734. When DC is
160 connected (either via the external adapter, or via USB), we try
161 to determine if it is actively charging or only maintaining the
162 charge. My tests show that ADC readings below about 0x80 means
163 that the LTC1734 is only maintaining the charge. */
164 return adc_read(ADC_EXT_POWER) >= 0x80;
165#elif defined(IRIVER_H100_SERIES) /* FIXME */
158 return charger_inserted(); 166 return charger_inserted();
159#elif defined(IRIVER_H300_SERIES) 167#elif defined IRIVER_H300_SERIES
160 return (GPIO_READ & 0x00800000)?true:false; 168 return (GPIO_READ & 0x00800000)?true:false;
161#elif defined(IPOD_VIDEO) 169#elif defined IPOD_VIDEO
162 return (GPIOB_INPUT_VAL & 0x01)?false:true; 170 return (GPIOB_INPUT_VAL & 0x01)?false:true;
163#endif 171#endif
164} 172}