Icarus Sensors / Mbed 2 deprecated SelfTestBoot

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_UARTConsole by Bluetooth Low Energy

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ADXL362Sensor.h Source File

ADXL362Sensor.h

00001 #ifndef MBED_ADXL362_SENSOR_H
00002 #define MBED_ADXL362_SENSOR_H
00003  
00004 #include "mbed.h"
00005 
00006 #include "BaseSensor.h"
00007 
00008 // ACC Registers
00009 #define ADXL362_DEVID_AD 0x00
00010 #define ADXL362_DEVID_MST 0x01
00011 #define ADXL362_PART_ID 0x02
00012 #define ADXL362_REV_ID 0x03
00013 
00014 //Three following addresses
00015 #define ADXL362_DATA 0x08
00016 
00017 #define ADXL362_STATUS 0x0b
00018 #define ADXL362_FIFO_ENTRIES_L 0x0c
00019 #define ADXL362_FIFO_ENTRIES_H 0x0d
00020 
00021 //Six following address as L & H
00022 #define ADXL362_DATA_12 0x0E
00023 
00024 //Two following bytes
00025 #define ADXL362_TEMP_12 0x14
00026 
00027 
00028 #define ADXL362_SOFT_RESET 0x1f
00029 #define ADXL362_THRESH_ACT_11 0x20
00030 #define ADXL362_TIME_ACT 0x22
00031 #define ADXL362_THRESH_INACT_11 0x20
00032 #define ADXL362_TIME_INACT_16 0x22
00033 #define ADXL362_ACT_INACT_CTL 0x27
00034 #define ADXL362_FIFO_CONTROL 0x28
00035 #define ADXL362_FIFO_SAMPLES 0x29
00036 #define ADXL362_INTMAP1 0x2a
00037 #define ADXL362_INTMAP2 0x2b
00038 #define ADXL362_FILTER_CTL 0x2c
00039 #define ADXL362_POWER_CTL 0x2d
00040 #define ADXL362_SELF_TEST 0x2e
00041  
00042 /**The ADXL362 command set is
00043 • 0x0A: write register
00044 • 0x0B: read register
00045 • 0x0D: read FIFO
00046 */ 
00047 #define ADXL362_WRITE_REGISTER 0x0a
00048 #define ADXL362_READ_REGISTER 0x0b
00049 #define ADXL362_READ_FIFO 0x0d
00050 
00051 #define ADXL362_SELF_TEST_SCALE_FACTOR 2.4f
00052 #define ADXL362_MG2G_MULTIPLIER 0.002f
00053 #define ADXL362_ODR 100.0f
00054 
00055  
00056 class ADXL362Sensor : public BaseSensor {
00057 
00058 public:
00059 //The recommended SPI clock speeds are 1 MHz to 5 MHz, with 12 pF maximum loading.
00060     ADXL362Sensor(SPI&,DigitalOut&, void (*debug_)(const char* format, ...)=0);
00061     virtual char* getSimpleName();
00062     virtual void getSensorDetails(sensor_t*);
00063     //verify basic integrity of underlining hardware
00064     virtual uint32_t verifyIntegrity(uint32_t*);  
00065 private:      
00066     SPI& spi; 
00067     DigitalOut& cs;
00068     
00069     uint32_t selfTest(uint32_t* errorResult);
00070     void refreshAcceleration12(int16_t* x, int16_t* y, int16_t* z);
00071     uint32_t readRegister32(uint8_t reg);
00072     uint8_t readRegister( uint8_t reg);
00073     void writeRegister( uint8_t reg, uint8_t cmd );
00074     
00075 };
00076  
00077 #endif