Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 511 → Rev 512

/branches/v0.60_MicroMag3_Nick666/trunc/compass.c
26,13 → 26,14
void init_MM3(void)
//############################################################################
{
SPCR = (1<<SPIE)|(1<<SPE)|(1<<MSTR)|(1<<SPR1)|(1<<SPR0); //Interrupt an, Master, 156 kHz Oszillator
//SPSR = (1<<SPI2X);
// SPI-Schnittstelle initialisieren
SPCR = (1<<SPIE)|(1<<SPE)|(1<<MSTR)|(1<<SPR1)|(1<<SPR0); // Interrupt an, Master, 156 kHz Oszillator
 
DDRB |= (1<<PB7)|(1<<PB5)|(1<<PB2); // J8, MOSI, SCK Ausgang
PORTD &= ~(1<<PD3); // J5 auf Low
PORTD &= ~(1<<PD3); // J5 permanent auf Low
// Init Statemachine
MM3.AXIS = MM3_X;
MM3.STATE = MM3_RESET;
56,7 → 57,7
case MM3_START_TRANSFER:
PORTB &= ~(1<<PB2); // J8 auf Low (war ~125 µs auf High)
if (MM3.AXIS == MM3_X) SPDR = 0x31; // Schreiben ins SPDR löst automatisch Übertragung (MOSI und MISO) aus
if (MM3.AXIS == MM3_X) SPDR = 0x31; // Schreiben ins SPDR löst automatisch SPI-Übertragung (MOSI und MISO) aus
else if (MM3.AXIS == MM3_Y) SPDR = 0x32; // Micromag Period Select ist auf 256 (0x30)
else SPDR = 0x33; //if (MM3.AXIS == MM3_Z) // 1: x-Achse, 2: Y-Achse, 3: Z-Achse