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