Subversion Repositories freemyipod

Rev

Go to most recent revision | Details | 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
{
734 theseven 59
    if (TIMEOUT_EXPIRED(power_last_update, 200000))
60
    {
61
        power_last_update = USEC_TIMER;
62
        power_last_state = !!(i2c_recvbyte(0, 0xe6, 4) & 0x40);
63
    }
64
    return power_last_state;
221 theseven 65
}
622 theseven 66
 
67
int read_battery_voltage(int battery)
68
{
69
    return -1;
70
}
71
 
72
int read_battery_current(int battery)
73
{
74
    return -1;
75
}
76
 
77
int read_battery_mwh_design(int battery)
78
{
79
    return -1;
80
}
81
 
82
int read_battery_mwh_full(int battery)
83
{
84
    return -1;
85
}
86
 
87
int read_battery_mwh_current(int battery)
88
{
89
    return -1;
90
}
91
 
92
int read_battery_mw(int battery)
93
{
94
    return -1;
95
}
96
 
846 theseven 97
enum battery_state read_battery_state(int battery)
622 theseven 98
{
846 theseven 99
    if (battery != 0) return BATTERY_STATE_INVALID;
100
    return BATTERY_STATE_UNKNOWN;
101
}
102
 
103
int read_input_voltage(int input)
104
{
622 theseven 105
    return -1;
106
}
107
 
846 theseven 108
int read_input_current(int input)
622 theseven 109
{
846 theseven 110
    return -1;
622 theseven 111
}
846 theseven 112
 
113
int read_input_mw(int input)
114
{
115
    return -1;
116
}
117
 
847 theseven 118
enum input_state read_input_state(int input)
846 theseven 119
{
120
    if (input != 0) return INPUT_STATE_INVALID;
121
    return INPUT_STATE_UNKNOWN;
847 theseven 122
}