Index: emcore/trunk/target/ipodnano2g/power.c |
— | — | @@ -67,3 +67,53 @@ |
68 | 68 | {
|
69 | 69 | return (PDAT14 & 8) ? false : true;
|
70 | 70 | }
|
| 71 | +
|
| 72 | +int read_battery_voltage(int battery)
|
| 73 | +{
|
| 74 | + if (battery == 0) return pmu_read_battery_voltage();
|
| 75 | + return -1;
|
| 76 | +}
|
| 77 | +
|
| 78 | +int read_battery_current(int battery)
|
| 79 | +{
|
| 80 | + if (battery == 0) return pmu_read_battery_current();
|
| 81 | + return -1;
|
| 82 | +}
|
| 83 | +
|
| 84 | +int read_battery_mwh_design(int battery)
|
| 85 | +{
|
| 86 | + if (battery == 0) return 1480;
|
| 87 | + return -1;
|
| 88 | +}
|
| 89 | +
|
| 90 | +int read_battery_mwh_full(int battery)
|
| 91 | +{
|
| 92 | + if (battery == 0) return 1480;
|
| 93 | + return -1;
|
| 94 | +}
|
| 95 | +
|
| 96 | +int read_battery_mwh_current(int battery)
|
| 97 | +{
|
| 98 | + // TODO: Approximate that better
|
| 99 | + if (battery == 0) return (read_battery_voltage(0) - 3600) * 2;
|
| 100 | + return -1;
|
| 101 | +}
|
| 102 | +
|
| 103 | +int read_battery_mw(int battery)
|
| 104 | +{
|
| 105 | + if (battery == 0) return read_battery_current(0) * 3700 / 1000;
|
| 106 | + return -1;
|
| 107 | +}
|
| 108 | +
|
| 109 | +int read_input_mw(int battery)
|
| 110 | +{
|
| 111 | + return -1;
|
| 112 | +}
|
| 113 | +
|
| 114 | +enum battery_state read_battery_state(int battery)
|
| 115 | +{
|
| 116 | + if (battery != 0) return BATTERY_STATE_INVALID;
|
| 117 | + if (charging_state()) return BATTERY_STATE_CHARGING;
|
| 118 | + if (external_power_state()) return BATTERY_STATE_IDLE;
|
| 119 | + return BATTERY_STATE_DISCHARGING;
|
| 120 | +}
|
Index: emcore/trunk/target/ipodnano3g/pmu.c |
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | /* milliamps */
|
82 | 82 | int pmu_read_battery_current(void)
|
83 | 83 | {
|
84 | | - return pmu_read_adc(2);
|
| 84 | + return -1;
|
85 | 85 | }
|
86 | 86 |
|
87 | 87 | void pmu_ldo_on_in_standby(unsigned int ldo, int onoff)
|
Index: emcore/trunk/target/ipodnano3g/power.c |
— | — | @@ -57,3 +57,52 @@ |
58 | 58 | {
|
59 | 59 | return (PDAT(12) & 8) ? false : true;
|
60 | 60 | }
|
| 61 | +
|
| 62 | +int read_battery_voltage(int battery)
|
| 63 | +{
|
| 64 | + if (battery == 0) return pmu_read_battery_voltage();
|
| 65 | + return -1;
|
| 66 | +}
|
| 67 | +
|
| 68 | +int read_battery_current(int battery)
|
| 69 | +{
|
| 70 | + if (battery == 0) return pmu_read_battery_current();
|
| 71 | + return -1;
|
| 72 | +}
|
| 73 | +
|
| 74 | +int read_battery_mwh_design(int battery)
|
| 75 | +{
|
| 76 | + if (battery == 0) return 2035;
|
| 77 | + return -1;
|
| 78 | +}
|
| 79 | +
|
| 80 | +int read_battery_mwh_full(int battery)
|
| 81 | +{
|
| 82 | + if (battery == 0) return 2035;
|
| 83 | + return -1;
|
| 84 | +}
|
| 85 | +
|
| 86 | +int read_battery_mwh_current(int battery)
|
| 87 | +{
|
| 88 | + // TODO: Approximate that better
|
| 89 | + if (battery == 0) return (read_battery_voltage(0) - 3600) * 3;
|
| 90 | + return -1;
|
| 91 | +}
|
| 92 | +
|
| 93 | +int read_battery_mw(int battery)
|
| 94 | +{
|
| 95 | + return -1;
|
| 96 | +}
|
| 97 | +
|
| 98 | +int read_input_mw(int battery)
|
| 99 | +{
|
| 100 | + return -1;
|
| 101 | +}
|
| 102 | +
|
| 103 | +enum battery_state read_battery_state(int battery)
|
| 104 | +{
|
| 105 | + if (battery != 0) return BATTERY_STATE_INVALID;
|
| 106 | + if (charging_state()) return BATTERY_STATE_CHARGING;
|
| 107 | + if (external_power_state()) return BATTERY_STATE_IDLE;
|
| 108 | + return BATTERY_STATE_DISCHARGING;
|
| 109 | +}
|
Index: emcore/trunk/target/ipodnano4g/power.c |
— | — | @@ -51,3 +51,44 @@ |
52 | 52 | {
|
53 | 53 | return true;
|
54 | 54 | }
|
| 55 | +
|
| 56 | +int read_battery_voltage(int battery)
|
| 57 | +{
|
| 58 | + return -1;
|
| 59 | +}
|
| 60 | +
|
| 61 | +int read_battery_current(int battery)
|
| 62 | +{
|
| 63 | + return -1;
|
| 64 | +}
|
| 65 | +
|
| 66 | +int read_battery_mwh_design(int battery)
|
| 67 | +{
|
| 68 | + return -1;
|
| 69 | +}
|
| 70 | +
|
| 71 | +int read_battery_mwh_full(int battery)
|
| 72 | +{
|
| 73 | + return -1;
|
| 74 | +}
|
| 75 | +
|
| 76 | +int read_battery_mwh_current(int battery)
|
| 77 | +{
|
| 78 | + return -1;
|
| 79 | +}
|
| 80 | +
|
| 81 | +int read_battery_mw(int battery)
|
| 82 | +{
|
| 83 | + return -1;
|
| 84 | +}
|
| 85 | +
|
| 86 | +int read_input_mw(int battery)
|
| 87 | +{
|
| 88 | + return -1;
|
| 89 | +}
|
| 90 | +
|
| 91 | +enum battery_state read_battery_state(int battery)
|
| 92 | +{
|
| 93 | + if (battery != 0) return BATTERY_STATE_INVALID;
|
| 94 | + return BATTERY_STATE_UNKNOWN;
|
| 95 | +}
|
Index: emcore/trunk/power.h |
— | — | @@ -27,11 +27,31 @@ |
28 | 28 |
|
29 | 29 | #include "global.h"
|
30 | 30 |
|
| 31 | +
|
| 32 | +enum battery_state
|
| 33 | +{
|
| 34 | + BATTERY_STATE_UNKNOWN,
|
| 35 | + BATTERY_STATE_INVALID,
|
| 36 | + BATTERY_STATE_NONPRESENT,
|
| 37 | + BATTERY_STATE_IDLE,
|
| 38 | + BATTERY_STATE_CHARGING,
|
| 39 | + BATTERY_STATE_DISCHARGING
|
| 40 | +};
|
| 41 | +
|
| 42 | +
|
31 | 43 | void power_off(void);
|
32 | 44 | void power_init(void) INITCODE_ATTR;
|
33 | 45 | bool charging_state(void);
|
34 | 46 | bool external_power_state(void);
|
35 | 47 | bool vbus_state(void);
|
| 48 | +int read_battery_voltage(int battery);
|
| 49 | +int read_battery_current(int battery);
|
| 50 | +int read_battery_mwh_design(int battery);
|
| 51 | +int read_battery_mwh_full(int battery);
|
| 52 | +int read_battery_mwh_current(int battery);
|
| 53 | +int read_battery_mw(int battery);
|
| 54 | +int read_input_mw(int battery);
|
| 55 | +enum battery_state read_battery_state(int battery);
|
36 | 56 |
|
37 | 57 |
|
38 | 58 | #endif
|