Subversion Repositories freemyipod

Rev

Rev 622 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 622 Rev 734
Line 20... Line 20...
20
//
20
//
21
//
21
//
22
 
22
 
23
 
23
 
24
#include "global.h"
24
#include "global.h"
-
 
25
#include "i2c.h"
-
 
26
#include "timer.h"
25
#include "power.h"
27
#include "power.h"
26
 
28
 
27
 
29
 
-
 
30
long power_last_update;
-
 
31
bool power_last_state;
-
 
32
 
-
 
33
 
28
void reset();
34
void reset();
29
 
35
 
30
 
36
 
31
void power_off(void)
37
void power_off(void)
32
{
38
{
33
    reset();
39
    reset();
34
}
40
}
35
 
41
 
36
void power_init(void)
42
void power_init(void)
37
{
43
{
-
 
44
    power_last_update = 0;
38
}
45
}
39
 
46
 
40
bool charging_state(void)
47
bool charging_state(void)
41
{
48
{
42
    return false;
49
    return false;
43
}
50
}
44
 
51
 
45
bool external_power_state(void)
52
bool external_power_state(void)
46
{
53
{
47
    return false;
54
    return vbus_state();
48
}
55
}
49
 
56
 
50
bool vbus_state(void)
57
bool vbus_state(void)
51
{
58
{
-
 
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
    }
52
    return true;
64
    return power_last_state;
53
}
65
}
54
 
66
 
55
int read_battery_voltage(int battery)
67
int read_battery_voltage(int battery)
56
{
68
{
57
    return -1;
69
    return -1;