valeria toffoli / Mbed OS COG4050_adxrs290_adxrs453

Dependencies:   COG4050_ADT7420

Fork of COG4050_adxl355_adxl357-ver2 by ADI_CAC

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ADXRS453.h Source File

ADXRS453.h

00001 
00002 #ifndef ADXRS453_H_
00003 #define ADXRS453_H_
00004 
00005 class ADXRS453
00006 {
00007 public: 
00008     #define  gyro_sens 0.0125; // 80 [LSB/°/s]   
00009     #define  t_sens 0.2;      // 5 [LSB/°C]  
00010     // -------------------------- //
00011     // REGISTERS                  // 
00012     // -------------------------- //
00013     typedef enum {
00014         RATE1 = 0x00,
00015         RATE0 = 0x01,
00016         TEMP1 = 0x02,
00017         TEMP0 = 0x03,
00018         LOCST1 = 0x04,
00019         LOCST0 = 0x05,
00020         HICST1 = 0x06,
00021         HICST0 = 0x07,
00022         QUAD1 = 0x08,
00023         QUAD0 = 0x09,
00024         FAULT1 = 0x0A,
00025         FAULT0 = 0x0B,
00026         PID1 = 0x0C,
00027         PID0 = 0x0D,
00028         SN3 = 0x0E,
00029         SN2 = 0x0F,
00030         SN1 = 0x10,
00031         SN0 = 0x11
00032     } ADXRS453_register_t;
00033     // -------------------------- //
00034     // OUTPUT DATA                //
00035     // -------------------------- //
00036     typedef struct  {
00037         float rt_x;
00038         float rt_y;
00039         float rt_z;
00040     } ADXRS453_rate_t;
00041     ADXRS453_rate_t rate_data;
00042     ADXRS453_rate_t selftest_data; 
00043     // -------------------------- //
00044     // FUNCTIONS                  //  
00045     // -------------------------- //
00046     // SPI configuration & constructor 
00047     ADXRS453(PinName cs_pin , PinName MOSI , PinName MISO , PinName SCK );
00048     void frequency(int hz);
00049     // SPI configuration & constructor 
00050     void write_reg(ADXRS453_register_t reg, uint16_t data);
00051     uint16_t read_reg(ADXRS453_register_t reg);
00052     // ADXRS X/T/SelfTest scanning methods   
00053     uint16_t scanx();
00054     uint16_t scant();
00055     uint16_t scanst();
00056     uint16_t fault();
00057     // 
00058     void st();
00059 private:
00060     // SPI adxl355;                 ///< SPI instance of the ADXL
00061     SPI adxrs453; DigitalOut cs;
00062     const static uint8_t _DEVICE_AD = 0xR01;     // contect of DEVID_AD (only-read) register 
00063     const static uint8_t _DUMMY_BYTE = 0xAA;    // 10101010
00064     const static uint8_t _WRITE_REG_CMD = 0x40; // write register
00065     const static uint8_t _READ_REG_CMD = 0x80;  // read register
00066     const static uint8_t _SPI_MODE = 0;         // timing scheme
00067 };
00068  
00069 #endif