mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
AHRS: Deal better with DMA errors
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1856 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
a9495e2cbb
commit
1931c75a4c
@ -202,28 +202,29 @@ void AHRS_ADC_DMA_Handler(void)
|
||||
if (ahrs_state == AHRS_IDLE) {
|
||||
// Ideally this would have a mutex, but I think we can avoid it (and don't have RTOS features)
|
||||
|
||||
if (DMA_GetFlagStatus(DMA1_IT_TC1)) // whole double buffer filled
|
||||
if (DMA_GetFlagStatus(DMA1_IT_TC1)) { // whole double buffer filled
|
||||
valid_data_buffer =
|
||||
&raw_data_buffer[1 * PIOS_ADC_NUM_CHANNELS *
|
||||
adc_oversample];
|
||||
else if (DMA_GetFlagStatus(DMA1_IT_HT1))
|
||||
DMA_ClearFlag(DMA1_IT_TC1);
|
||||
}
|
||||
else if (DMA_GetFlagStatus(DMA1_IT_HT1)) {
|
||||
valid_data_buffer =
|
||||
&raw_data_buffer[0 * PIOS_ADC_NUM_CHANNELS *
|
||||
adc_oversample];
|
||||
DMA_ClearFlag(DMA1_IT_HT1);
|
||||
}
|
||||
else {
|
||||
// lets cause a seg fault and catch whatever is going on
|
||||
valid_data_buffer = 0;
|
||||
// This should not happen, probably due to transfer errors
|
||||
DMA_ClearFlag(DMA1_FLAG_GL1);
|
||||
}
|
||||
|
||||
ahrs_state = AHRS_DATA_READY;
|
||||
} else {
|
||||
// Track how many times an interrupt occurred before EKF finished processing
|
||||
ekf_too_slow++;
|
||||
DMA_ClearFlag(DMA1_IT_GL1);
|
||||
}
|
||||
|
||||
total_conversion_blocks++;
|
||||
|
||||
// Clear all interrupt from DMA 1 - regardless if buffer swapped
|
||||
DMA_ClearFlag(DMA1_IT_GL1);
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user