diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-04-14 21:47:14 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-04-14 21:47:14 +0200 |
commit | b78a68e23216dd4f3c08f8101ba13ad713452206 (patch) | |
tree | 95d28d10413ce1409b5758f962797485971f2a00 /src/glutt-o-logique | |
parent | b9da01524a915c5a97027ab38b3026d32e2764c7 (diff) | |
download | glutte-o-matic-b78a68e23216dd4f3c08f8101ba13ad713452206.tar.gz glutte-o-matic-b78a68e23216dd4f3c08f8101ba13ad713452206.tar.bz2 glutte-o-matic-b78a68e23216dd4f3c08f8101ba13ad713452206.zip |
Properly use queues from ISR
Diffstat (limited to 'src/glutt-o-logique')
-rw-r--r-- | src/glutt-o-logique/audio_in.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/glutt-o-logique/audio_in.c b/src/glutt-o-logique/audio_in.c index a3abdce..b73e98c 100644 --- a/src/glutt-o-logique/audio_in.c +++ b/src/glutt-o-logique/audio_in.c @@ -65,6 +65,8 @@ void TIM6_DAC_IRQHandler() void ADC_IRQHandler(void); void ADC_IRQHandler() { + BaseType_t require_context_switch = pdFALSE; + if (ADC_GetFlagStatus(ADC2, ADC_FLAG_EOC) == SET) { uint16_t value = ADC_GetConversionValue(ADC2); @@ -77,7 +79,7 @@ void ADC_IRQHandler() int success = xQueueSendToBackFromISR( adc2_values_queue, &adc2_current_buffer, - NULL); + &require_context_switch); adc2_values_end = 0; adc2_current_buffer = (adc2_current_buffer + 1) % 2; @@ -90,6 +92,8 @@ void ADC_IRQHandler() else { adc2_lost_samples++; } + + portYIELD_FROM_ISR(require_context_switch); } // Timer6 is used for ADC2 sampling @@ -157,7 +161,7 @@ void audio_in_initialize() ADC_Cmd(ADC2, ENABLE); - adc2_values_queue = xQueueCreate(4, sizeof(adc2_current_buffer)); + adc2_values_queue = xQueueCreate(2, sizeof(adc2_current_buffer)); if (adc2_values_queue == 0) { trigger_fault(FAULT_SOURCE_ADC2_QUEUE); } |