Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 886 → Rev 903

/branches/V0.69k 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[MOTOR_COUNT*2];
 
/**************************************************/
/* Initialize I2C (TWI) */
136,9 → 136,33
I2C_WriteByte(0x52+(motor*2));
break;
case 1: // Send Data to Salve
#ifdef HEXAKOPTER
switch(motor++)
{
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++)
{
case 0:
I2C_WriteByte(Motor_Front);
break;
case 1:
151,9 → 175,10
I2C_WriteByte(Motor_Left);
break;
}
#endif
break;
case 2: // repeat case 0+1 for all Slaves
if (motor<4) twi_state = 0;
if (motor<MOTOR_COUNT) twi_state = 0;
I2C_Start(); // Repeated start -> switch salve or switch Master Transmit -> Master Receive
break;
 
172,8 → 197,7
case 6:
//Read 2nd byte
motor_rx[motorread+4] = TWDR;
motorread++;
if (motorread > 3) motorread=0;
if (++motorread >= MOTOR_COUNT) motorread=0;
 
default:
I2C_Stop();