imu rev1
Fork of AIviate by
Diff: sensor.cpp
- Revision:
- 3:f9e18a9cd9af
- Parent:
- 2:452dd766d212
- Child:
- 4:44a5b1e8fd27
--- a/sensor.cpp Fri Nov 01 00:48:06 2013 +0000 +++ b/sensor.cpp Fri Nov 01 01:23:04 2013 +0000 @@ -136,7 +136,7 @@ if (ret == 0) { if (DEBUG) - pc.printf("Error putting accelerometer in measure mode (accelerometer_measure)\r\n"); + pc.printf("Error turning on gyro (gyro_turnon)\r\n"); return 0; } power_ctl |= 0x8 ; @@ -144,7 +144,7 @@ if (ret == 0) { if (DEBUG) - pc.printf("Error putting accelerometer in measure mode (accelerometer_measure)\r\n"); + pc.printf("Error turning on gyro (gyro_turnon)\r\n"); return 0; } return 1; @@ -157,7 +157,7 @@ if (ret == 0) { if (DEBUG) - pc.printf("Error putting accelerometer in standby (accelerometer_standby)\r\n"); + pc.printf("Error turning off gyro (gyro_turnoff)\r\n"); return 0; } power_ctl &= 0xF7 ; @@ -165,7 +165,7 @@ if (ret == 0) { if (DEBUG) - pc.printf("Error putting accelerometer in standby (accelerometer_standby)\r\n"); + pc.printf("Error turning off gyro (gyro_turnoff)\r\n"); return 0; } return 1; @@ -202,9 +202,9 @@ { if (DEBUG) pc.printf("Error starting up accelerometer\r\n"); - return 1; + return 0; } - return ret; + return 8; } int config_gyro(void) { @@ -214,17 +214,21 @@ { if (DEBUG) pc.printf("Error starting up gyro\r\n"); - return 1; + return 0; } - return ret; + return 4; } -void config_compass(void){} -void config_barometer(void){} +int config_compass(void){return 2;} +int config_barometer(void){return 1;} int config_gy80(struct config *c) { + // return value is a 4-bit number: AGCB, indicating + // the return values of accel, gyro, compass, and barometer i2c.frequency(c->frequency); - return config_accelerometer(); - /*config_gyro(); - config_compass()*/; + int ret = config_accelerometer(); + ret |= config_gyro(); + ret |= config_compass(); + ret |= config_barometer(); + return ret; } \ No newline at end of file