aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-04-14 21:47:14 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-04-14 21:47:14 +0200
commitb78a68e23216dd4f3c08f8101ba13ad713452206 (patch)
tree95d28d10413ce1409b5758f962797485971f2a00 /src
parentb9da01524a915c5a97027ab38b3026d32e2764c7 (diff)
downloadglutte-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')
-rw-r--r--src/common/src/Core/main.c2
-rw-r--r--src/common/src/GPIO/usart.c7
-rw-r--r--src/glutt-o-logique/audio_in.c8
-rw-r--r--src/temperature/main.c2
4 files changed, 12 insertions, 7 deletions
diff --git a/src/common/src/Core/main.c b/src/common/src/Core/main.c
index da3a27b..b308f08 100644
--- a/src/common/src/Core/main.c
+++ b/src/common/src/Core/main.c
@@ -225,7 +225,7 @@ static void launcher_task(void __attribute__ ((unused))*pvParameters)
"TaskNF",
3*configMINIMAL_STACK_SIZE,
(void*) NULL,
- tskIDLE_PRIORITY + 2UL,
+ tskIDLE_PRIORITY + 3UL,
&task_handle);
if (!task_handle) {
diff --git a/src/common/src/GPIO/usart.c b/src/common/src/GPIO/usart.c
index 535b062..8bcd80a 100644
--- a/src/common/src/GPIO/usart.c
+++ b/src/common/src/GPIO/usart.c
@@ -134,7 +134,9 @@ void usart_process_char(char c) {
usart_debug("Unknown command %c\r\n", c);
}
-void usart_gps_process_char(char c) {
+void usart_gps_process_char(char c)
+{
+ BaseType_t require_context_switch = pdFALSE;
if (nmea_sentence_last_written == 0) {
if (c == '$') {
@@ -151,7 +153,7 @@ void usart_gps_process_char(char c) {
int success = xQueueSendToBackFromISR(
usart_nmea_queue,
nmea_sentence,
- NULL);
+ &require_context_switch);
if (success == pdFALSE) {
trigger_fault(FAULT_SOURCE_USART);
@@ -165,4 +167,5 @@ void usart_gps_process_char(char c) {
usart_clear_nmea_buffer();
}
+ portYIELD_FROM_ISR(require_context_switch);
}
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);
}
diff --git a/src/temperature/main.c b/src/temperature/main.c
index 7be7f45..a4d9830 100644
--- a/src/temperature/main.c
+++ b/src/temperature/main.c
@@ -99,9 +99,7 @@ static void detect_button_press(void *pvParameters)
static void update_temperature(void *pvParameters)
{
-
while (1) {
-
vTaskDelay(pdMS_TO_TICKS(1000));
GPIO_SetBits(GPIOD, GPIO_Pin_13);