Vince et Yann / Mbed 2 deprecated APP1_customProtocole

Dependencies:   mbed

Fork of APP1_customProtocole by Yann Lemay-Sévigny

Revision:
4:e6df056992c1
Parent:
3:b3574c385012
Child:
6:5c8e02d5ebcc
--- a/acceleroMMA8452Q.cpp	Sun Jan 10 21:55:39 2016 +0000
+++ b/acceleroMMA8452Q.cpp	Sun Jan 10 23:03:40 2016 +0000
@@ -10,15 +10,16 @@
 
 void Accelero::init(int frequency)
 {
+    i2cPort.frequency(frequency);
+    
     char command[2];
     command[0] = 0x2B;
     command[1] = 0x40;
     
-    i2cPort.write(ACCELERO_WRITE_ADRESS, command, 1, false);
+    i2cPort.write(ACCELERO_WRITE_ADRESS, command, 2, false);
     wait(0.1);
     
     char response = 0x00;
-    i2cPort.frequency(frequency);
     i2cPort.write(ACCELERO_WRITE_ADRESS, &ACCELERO_REGISTER_WHO_AM_I, 1, true);
     i2cPort.read(ACCELERO_READ_ADRESS, &response, 1, false);
     
@@ -31,7 +32,7 @@
     command[0] = ACCELERO_REGISTER_CTRL_REG1;
     command[1] = 0x01; //Put accelro in active mode
     
-    i2cPort.write(ACCELERO_WRITE_ADRESS, command, 1, false);
+    i2cPort.write(ACCELERO_WRITE_ADRESS, command, 2, false);
 }
 
 vector Accelero::getAccelVector()