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