12 #include "simplei2c.h" 13 #include "simpletext.h" 14 #include "simpletools.h" 18 int ee_writeBuffer(
i2c *bus,
int devaddr,
int address,
unsigned char *buffer,
int count)
21 int upaddr = ((address >> 16) & 0x07) << 1;
24 i2c_writeByte(bus, devaddr | upaddr);
25 i2c_writeByte(bus, (address >> 8) & 0xff);
26 i2c_writeByte(bus, address & 0xff);
27 result = i2c_writeData(bus, buffer, count);
30 }
while(i2c_poll(bus, 0xA0));
34 int ee_readBuffer(
i2c *bus,
int devaddr,
int address,
unsigned char *buffer,
int count)
37 int upaddr = ((address >> 16) & 0x07) << 1;
39 i2c_writeByte(bus, devaddr | upaddr);
40 i2c_writeByte(bus, (address >> 8) & 0xff);
41 i2c_writeByte(bus, (address) & 0xff);
43 i2c_writeByte(bus, devaddr | 1);
44 result = i2c_readData(bus, buffer, count);
59 text_t *termp = simpleterm_pointer();
62 i2c_open(&eebus, 28, 29, 1);
94 print(
"ack = %d\n", ack);
95 x16 = (data[0] << 8) | data[1];
96 z16 = (data[2] << 8) | data[3];
97 y16 = (data[4] << 8) | data[5];
110 float heading = atan2(x16, y16);
113 heading += 2.0 * 3.14;
116 float headingDegrees = heading * 180/3.14;
119 print(
"%c\nx=%d, y=%d, z=%d%c\n",
120 HOME, x, y, z, CLREOL);
121 print(
"heading = %f, \n",
123 waitcnt(CLKFREQ/2+CNT);
Structure that contains data used by simple text device libraries.