34,7 → 34,25 |
TWCR = (1<<TWEN) | (1<<TWSTO) | (1<<TWINT); |
} |
|
void i2c_reset(void) |
//############################################################################ |
{ |
i2c_stop(); |
twi_state = 0; |
motor = TWDR; |
motor = 0; |
TWCR = 0x80; |
TWAMR = 0; |
TWAR = 0; |
TWDR = 0; |
TWSR = 0; |
TWBR = 0; |
i2c_init(); |
i2c_start(); |
i2c_write_byte(0); |
} |
|
//############################################################################ |
//Start I2C |
char i2c_write_byte(char byte) |
//############################################################################ |
104,6 → 122,7 |
break; |
case 5: //1 Byte vom Motor lesen |
motor_rx[motorread] = TWDR; |
|
case 6: |
switch(motorread) |
{ |
126,6 → 145,8 |
motorread++; |
if (motorread>3) motorread=0; |
i2c_stop(); |
I2CTimeout = 10; |
twi_state = 0; |
} |
TWCR |= 0x80; |
} |