work nice now
Fork of LSM303DLHC by
LSM303DLHC.h@3:4d9465e7e10e, 2013-02-20 (annotated)
- Committer:
- bclaus
- Date:
- Wed Feb 20 23:52:53 2013 +0000
- Revision:
- 3:4d9465e7e10e
- Child:
- 4:612f7d5a822d
This provides some updates for dealing with LSM303DLHC; biggest changes are to addresses for this chip but I have stripped things I didn't need.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bclaus | 3:4d9465e7e10e | 1 | #include "mbed.h" |
bclaus | 3:4d9465e7e10e | 2 | |
bclaus | 3:4d9465e7e10e | 3 | |
bclaus | 3:4d9465e7e10e | 4 | |
bclaus | 3:4d9465e7e10e | 5 | class LSM303DLHC { |
bclaus | 3:4d9465e7e10e | 6 | public: |
bclaus | 3:4d9465e7e10e | 7 | /** Create a new interface for an LSM303DLHC |
bclaus | 3:4d9465e7e10e | 8 | * |
bclaus | 3:4d9465e7e10e | 9 | * @param sda is the pin for the I2C SDA line |
bclaus | 3:4d9465e7e10e | 10 | * @param scl is the pin for the I2C SCL line |
bclaus | 3:4d9465e7e10e | 11 | */ |
bclaus | 3:4d9465e7e10e | 12 | LSM303DLHC(PinName sda, PinName scl); |
bclaus | 3:4d9465e7e10e | 13 | |
bclaus | 3:4d9465e7e10e | 14 | |
bclaus | 3:4d9465e7e10e | 15 | /** read the raw accelerometer and compass values |
bclaus | 3:4d9465e7e10e | 16 | * |
bclaus | 3:4d9465e7e10e | 17 | * @param ax,ay,az is the accelerometer 3d vector, written by the function |
bclaus | 3:4d9465e7e10e | 18 | * @param mx,my,mz is the magnetometer 3d vector, written by the function |
bclaus | 3:4d9465e7e10e | 19 | */ |
bclaus | 3:4d9465e7e10e | 20 | bool read(float *ax, float *ay, float *az, float *mx, float *my, float *mz); |
bclaus | 3:4d9465e7e10e | 21 | |
bclaus | 3:4d9465e7e10e | 22 | |
bclaus | 3:4d9465e7e10e | 23 | private: |
bclaus | 3:4d9465e7e10e | 24 | I2C _LSM303; |
bclaus | 3:4d9465e7e10e | 25 | |
bclaus | 3:4d9465e7e10e | 26 | |
bclaus | 3:4d9465e7e10e | 27 | float ax, ay, az; |
bclaus | 3:4d9465e7e10e | 28 | float mx, my, mz; |
bclaus | 3:4d9465e7e10e | 29 | |
bclaus | 3:4d9465e7e10e | 30 | bool write_reg(int addr_i2c,int addr_reg, char v); |
bclaus | 3:4d9465e7e10e | 31 | bool read_reg(int addr_i2c,int addr_reg, char *v); |
bclaus | 3:4d9465e7e10e | 32 | bool recv(char sad, char sub, char *buf, int length); |
bclaus | 3:4d9465e7e10e | 33 | }; |