app3

Dependencies:   mbed

Fork of Code_APP1 by Louis Beaulieu

Committer:
ericbisson
Date:
Tue Feb 14 04:11:07 2017 +0000
Revision:
9:dc81d8ee4a97
app3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ericbisson 9:dc81d8ee4a97 1 #include "Accelerometer.h"
ericbisson 9:dc81d8ee4a97 2
ericbisson 9:dc81d8ee4a97 3 I2C accel(p28, p27);
ericbisson 9:dc81d8ee4a97 4 bool bIsInitialized = false;
ericbisson 9:dc81d8ee4a97 5
ericbisson 9:dc81d8ee4a97 6 //--------------------------------------------------------------//
ericbisson 9:dc81d8ee4a97 7 // Fonction pour l'envoie de données de l'accéléromètre
ericbisson 9:dc81d8ee4a97 8 // Testé et fonctionnel
ericbisson 9:dc81d8ee4a97 9 //--------------------------------------------------------------//
ericbisson 9:dc81d8ee4a97 10 void func_accel(CArray* DATA_TO_SEND)
ericbisson 9:dc81d8ee4a97 11 {
ericbisson 9:dc81d8ee4a97 12 if (!bIsInitialized)
ericbisson 9:dc81d8ee4a97 13 {
ericbisson 9:dc81d8ee4a97 14 char activation[2] = {0x2A, 0x03};
ericbisson 9:dc81d8ee4a97 15 char fullScale[2] = {0x0E, 0x00};
ericbisson 9:dc81d8ee4a97 16 accel.write(0x3A, activation, 2, true);
ericbisson 9:dc81d8ee4a97 17 accel.write(0x3A, fullScale, 2, true);
ericbisson 9:dc81d8ee4a97 18 bIsInitialized = true;
ericbisson 9:dc81d8ee4a97 19 }
ericbisson 9:dc81d8ee4a97 20 DATA_TO_SEND->_ptr = new char[3];
ericbisson 9:dc81d8ee4a97 21 accel.write(0x3A, DATA_TO_SEND->_ptr, 1, true);
ericbisson 9:dc81d8ee4a97 22 accel.read(0x3A, DATA_TO_SEND->_ptr, 3);
ericbisson 9:dc81d8ee4a97 23 DATA_TO_SEND->size = 3;
ericbisson 9:dc81d8ee4a97 24 }
ericbisson 9:dc81d8ee4a97 25 //--------------------------------------------------------------//