Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 413 → Rev 422

/branches/v0.60_MicroMag3_Nick666/trunc/compass.c
33,6 → 33,7
PORTD &= ~(1<<PD3); // J5 auf Low
// Init Statemachine
MM3.AXIS = MM3_X;
MM3.STATE = MM3_RESET;
58,7 → 59,7
if (MM3.AXIS == MM3_X) SPDR = 0x31; // Schreiben ins SPDR löst automatisch Übertragung (MOSI und MISO) aus
else if (MM3.AXIS == MM3_Y) SPDR = 0x32; // Micromag Period Select ist auf 256 (0x30)
else if (MM3.AXIS == MM3_Z) SPDR = 0x33; // 1: x-Achse, 2: Y-Achse, 3: Z-Achse
else SPDR = 0x33; //if (MM3.AXIS == MM3_Z) // 1: x-Achse, 2: Y-Achse, 3: Z-Achse
MM3.DRDY = SetDelay(5); // Laut Datenblatt max. Zeit bis Messung fertig (bei PS 256 eigentlich 4 ms)
MM3.STATE = MM3_WAIT_DRDY;
223,8 → 224,7
x_corr += y_axis * sin_roll * sin_nick;
x_corr -= z_axis * cos_roll * sin_nick;
y_corr = y_axis * cos_roll;
y_corr += z_axis * sin_roll;
y_corr = (y_axis * cos_roll) + (z_axis * sin_roll);
// Winkelberechnung
heading = atan2_i(x_corr, y_corr);