9,6 → 9,19 |
#define PITCHROLL_MINLIMIT GYRO_SUMMATION_FACTOR_PITCHROLL * 510 |
#define PITCHROLL_MAXLIMIT GYRO_SUMMATION_FACTOR_PITCHROLL * 515 |
|
void I2C_OutputAmplifierOffsets() { |
uint16_t timeout = setDelay(2000); |
I2C_Start(TWI_STATE_GYRO_OFFSET_TX); // initiate data transmission |
// Wait for I2C to finish transmission. |
while (twi_state) { |
// Did it take too long? |
if (checkDelay(timeout)) { |
printf("\r\n DAC or I2C Error! check I2C, 3Vref, DAC, and BL-Ctrl"); |
break; |
} |
} |
} |
|
void gyro_calibrate(void) { |
printf("gyro_calibrate"); |
uint8_t i, axis, factor, numberOfAxesInRange = 0; |
38,35 → 51,28 |
/* Gyro is defective. But do keep DAC within bounds (it's an op amp not a differential amp). */ |
if (gyroAmplifierOffset.offsets[axis] < 10) { |
gyroAmplifierOffset.offsets[axis] = 10; |
versionInfo.hardwareErrors[0] |= (FC_ERROR0_GYRO_PITCH << axis); |
} else if (gyroAmplifierOffset.offsets[axis] > 245) { |
gyroAmplifierOffset.offsets[axis] = 245; |
versionInfo.hardwareErrors[0] |= (FC_ERROR0_GYRO_PITCH << axis); |
} |
} |
|
gyro_loadAmplifierOffsets(0); |
I2C_OutputAmplifierOffsets(); |
} |
gyroAmplifierOffset_writeToEEProm(); |
delay_ms_with_adc_measurement(70, 0); |
} |
|
void gyro_loadAmplifierOffsets(uint8_t overwriteWithDefaults) { |
uint16_t timeout = setDelay(2000); |
|
if (overwriteWithDefaults) { |
gyroAmplifierOffset.offsets[PITCH] = |
void gyro_init() { |
if (gyroAmplifierOffset_readFromEEProm()) { |
printf("gyro amp invalid%s", recal); |
gyroAmplifierOffset.offsets[PITCH] = |
gyroAmplifierOffset.offsets[ROLL] = |
gyroAmplifierOffset.offsets[YAW] = (uint8_t)(255 * 1.2089 / 3.0); |
} |
|
I2C_Start(TWI_STATE_GYRO_OFFSET_TX); // initiate data transmission |
// Wait for I2C to finish transmission. |
while (twi_state) { |
// Did it take too long? |
if (checkDelay(timeout)) { |
printf("\r\n DAC or I2C Error! check I2C, 3Vref, DAC, and BL-Ctrl"); |
break; |
} |
} |
} else { |
I2C_OutputAmplifierOffsets(); |
} |
} |
|
void gyro_setDefaultParameters(void) { |