Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 2025 → Rev 2099

/branches/dongfang_FC_fixedwing/invenSense.c
1,4 → 1,3
#include "invenSense.h"
#include "timer0.h"
#include "configuration.h"
 
8,8 → 7,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.
*/
PR_GYROS_ORIENTATION_REVERSED = 0;
 
// The special auto-zero feature of this gyro needs a port.
#define AUTOZERO_PORT PORTD
#define AUTOZERO_DDR DDRD
#define AUTOZERO_BIT 5
16,8 → 15,7
 
void gyro_calibrate(void) {
// If port not already set to output and high, do it.
if (!(AUTOZERO_DDR & (1 << AUTOZERO_BIT)) || !(AUTOZERO_PORT & (1
<< AUTOZERO_BIT))) {
if (!(AUTOZERO_DDR & (1 << AUTOZERO_BIT)) || !(AUTOZERO_PORT & (1 << AUTOZERO_BIT))) {
AUTOZERO_PORT |= (1 << AUTOZERO_BIT);
AUTOZERO_DDR |= (1 << AUTOZERO_BIT);
delay_ms(100);
28,11 → 26,16
delay_ms(1);
AUTOZERO_PORT |= (1 << AUTOZERO_BIT);
// Delay_ms(10);
delay_ms_Mess(100);
delay_ms_with_adc_measurement(100, 0);
}
 
void gyro_setDefaults(void) {
staticParams.zerothOrderGyroCorrectionFactorx1000 = 1;
staticParams.secondOrderGyroCorrectionDivisor = 2;
staticParams.secondOrderGyroCorrectionLimit = 3;
void gyro_init(void) {
gyro_calibrate();
}
 
void gyro_setDefaultParameters(void) {
IMUConfig.driftCompDivider = 2;
IMUConfig.driftCompLimit = 5;
IMUConfig.zerothOrderCorrection = 1;
IMUConfig.imuReversedFlags = IMU_REVERSE_ACC_Z;
}