Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 1820 → Rev 1821

/branches/dongfang_FC_rewrite/invenSense.c
8,8 → 8,8
* Configuration for my prototype board with InvenSense gyros.
* The FC 1.3 board is installed upside down, therefore Z acc is reversed but not roll.
*/
const uint8_t GYRO_REVERSED[3] = {0,0,0};
const uint8_t ACC_REVERSED[3] = {0,0,1};
const uint8_t GYRO_REVERSED[3] = { 0, 0, 0 };
const uint8_t ACC_REVERSED[3] = { 0, 0, 1 };
 
#define AUTOZERO_PORT PORTD
#define AUTOZERO_DDR DDRD
16,27 → 16,28
#define AUTOZERO_BIT 5
 
void gyro_calibrate() {
// If port not already set to output and high, do it.
if (!(AUTOZERO_DDR & (1<<AUTOZERO_BIT)) || !(AUTOZERO_PORT & (1<<AUTOZERO_BIT))) {
AUTOZERO_PORT |= (1<<AUTOZERO_BIT);
AUTOZERO_DDR |= (1<<AUTOZERO_BIT);
Delay_ms(100);
}
// Make a pulse on the auto-zero output line.
AUTOZERO_PORT &= ~(1<<AUTOZERO_BIT);
Delay_ms(1);
AUTOZERO_PORT |= (1<<AUTOZERO_BIT);
// Delay_ms(10);
Delay_ms_Mess(100);
// If port not already set to output and high, do it.
if (!(AUTOZERO_DDR & (1 << AUTOZERO_BIT)) || !(AUTOZERO_PORT & (1
<< AUTOZERO_BIT))) {
AUTOZERO_PORT |= (1 << AUTOZERO_BIT);
AUTOZERO_DDR |= (1 << AUTOZERO_BIT);
Delay_ms(100);
}
 
// Make a pulse on the auto-zero output line.
AUTOZERO_PORT &= ~(1 << AUTOZERO_BIT);
Delay_ms(1);
AUTOZERO_PORT |= (1 << AUTOZERO_BIT);
// Delay_ms(10);
Delay_ms_Mess(100);
}
 
void gyro_setDefaults(void) {
staticParams.GyroD = 3;
staticParams.GyroAccFactor = 1;
staticParams.DriftComp = 10;
staticParams.GyroD = 3;
staticParams.GyroAccFactor = 1;
staticParams.DriftComp = 10;
 
// Not used.
staticParams.AngleTurnOverPitch = 85;
staticParams.AngleTurnOverRoll = 85;
// Not used.
staticParams.AngleTurnOverPitch = 85;
staticParams.AngleTurnOverRoll = 85;
}