diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-09-26 09:49:12 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-09-26 09:49:12 +0200 |
commit | b7f74a89a65933ec98d72fdaa5a02a6932ef9e39 (patch) | |
tree | bb598791e5073d940e63076bdde61ac54ef71a7b /src/glutt-o-logique | |
parent | b634ee618288e217a2d26fcd04acbc63df520523 (diff) | |
download | glutte-o-matic-b7f74a89a65933ec98d72fdaa5a02a6932ef9e39.tar.gz glutte-o-matic-b7f74a89a65933ec98d72fdaa5a02a6932ef9e39.tar.bz2 glutte-o-matic-b7f74a89a65933ec98d72fdaa5a02a6932ef9e39.zip |
Add delays to fix aggressive FAULT_ADC1
Diffstat (limited to 'src/glutt-o-logique')
-rw-r--r-- | src/glutt-o-logique/analog_input.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/glutt-o-logique/analog_input.c b/src/glutt-o-logique/analog_input.c index 682472b..ebfa486 100644 --- a/src/glutt-o-logique/analog_input.c +++ b/src/glutt-o-logique/analog_input.c @@ -23,6 +23,11 @@ */ #include "analog_input.h" + +#include "FreeRTOS.h" +#include "task.h" +#include "timers.h" + #include "Core/delay.h" #include "Core/common.h" #include "stm32f4xx_adc.h" @@ -83,16 +88,18 @@ static uint16_t analog_read_channel(uint8_t channel) * System clock is at 168MHz, ADC is on APB2 which has a prescaler of 2. * 480 cycles at 84Mhz is about 6us. * - * If we have no result after 10ms it is a real problem. + * If we have no result after 10ms it is a real problem. Keep in mind + * we could get preempted. */ int ready = 0; - for (int i = 0; i < 10000; i++) { + for (int i = 0; i < 10; i++) { if (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == SET) { ready = 1; break; } + vTaskDelay(pdMS_TO_TICKS(1)); } if (!ready) { |