119,6 → 119,7 |
switch (MM3.STATE) |
{ |
case MM3_STATE_RESET: |
PORTC &= ~(1<<PORTC4); // select slave |
PORTC |= (1<<PORTC5); // PC5 to High, MM3 Reset |
MM3.STATE = MM3_STATE_START_TRANSFER; |
return; |
193,6 → 194,7 |
break; |
} |
} |
PORTC |= (1<<PORTC4); // deselect slave |
MM3.STATE = MM3_STATE_RESET; |
} |
} |
325,9 → 327,10 |
// calculate Heading |
heading = c_atan2(Hy_corr, Hx_corr); |
|
// transform range from +-180° to 0°- 359° |
heading += 360; |
heading %= 360; |
// atan returns angular range from -180 deg to 180 deg in counter clockwise notation |
// but the compass course is defined in a range from 0 deg to 360 deg clockwise notation. |
if (heading < 0) heading = -heading; |
else heading = 360 - heading; |
|
return heading; |
} |