]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/commitdiff
Trigger context switch after ADC interrupts - simpler version eaton-0.5.5
authorMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 27 Aug 2015 07:17:00 +0000 (09:17 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Thu, 27 Aug 2015 07:17:00 +0000 (09:17 +0200)
Given the implementation of portYIELD_FROM_ISR() in FreeRTOS 8.2.2, it is
not necessary to call this macro at the end of the interrupt handler. This
allows us to centralize the call of this macro and keep target specific
files unmodified.

rpp/src/drv/adc.c

index 7089cfa56144662b232e707e29eac12a0f1e965b..e8f8fca3367b8efd0421abf6f96e5de60af875d1 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "drv/drv.h"
 #include "drv/port.h"
+#include "os/portmacro.h"
 
 // Binary semaphores for finish notifications
 static xSemaphoreHandle sem[2][2];
@@ -59,10 +60,12 @@ void drv_adc_init()
 void adcNotification(adcBASE_t *adc, uint32_t group)
 {
        if (adcIsConversionComplete(adc, group) == ADC_CONVERSION_IS_FINISHED) {
-               signed portBASE_TYPE dummy;
                int adc_idx = (adc == adcREG1) ? 0 : 1;
                int grp_idx = (group == adcGROUP1) ? 0 : 1;
-               xSemaphoreGiveFromISR(sem[adc_idx][grp_idx], &dummy);
+               portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
+
+               xSemaphoreGiveFromISR(sem[adc_idx][grp_idx], &xHigherPriorityTaskWoken);
+               portYIELD_FROM_ISR(xHigherPriorityTaskWoken); /* Cause context switch after return from interrupt */
        }
 }