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

Dependents:   LPC1768_AE_KXSD9

Committer:
Naoto_111
Date:
Fri May 16 14:17:37 2014 +0000
Revision:
1:4dc1a0ac0cf1
first release; some functions unimplemented

Who changed what in which revision?

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