Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 726 → Rev 898

/branches/V0.68d CRK HexaLotte/twimaster.c
10,7 → 10,7
 
volatile uint8_t twi_state = 0;
volatile uint8_t motor = 0;
volatile uint8_t motor_rx[8];
volatile uint8_t motor_rx[12];
 
/**************************************************/
/* Initialize I2C (TWI) */
139,21 → 139,27
switch(motor++)
{
case 0:
I2C_WriteByte(Motor_Front);
I2C_WriteByte(Motor_FrontLeft);
break;
case 1:
I2C_WriteByte(Motor_Rear);
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 3:
case 5:
I2C_WriteByte(Motor_Left);
break;
}
break;
case 2: // repeat case 0+1 for all Slaves
if (motor<4) twi_state = 0;
if (motor<6) twi_state = 0;
I2C_Start(); // Repeated start -> switch salve or switch Master Transmit -> Master Receive
break;
 
171,9 → 177,9
break;
case 6:
//Read 2nd byte
motor_rx[motorread+4] = TWDR;
motor_rx[motorread+6] = TWDR;
motorread++;
if (motorread > 3) motorread=0;
if (motorread > 5) motorread=0;
 
default:
I2C_Stop();