aboutsummaryrefslogtreecommitdiffstats
path: root/src/glutt-o-logique
diff options
context:
space:
mode:
Diffstat (limited to 'src/glutt-o-logique')
-rw-r--r--src/glutt-o-logique/analog_input.c11
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) {