Self test boot program for testing icarus sensors

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_UARTConsole by Bluetooth Low Energy

Revision:
13:ef0ce8fa871f
Parent:
12:9076e6453115
Child:
14:cb369746225d
--- a/ADXL362Sensor.cpp	Tue Mar 03 20:00:21 2015 +0000
+++ b/ADXL362Sensor.cpp	Sun Apr 05 09:54:04 2015 +0000
@@ -1,13 +1,11 @@
 #include "ADXL362Sensor.h"
-#include "mbed.h"
+
 
-#ifndef LOG
-#define LOG(...) do printf(__VA_ARGS__); while (0)
-#endif
 
-ADXL362Sensor::ADXL362Sensor(SPI& spi_,DigitalOut& cs_) : BaseSensor(), spi(spi_), cs(cs_)  {    
+ADXL362Sensor::ADXL362Sensor(SPI& spi_,DigitalOut& cs_,void (*debug_)(const char* format, ...)) : BaseSensor(debug_), spi(spi_), cs(cs_)  {    
     cs = UP;
 }
+
  
 char* ADXL362Sensor::getSimpleName() {
     return "ADXL362";
@@ -57,13 +55,15 @@
     int16_t x12,y12,z12;
     int16_t test_x12,test_y12,test_z12;
 // 1. Read acceleration data for the x-, y-, and z-axes.    
-    refreshAcceleration12(&x12, &y12, &z12);    
+    refreshAcceleration12(&x12, &y12, &z12); 
+    LOG("Acc1: %d %d %d\r\n",x12,y12,z12);   
 // 2. Assert self test by setting the ST bit in the SELF_TEST register, Address 0x2E.
     writeRegister(ADXL362_SELF_TEST,0x01);
 // 3. Wait 1/ODR for the output to settle to its new value.
     wait(1/ADXL362_ODR);
 // 4. Read acceleration data for the x-, y-, and z-axes.
     refreshAcceleration12(&test_x12, &test_y12, &test_z12);
+    LOG("Acc2: %d %d %d\r\n",test_x12,test_y12,test_z12);   
 // 5. Compare to the values from Step 1, and convert the difference from LSB to mg by multiplying by the sensitivity. If the observed difference falls within the self test output change specification listed in Table 1, then the device passes self test and is deemed operational.
     float reactionX = (x12-test_x12)* ADXL362_MG2G_MULTIPLIER * SENSORS_GRAVITY_STANDARD / ADXL362_SELF_TEST_SCALE_FACTOR;
     float reactionY = (y12-test_y12)* ADXL362_MG2G_MULTIPLIER * SENSORS_GRAVITY_STANDARD / ADXL362_SELF_TEST_SCALE_FACTOR;
@@ -77,7 +77,7 @@
     }
     
 // 6. Deassert self test by clearing the ST bit in the SELF_TEST register, Address 0x2E.
-    writeRegister(ADXL362_SELF_TEST,0x01);
+    writeRegister(ADXL362_SELF_TEST,0x00);
     
     return errors;
 }