Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 942 → Rev 943

/branches/V0.70d CRK HexaLotte/twimaster.c
13,7 → 13,7
volatile uint8_t motor_write = 0;
volatile uint8_t motor_read = 0;
volatile uint8_t dac_channel = 0;
volatile uint8_t motor_rx[8];
volatile uint8_t motor_rx[MOTOR_COUNT*2];
volatile uint16_t I2CTimeout = 100;
 
 
161,9 → 161,33
I2C_WriteByte(0x52 + (motor_write * 2) );
break;
case 1: // Send Data to Slave
#ifdef HEXAKOPTER
switch(motor_write)
{
{
case 0:
I2C_WriteByte(Motor_FrontLeft);
break;
case 1:
I2C_WriteByte(Motor_RearRight);
break;
case 2:
I2C_WriteByte(Motor_FrontRight);
break;
case 3:
I2C_WriteByte(Motor_RearLeft);
break;
case 4:
I2C_WriteByte(Motor_Right);
break;
case 5:
I2C_WriteByte(Motor_Left);
break;
}
 
#else
switch(motor_write++)
{
case 0:
I2C_WriteByte(Motor_Front);
break;
case 1:
176,10 → 200,11
I2C_WriteByte(Motor_Left);
break;
}
#endif
break;
case 2: // repeat case 0+1 for all motors
I2C_Stop();
if (motor_write < 3)
I2C_Stop();
if (motor_write < (MOTOR_COUNT-1))
{
motor_write++; // jump to next motor
twi_state = 0; // and repeat from state 0
190,7 → 215,6
}
I2C_Start(); // Repeated start -> switch salve or switch Master Transmit -> Master Receive
break;
 
// Master Receive
case 3: // Send SLA-R
I2C_WriteByte(0x53 + (motor_read * 2) );
207,7 → 231,7
//Read 2nd byte
motor_rx[motor_read + 4] = TWDR;
motor_read++;
if (motor_read > 3) motor_read = 0;
if (motor_read > (MOTOR_COUNT-1)) motor_read = 0;
I2C_Stop();
twi_state = 0;
I2CTimeout = 10;