Line 13... |
Line 13... |
13 |
unsigned int8 reg; |
13 |
unsigned int8 reg; |
14 |
|
14 |
|
15 |
i2c_start(); // Start condition |
15 |
i2c_start(); // Start condition |
16 |
i2c_write(0x80); // Device address |
16 |
i2c_write(0x80); // Device address |
17 |
i2c_write(0xE7); // Device command |
17 |
i2c_write(0xE7); // Device command |
18 |
// i2c_stop(); // Stop condition |
- |
|
19 |
|
18 |
|
20 |
i2c_start(); // Start condition |
19 |
i2c_start(); // Start condition |
21 |
i2c_write(0x81); // Device address |
20 |
i2c_write(0x81); // Device address |
22 |
reg=i2c_read(0); // Device command |
21 |
reg=i2c_read(0); // Device command |
23 |
i2c_stop(); // Stop condition |
22 |
i2c_stop(); // Stop condition |
Line 41... |
Line 40... |
41 |
I2C_Write(0x81); |
40 |
I2C_Write(0x81); |
42 |
MSB=i2c_read(1); |
41 |
MSB=i2c_read(1); |
43 |
LSB=i2c_read(1); |
42 |
LSB=i2c_read(1); |
44 |
Check=i2c_read(0); |
43 |
Check=i2c_read(0); |
45 |
i2c_stop(); |
44 |
i2c_stop(); |
46 |
|
- |
|
47 |
printf("%X %X %X\r\n",MSB, LSB, Check); |
- |
|
48 |
|
45 |
|
49 |
LSB = LSB >> 2; // trow out status bits |
46 |
LSB = LSB >> 2; // trow out status bits |
50 |
|
47 |
|
51 |
data = (((unsigned int16) MSB << 8) + (LSB << 4)); |
48 |
data = (((unsigned int16) MSB << 8) + (LSB << 4)); |
52 |
return(-46.85 + 175.72*((float)data/0xFFFF)); |
49 |
return(-46.85 + 175.72*((float)data/0xFFFF)); |
53 |
} |
50 |
} |
Line 69... |
Line 66... |
69 |
MSB=i2c_read(1); |
66 |
MSB=i2c_read(1); |
70 |
LSB=i2c_read(1); |
67 |
LSB=i2c_read(1); |
71 |
Check=i2c_read(0); |
68 |
Check=i2c_read(0); |
72 |
i2c_stop(); |
69 |
i2c_stop(); |
73 |
|
70 |
|
74 |
printf("%X %X %X\r\n",MSB, LSB, Check); |
71 |
// printf("%X %X %X\r\n",MSB, LSB, Check); |
75 |
|
72 |
|
76 |
LSB = LSB >> 2; // trow out status bits |
73 |
LSB = LSB >> 2; // trow out status bits |
77 |
|
74 |
|
78 |
data = (((unsigned int16) MSB << 8) + (LSB << 4) ); |
75 |
data = (((unsigned int16) MSB << 8) + (LSB << 4) ); |
79 |
return( -6.0 + 125.0*((float)data/0xFFFF)); |
76 |
return( -6.0 + 125.0*((float)data/0xFFFF)); |