Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 903 → Rev 886

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