Rev Author Line No. Line
2953 jacho 1 int16 cteniBAT(byte lsb, byte msb)
2 {
3 int16 data = 0;
4 unsigned int8 h, l;
5 i2c_start();
6 I2C_Write(BAT_ADDR_W);
7 I2C_write(lsb);
8  
9 i2c_start();
10 I2C_Write(BAT_ADDR_R);
11 l=i2c_read(0);
12 i2c_stop();
13  
14 i2c_start();
15 I2C_Write(BAT_ADDR_W);
16 I2C_write(msb);
17 i2c_start();
18 I2C_Write(BAT_ADDR_R);
19 h=i2c_read(0);
20 i2c_stop();
21  
22 return data = (((unsigned int16) h << 8) + l );
23 }
24  
25 int16 batintT(void) //teplota baterie (pri vyrobnim nastaveni, je mozne zmenit na teplotu v IO
26 {
27 int16 data = cteniBAT(0x0C, 0x0D);
28 data = (data/10)-273;
29 return data;
30  
31 }
32  
33 int16 batNAP(void) //napeti baterie
34 {
35 int16 data = cteniBAT(0x08, 0x09);
36 return data;
37  
38 }
39  
40 int16 batPROUD(void) //proud z nebo do baterie
41 {
42 int16 data = cteniBAT(0x0A, 0x0B);
43 return data;
44  
45 }
46  
47 int16 batKAPAKT(void) //zbyvajici kapacita
48 {
49 int16 data = cteniBAT(0x04, 0x05);
50 return data;
51  
52 }
53 int16 batKAPMAX(void) //max. kapacita
54 {
55 int16 data = cteniBAT(0x06, 0x07);
56 return data;
57  
58 }
59  
60 int16 batSTAV(void) //zbytek energie v baterii v %
61 {
62 int16 data = cteniBAT(0x02, 0x03);
63 return data;
64  
65 }