Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 684 → Rev 685

/branches/V0.68d Code Redesign killagreg/twimaster.c
2,6 → 2,8
############################################################################*/
 
#include "main.h"
#include "twimaster.h"
#include "fc.h"
 
unsigned char twi_state = 0;
unsigned char motor = 0;
14,12 → 16,12
//############################################################################
{
TWSR = 0;
TWBR = ((SYSCLK/SCL_CLOCK)-16)/2;
TWBR = ((SYSCLK/SCL_CLOCK)-16)/2;
}
 
//############################################################################
//Start I2C
char i2c_start(void)
char i2c_start(void)
//############################################################################
{
TWCR = (1<<TWSTA) | (1<<TWEN) | (1<<TWINT) | (1<<TWIE);
37,7 → 39,7
void i2c_reset(void)
//############################################################################
{
i2c_stop();
i2c_stop();
twi_state = 0;
motor = TWDR;
motor = 0;
56,13 → 58,13
//Start I2C
char i2c_write_byte(char byte)
//############################################################################
{
{
TWSR = 0x00;
TWDR = byte;
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE);
 
return(0);
 
}
 
//############################################################################
81,7 → 83,7
case 0:
i2c_write_byte(Motor_Vorne);
break;
case 1:
case 1:
i2c_write_byte(Motor_Hinten);
break;
case 2:
96,9 → 98,9
i2c_stop();
if (motor<4) twi_state = 0;
else motor = 0;
i2c_start();
break;
i2c_start();
break;
 
//Liest Daten von Motor
case 3:
i2c_write_byte(0x53+(motorread*2));
120,7 → 122,7
break;
}
break;
case 5: //1 Byte vom Motor lesen
case 5: //1 Byte vom Motor lesen
motor_rx[motorread] = TWDR;
 
case 6:
139,8 → 141,8
i2c_write_byte(Motor_Links);
break;
}
break;
case 7: //2 Byte vom Motor lesen
break;
case 7: //2 Byte vom Motor lesen
motor_rx[motorread+4] = TWDR;
motorread++;
if (motorread>3) motorread=0;