Library for AE-KXSD9(3 axis accelerometer Module KXSD9-2050)

Dependents:   LPC1768_AE_KXSD9

Committer:
Naoto_111
Date:
Fri May 16 14:10:09 2014 +0000
Revision:
0:809f34a09f98
first release; some functions are unimplemented

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Naoto_111 0:809f34a09f98 1 #ifndef KXSD9_2050_H
Naoto_111 0:809f34a09f98 2 #define KXSD9_2050_H
Naoto_111 0:809f34a09f98 3
Naoto_111 0:809f34a09f98 4 #include "mbed.h"
Naoto_111 0:809f34a09f98 5
Naoto_111 0:809f34a09f98 6 class KXSD9_2050
Naoto_111 0:809f34a09f98 7 {
Naoto_111 0:809f34a09f98 8 public:
Naoto_111 0:809f34a09f98 9 KXSD9_2050(PinName sda, PinName scl, int addr1, int addr2);//constructor
Naoto_111 0:809f34a09f98 10 //~KXSD9_2050();//destructor(unimplemented)
Naoto_111 0:809f34a09f98 11 void init();//initialization(required)
Naoto_111 0:809f34a09f98 12 void read_xyz(double *x, double *y, double *z);//read each axial acceleration(unit:g)
Naoto_111 0:809f34a09f98 13 double read_x();//read the acceleration in x-axis(unit:g)
Naoto_111 0:809f34a09f98 14 double read_y();//read the acceleration in y-axis(unit:g)
Naoto_111 0:809f34a09f98 15 double read_z();//read the acceleration in z-axis(unit:g)
Naoto_111 0:809f34a09f98 16 //char read_reg(char addr);//read from KXSD9_2050 register(unimplemented)
Naoto_111 0:809f34a09f98 17 //void write_reg(char addr, char data); //write register(unimplemented)
Naoto_111 0:809f34a09f98 18 enum{
Naoto_111 0:809f34a09f98 19 XOUT_H=0x00, //the highest 8 bits of the acceleration in x-axis
Naoto_111 0:809f34a09f98 20 XOUT_L=0x01, //the lowest 4 bits of the acceleration in x-axis
Naoto_111 0:809f34a09f98 21 YOUT_H=0x02, //the highest 8 bits of the acceleration in y-axis
Naoto_111 0:809f34a09f98 22 YOUT_L=0x03, //the lowest 4 bits of the acceleration in y-axis
Naoto_111 0:809f34a09f98 23 ZOUT_H=0x04, //the highest 8 bits of the acceleration in z-axis
Naoto_111 0:809f34a09f98 24 ZOUT_L=0x05, //the lowest 4 bits of the acceleration in z-axis
Naoto_111 0:809f34a09f98 25 AUXOUT_H=0x06,
Naoto_111 0:809f34a09f98 26 AUXOUT_L=0x07,
Naoto_111 0:809f34a09f98 27 RESET_WRITE=0x0A,
Naoto_111 0:809f34a09f98 28 CTRL_REGC=0x0C,
Naoto_111 0:809f34a09f98 29 CTRL_REGB=0x0D,
Naoto_111 0:809f34a09f98 30 CTRL_REGA=0x0E,
Naoto_111 0:809f34a09f98 31 SENSITIVITY=819
Naoto_111 0:809f34a09f98 32 };
Naoto_111 0:809f34a09f98 33 private:
Naoto_111 0:809f34a09f98 34 I2C i2c_k;
Naoto_111 0:809f34a09f98 35 int addr_w, addr_r;
Naoto_111 0:809f34a09f98 36 };
Naoto_111 0:809f34a09f98 37
Naoto_111 0:809f34a09f98 38 #endif