John Scharf
/
Hat_Board_v5
accel now workin
Fork of Hat_Board_Test by
Diff: SI_LIS.cpp
- Revision:
- 1:2efeed26d93a
- Parent:
- 0:34bad5aca893
- Child:
- 2:3a8cd127b72a
--- a/SI_LIS.cpp Thu Mar 20 02:50:57 2014 +0000 +++ b/SI_LIS.cpp Thu Mar 20 09:03:12 2014 +0000 @@ -7,7 +7,7 @@ unsigned int IR; extern char rx_data[4]; extern char accel_2_data[2]; -extern char accel_data; +extern char accel_data[6]; void restart() { @@ -104,7 +104,6 @@ return 0; } - char read_reg (/*unsigned*/ char address, int num_data) // Read a register { char tx[1]; @@ -119,7 +118,6 @@ void write_reg(char address, char num_data) // Write a resigter { char tx[2]; - tx[0] = address; tx[1] = num_data; i2c.write((IR_ADDRESS << 1) & 0xFE, tx, 2); @@ -143,7 +141,7 @@ i2c.write((LIS_Addr << 1) & 0xFE , ®, 1 ); // Write register number i2c.read ((LIS_Addr << 1) | 0x01, &data, 1 ); // Receive Byte from Slave - accel_data = data; + accel_data[0] = data; } void Get_Accel_Register_2 (char Reg_Num) // Read 2 registers @@ -159,6 +157,14 @@ i2c.read((LIS_Addr << 1) | 0x01, accel_2_data, 2); } +void Get_Accel_Reg_6 (char Reg_Num) // Read 6 registers +{ + char reg; + reg = Reg_Num | 0x80; // set bit 7 high + i2c.write((LIS_Addr << 1) & 0xFE, ®, 1); + i2c.read((LIS_Addr << 1) | 0x01, accel_data, 6); +} + void i2c_start() // also set by photodiode setup/reset { i2c.frequency(400000);