Rev 1869 | Rev 1887 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1869 | Rev 1870 | ||
---|---|---|---|
Line 170... | Line 170... | ||
170 | * re-enabling ADC, the real limit is (how much?) lower. |
170 | * re-enabling ADC, the real limit is (how much?) lower. |
171 | * The acc. sensor is sampled even if not used - or installed |
171 | * The acc. sensor is sampled even if not used - or installed |
172 | * at all. The cost is not significant. |
172 | * at all. The cost is not significant. |
173 | */ |
173 | */ |
Line 174... | Line 174... | ||
174 | 174 | ||
175 | const uint8_t channelsForStates[] PROGMEM = { AD_GYRO_PITCH, AD_GYRO_ROLL, |
175 | const uint8_t channelsForStates[] PROGMEM = { |
176 | AD_GYRO_YAW, |
- | |
177 | 176 | AD_GYRO_PITCH, AD_GYRO_ROLL, AD_GYRO_YAW, |
|
Line 178... | Line 177... | ||
178 | AD_ACC_PITCH, AD_ACC_ROLL, AD_AIRPRESSURE, |
177 | AD_ACC_PITCH, AD_ACC_ROLL, AD_AIRPRESSURE, |
179 | - | ||
180 | AD_GYRO_PITCH, AD_GYRO_ROLL, AD_ACC_Z, // at 8, measure Z acc. |
178 | |
Line 181... | Line 179... | ||
181 | 179 | AD_GYRO_PITCH, AD_GYRO_ROLL, AD_ACC_Z, // at 8, measure Z acc. |
|
182 | AD_GYRO_PITCH, AD_GYRO_ROLL, AD_GYRO_YAW, // at 11, finish yaw gyro |
180 | AD_GYRO_PITCH, AD_GYRO_ROLL, AD_GYRO_YAW, // at 11, finish yaw gyro |
183 | 181 | ||
Line 246... | Line 244... | ||
246 | * Interrupt Service Routine for ADC |
244 | * Interrupt Service Routine for ADC |
247 | * Runs at 312.5 kHz or 3.2 µs. When all states are |
245 | * Runs at 312.5 kHz or 3.2 µs. When all states are |
248 | * processed the interrupt is disabled and further |
246 | * processed the interrupt is disabled and further |
249 | * AD conversions are stopped. |
247 | * AD conversions are stopped. |
250 | *****************************************************/ |
248 | *****************************************************/ |
251 | ISR(ADC_vect) |
249 | ISR(ADC_vect) { |
252 | { |
- | |
253 | static uint8_t ad_channel = AD_GYRO_PITCH, state = 0; |
250 | static uint8_t ad_channel = AD_GYRO_PITCH, state = 0; |
254 | static uint16_t sensorInputs[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
251 | static uint16_t sensorInputs[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
255 | static uint16_t pressureAutorangingWait = 25; |
252 | static uint16_t pressureAutorangingWait = 25; |
256 | uint16_t rawAirPressure; |
253 | uint16_t rawAirPressure; |
257 | uint8_t i, axis; |
254 | uint8_t i, axis; |
258 | int16_t newrange; |
255 | int16_t newrange; |
Line -... | Line 256... | ||
- | 256 | ||
- | 257 | J5HIGH; |
|
259 | 258 | ||
260 | // for various filters... |
259 | // for various filters... |
Line 261... | Line 260... | ||
261 | int16_t tempOffsetGyro, tempGyro; |
260 | int16_t tempOffsetGyro, tempGyro; |
Line 481... | Line 480... | ||
481 | // set adc muxer to next ad_channel |
480 | // set adc muxer to next ad_channel |
482 | ADMUX = (ADMUX & 0xE0) | ad_channel; |
481 | ADMUX = (ADMUX & 0xE0) | ad_channel; |
483 | // after full cycle stop further interrupts |
482 | // after full cycle stop further interrupts |
484 | if (state) |
483 | if (state) |
485 | analog_start(); |
484 | analog_start(); |
- | 485 | else |
|
- | 486 | J4LOW; |
|
- | 487 | ||
- | 488 | J5LOW; |
|
486 | } |
489 | } |
Line 487... | Line 490... | ||
487 | 490 | ||
488 | void analog_calibrate(void) { |
491 | void analog_calibrate(void) { |
489 | #define GYRO_OFFSET_CYCLES 32 |
492 | #define GYRO_OFFSET_CYCLES 32 |