Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 2108 → Rev 2109

/branches/dongfang_FC_fixedwing/arduino_atmega328/twimaster.c
1,5 → 1,6
#include "twimaster.h"
#include "analog.h"
#include "output.h"
#include <inttypes.h>
#include <util/twi.h>
#include <avr/interrupt.h>
43,6 → 44,7
}
 
void I2CReset(void) {
debugOut.analog[29]++;
I2CStop();
TWCR = (1 << TWINT); // reset to original state incl. interrupt flag reset
TWAMR = 0;
61,8 → 63,12
}
 
void twimaster_startCycle(void) {
twiState = TWI_STATE_LOOP_0;
I2CStart();
if (sensorDataReady & TWI_DATA_READY) { // if OK last time
twiState = TWI_STATE_LOOP_0;
I2CStart();
} else { // go get em.
I2CReset();
}
}
 
const uint8_t EXPECTED_STATUS[] = { START, MT_SLA_ACK, MT_DATA_ACK,
145,6 → 151,7
// Dont re-init the gyro but just restart the loop.
I2CStop();
sensorDataReady |= TWI_DATA_READY;
debugOut.analog[28]++;
break;
}
}