Finished project.

Dependencies:   X_NUCLEO_COMMON

Fork of ReferredCoursework2016 by Stage-1 Students SoCEM

sensor.cpp

Committer:
J_Satchell
Date:
2017-08-17
Revision:
90:38dfa3f350aa
Child:
91:cd9fcd45ecf6

File content as of revision 90:38dfa3f350aa:

/*sensor.cpp simply reads in the acceleration measurements
using the NUCLEO board and using the function and struct
from buffer.cpp, stores the values in to the circular buffer*/
#include "mbed.h"
#include "x_nucleo_iks01a1.h"
#include "buffer.h"
#include "sensor.h"

/* Instantiate the expansion board */
static X_NUCLEO_IKS01A1 *mems_expansion_board = X_NUCLEO_IKS01A1::Instance(D14, D15);

/* Retrieve the composing elements of the expansion board */
static MotionSensor *accelerometer = mems_expansion_board->GetAccelerometer();

extern char *printDouble(char* str, double v, int decimalDigits = 2);

int32_t axes[3];

void sensor_run(){
     while (1) {
   
    accelerometer->Get_X_Axes(axes);

    AccelData d;
    d.x = axes[0];
    d.y = axes[1];
    d.z = axes[2];  
    
    log_push(d);
    }

}