9,14 → 9,14 |
uint8_t twiTroubleSpot; |
uint8_t twiGotStatus; |
|
volatile uint16_t IMU3200SensorInputs[4]; |
volatile int16_t ITG3200SensorInputs[4]; |
|
void twimaster_init(void) { |
// Set pullups |
// Set pullups OFF |
uint8_t sreg = SREG; |
cli(); |
DDRC = 0; |
PORTC = ((1 << 4) | (1 << 5)); |
PORTC &= ~((1<<4) | (1<<5)); |
TWBR = ((F_CPU / SCL_CLOCK) - 16) / 2; |
twiState = TWI_STATE_INIT_0; |
SREG = sreg; |
140,14 → 140,14 |
I2CReceiveByte(); |
break; |
default: // data bytes |
((uint8_t*) IMU3200SensorInputs)[dataIndex] = TWDR; |
if (twiState < TWI_STATE_LOOP_0 + 5 + sizeof(IMU3200SensorInputs) - 1) |
((uint8_t*) ITG3200SensorInputs)[dataIndex] = TWDR; |
if (twiState < TWI_STATE_LOOP_0 + 5 + sizeof(ITG3200SensorInputs) - 1) |
I2CReceiveByte(); |
else |
I2CReceiveLastByte(); |
break; |
case TWI_STATE_LOOP_0 + 5 + sizeof(IMU3200SensorInputs) - 1: // last data byte |
((uint8_t*) IMU3200SensorInputs)[dataIndex] = TWDR; |
case TWI_STATE_LOOP_0 + 5 + sizeof(ITG3200SensorInputs) - 1: // last data byte |
((uint8_t*) ITG3200SensorInputs)[dataIndex] = TWDR; |
// Dont re-init the gyro but just restart the loop. |
I2CStop(); |
sensorDataReady |= TWI_DATA_READY; |