Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 463 → Rev 464

/branches/v0.60_MicroMag3_Nick666/trunc/compass.c
176,7 → 176,8
{
float sin_nick, cos_nick, sin_roll, cos_roll;
float x_corr, y_corr;
signed int x_axis,y_axis,z_axis,heading,nicktilt,rolltilt;
signed int x_axis,y_axis,z_axis,heading;
signed int nicktilt,rolltilt;
unsigned int div_faktor;
div_faktor = (uint16_t)EE_Parameter.UserParam1 * 8;
/branches/v0.60_MicroMag3_Nick666/trunc/twimaster.c
19,15 → 19,14
 
//############################################################################
//Start I2C
char i2c_start(void)
void i2c_start(void)
//############################################################################
{
TWCR = (1<<TWSTA) | (1<<TWEN) | (1<<TWINT) | (1<<TWIE);
return(0);
}
 
//############################################################################
//Start I2C
//Stop I2C
void i2c_stop(void)
//############################################################################
{
35,16 → 34,12
}
 
//############################################################################
//Start I2C
char i2c_write_byte(char byte)
//Write to I2C
void i2c_write_byte(char byte)
//############################################################################
{
TWSR = 0x00;
{
TWDR = byte;
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE);
return(0);
}
 
//############################################################################
75,9 → 70,7
}
break;
case 2:
i2c_stop();
if (motor<4) twi_state = 0;
else motor = 0;
i2c_start();
break;
86,46 → 79,19
i2c_write_byte(0x53+(motorread*2));
break;
case 4:
switch(motorread)
{
case 0:
i2c_write_byte(Motor_Vorne);
break;
case 1:
i2c_write_byte(Motor_Hinten);
break;
case 2:
i2c_write_byte(Motor_Rechts);
break;
case 3:
i2c_write_byte(Motor_Links);
break;
}
i2c_write_byte(0xFF);
break;
case 5: //1 Byte vom Motor lesen
case 5: //1. Byte vom Motor lesen
motor_rx[motorread] = TWDR;
case 6:
switch(motorread)
{
case 0:
i2c_write_byte(Motor_Vorne);
break;
case 1:
i2c_write_byte(Motor_Hinten);
break;
case 2:
i2c_write_byte(Motor_Rechts);
break;
case 3:
i2c_write_byte(Motor_Links);
break;
}
break;
case 7: //2 Byte vom Motor lesen
i2c_write_byte(0xFF);
break;
case 6: //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;
motor = 0;
}
}
/branches/v0.60_MicroMag3_Nick666/trunc/twimaster.h
25,8 → 25,8
 
 
void i2c_init (void); // I2C initialisieren
char i2c_start (void); // Start I2C
void i2c_start (void); // Start I2C
void i2c_stop (void); // Stop I2C
char i2c_write_byte (char byte); // 1 Byte schreiben
void i2c_write_byte (char byte); // 1 Byte schreiben
 
#endif