Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 464 → Rev 465

/branches/v0.60_MicroMag3_Nick666/trunc/twimaster.c
47,12 → 47,13
SIGNAL (TWI_vect)
//############################################################################
{
switch (twi_state++)
switch (twi_state++) // First i2c_start from SendMotorData()
{
case 0:
// Master Transmit
case 0: // Address Slave SL+W
i2c_write_byte(0x52+(motor*2));
break;
case 1:
case 1: // Send Data
switch(motor++)
{
case 0:
69,26 → 70,23
break;
}
break;
case 2:
if (motor<4) twi_state = 0;
i2c_start();
break;
//Liest Daten von Motor
case 3:
case 2: // Repeat case 0+1 for all Slaves
if (motor < 4) twi_state = 0;
i2c_start(); // Repeated start -> switch salve and switch Master Transmit <-> Master Receive respectively
break;
// Master Receive
case 3: // Address Slave SL+R
i2c_write_byte(0x53+(motorread*2));
break;
case 4:
i2c_write_byte(0xFF);
break;
case 5: //1. Byte vom Motor lesen
case 4: //1. Byte vom Motor lesen
motor_rx[motorread] = TWDR;
i2c_write_byte(0xFF);
TWCR |= (1<<TWINT);
break;
case 6: //2. Byte vom Motor lesen
case 5: //2. Byte vom Motor lesen
motor_rx[motorread+4] = TWDR;
motorread++;
if (motorread>3) motorread=0;
if (motorread > 3) motorread=0;
default:
i2c_stop();
twi_state = 0;