Subversion Repositories freemyipod

Rev

Rev 878 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
85 theseven 1
//
2
//
3
//    Copyright 2010 TheSeven
4
//
5
//
427 farthen 6
//    This file is part of emCORE.
85 theseven 7
//
427 farthen 8
//    emCORE is free software: you can redistribute it and/or
85 theseven 9
//    modify it under the terms of the GNU General Public License as
10
//    published by the Free Software Foundation, either version 2 of the
11
//    License, or (at your option) any later version.
12
//
427 farthen 13
//    emCORE is distributed in the hope that it will be useful,
85 theseven 14
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
//    See the GNU General Public License for more details.
17
//
18
//    You should have received a copy of the GNU General Public License along
427 farthen 19
//    with emCORE.  If not, see <http://www.gnu.org/licenses/>.
85 theseven 20
//
21
//
22
 
23
 
24
#include "global.h"
734 theseven 25
#include "i2c.h"
26
#include "timer.h"
85 theseven 27
#include "power.h"
28
 
29
 
734 theseven 30
long power_last_update;
31
bool power_last_state;
32
 
33
 
85 theseven 34
void reset();
35
 
36
 
37
void power_off(void)
38
{
39
    reset();
40
}
41
 
42
void power_init(void)
43
{
734 theseven 44
    power_last_update = 0;
85 theseven 45
}
46
 
47
bool charging_state(void)
48
{
49
    return false;
50
}
221 theseven 51
 
52
bool external_power_state(void)
53
{
734 theseven 54
    return vbus_state();
221 theseven 55
}
56
 
57
bool vbus_state(void)
58
{
878 theseven 59
    return true;
734 theseven 60
    if (TIMEOUT_EXPIRED(power_last_update, 200000))
61
    {
62
        power_last_update = USEC_TIMER;
63
        power_last_state = !!(i2c_recvbyte(0, 0xe6, 4) & 0x40);
64
    }
65
    return power_last_state;
221 theseven 66
}
622 theseven 67
 
68
int read_battery_voltage(int battery)
69
{
70
    return -1;
71
}
72
 
73
int read_battery_current(int battery)
74
{
75
    return -1;
76
}
77
 
78
int read_battery_mwh_design(int battery)
79
{
80
    return -1;
81
}
82
 
83
int read_battery_mwh_full(int battery)
84
{
85
    return -1;
86
}
87
 
88
int read_battery_mwh_current(int battery)
89
{
90
    return -1;
91
}
92
 
93
int read_battery_mw(int battery)
94
{
95
    return -1;
96
}
97
 
846 theseven 98
enum battery_state read_battery_state(int battery)
622 theseven 99
{
846 theseven 100
    if (battery != 0) return BATTERY_STATE_INVALID;
101
    return BATTERY_STATE_UNKNOWN;
102
}
103
 
104
int read_input_voltage(int input)
105
{
622 theseven 106
    return -1;
107
}
108
 
846 theseven 109
int read_input_current(int input)
622 theseven 110
{
846 theseven 111
    return -1;
622 theseven 112
}
846 theseven 113
 
114
int read_input_mw(int input)
115
{
116
    return -1;
117
}
118
 
847 theseven 119
enum input_state read_input_state(int input)
846 theseven 120
{
121
    if (input != 0) return INPUT_STATE_INVALID;
122
    return INPUT_STATE_UNKNOWN;
847 theseven 123
}