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