sketchbook
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Sensors.h
Go to the documentation of this file.
1 #ifndef SENSORS_H_
2 #define SENSORS_H_
3 
4 void ACC_getADC ();
5 void Gyro_getADC ();
6 uint8_t Mag_getADC();
7 uint8_t Baro_update();
8 void Sonar_update();
9 
10 void initSensors();
11 void i2c_rep_start(uint8_t address);
12 void i2c_write(uint8_t data );
13 void i2c_stop(void);
14 void i2c_write(uint8_t data );
15 void i2c_writeReg(uint8_t add, uint8_t reg, uint8_t val);
16 uint8_t i2c_readReg(uint8_t add, uint8_t reg);
17 uint8_t i2c_readAck();
18 uint8_t i2c_readNak();
19 
20 void i2c_read_reg_to_buf(uint8_t add, uint8_t reg, uint8_t *buf, uint8_t size);
21 
22 #if defined(MMA7455)
23  #define ACC_1G 64
24 #endif
25 #if defined(MMA8451Q)
26  #define ACC_1G 512
27 #endif
28 #if defined(ADXL345)
29  #define ACC_1G 265
30 #endif
31 #if defined(BMA180) || defined(BMA280) || defined(LIS3LV02) || defined(LSM303DLx_ACC) || defined(LSM330)
32  #define ACC_1G 255
33 #endif
34 #if defined(BMA020)
35  #define ACC_1G 63
36 #endif
37 #if defined(ADCACC)
38  #define ACC_1G 75
39 #endif
40 #if defined(MPU6050)
41  #if defined(FREEIMUv04)
42  #define ACC_1G 255
43  #else
44  #define ACC_1G 512
45  #endif
46 #endif
47 #if !defined(ACC_1G)
48  #define ACC_1G 256
49 #endif
50 #define ACCZ_25deg (int16_t)(ACC_1G * 0.90631) // 0.90631 = cos(25deg) (cos(theta) of accZ comparison)
51 #define ACC_VelScale (9.80665f / 10000.0f / ACC_1G)
52 
53 // GYRO SCALE: we ignore the last 2 bits and convert it for rad/s
54 #if defined(ITG3050)
55  #define GYRO_SCALE (4 / 16.0 * PI / 180.0 / 1000000.0) //16.4 LSB = 1 deg/s -- 16.0 apparently gives beter results than 16.4 (empirical)
56 #endif
57 #if defined(MPU6050) || defined(MPU3050)
58  #define GYRO_SCALE (4 / 16.4 * PI / 180.0 / 1000000.0) //16.4 LSB = 1 deg/s
59 #endif
60 #if defined(ITG3200)
61  #define GYRO_SCALE (4 / 14.375 * PI / 180.0 / 1000000.0) //ITG3200 14.375 LSB = 1 deg/s
62 #endif
63 #if defined(L3G4200D) || defined(LSM330) || defined(LSM9DS0)
64  #define GYRO_SCALE ((4.0f * PI * 70.0f)/(1000.0f * 180.0f * 1000000.0f)) // 70 milli deg/s /digit => 1 deg/s = 1000/70 LSB
65 #endif
66 #if defined(WMP)
67  #define GYRO_SCALE (1.0f/200e6f)
68 #endif
69 
70 #endif /* SENSORS_H_ */
void initSensors()
Definition: Sensors.cpp:1977
void Sonar_update()
Definition: Sensors.cpp:1964
void i2c_stop(void)
Definition: Sensors.cpp:103
uint8_t Baro_update()
Definition: Sensors.cpp:756
tuple buf
Definition: DeviceGeneric.py:119
void ACC_getADC()
Definition: Sensors.cpp:1658
uint8_t Mag_getADC()
void i2c_rep_start(uint8_t address)
Definition: Sensors.cpp:97
tuple size
Definition: unpack-test.py:15
tuple data
Definition: ser-mon-AS7265X.py:40
void Gyro_getADC()
Definition: Sensors.cpp:1695
uint8_t i2c_readReg(uint8_t add, uint8_t reg)
Definition: Sensors.cpp:145
void i2c_writeReg(uint8_t add, uint8_t reg, uint8_t val)
Definition: Sensors.cpp:138
void i2c_write(uint8_t data)
Definition: Sensors.cpp:108
uint8_t i2c_readNak()
Definition: Sensors.cpp:118
uint8_t i2c_readAck()
Definition: Sensors.cpp:113
void i2c_read_reg_to_buf(uint8_t add, uint8_t reg, uint8_t *buf, uint8_t size)
Definition: Sensors.cpp:125