How should I pass data between them?
Code: Select all
int ADC_VALUE_1 = 0;
int ADC_VALUE_2 = 0;
void display_and_keyboard_task(void *pvParameters) {
while (1) {
if (shouldInit()) {
init();
}
if (xSemaphoreTake(display_semaphore, 10 / portTICK_RATE_MS) == pdTRUE) {
if (flags & UPDATE_VIEW) {
switch (view) {
case MAIN: {
// ...
writeToDisplay("ADC1 ", ADC_VALUE_1, "ADC2 ", ADC_VALUE_2);
break;
}
// case ...: ...
}
}
}
readKeyboard();
}
}
void adc1_task(void *pvParameters) {
while (1) {
ADC_VALUE_1 = measure();
flags |= UPDATE_VIEW;
xSemaphoreGive(display_semaphore);
vTaskDelay(100 / portTICK_RATE_MS);
}
}
void adc2_task(void *pvParameters) {
while (1) {
ADC_VALUE_2 = measure();
flags |= UPDATE_VIEW;
xSemaphoreGive(display_semaphore);
vTaskDelay(200 / portTICK_RATE_MS);
}
}