From 15de31d03593bf212e9cc6ba7c64299f214ba1a5 Mon Sep 17 00:00:00 2001 From: rkcf Date: Tue, 21 Feb 2023 13:21:03 -0600 Subject: [PATCH] Fix: conversion buffer too large Refs: #4 --- src/main/esp32_eurorack_generic.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/esp32_eurorack_generic.c b/src/main/esp32_eurorack_generic.c index 09fa69f..5d2a8e9 100644 --- a/src/main/esp32_eurorack_generic.c +++ b/src/main/esp32_eurorack_generic.c @@ -19,7 +19,7 @@ #define ADC_INPUT_3_PIN 9 /* TODO Reroute from pin 46 to 9 on schematic, cant do ADC */ #define ADC_INPUT_4_PIN 10 -#define ADC_READ_LEN 256 +#define ADC_READ_LEN 16 /* ADC channels */ static adc_channel_t channel[4] = {ADC_CHANNEL_3, ADC_CHANNEL_5, ADC_CHANNEL_8, ADC_CHANNEL_9}; @@ -41,13 +41,14 @@ static void adc_read_task(void *pvParameter) /* Fill result with 0xcc */ memset(result, 0xcc, ADC_READ_LEN); - /* Wait here until notified that the conversion is done */ - ulTaskNotifyTake(pdTRUE, portMAX_DELAY); - while (1) { + /* Wait here until notified that the conversion is done */ + ulTaskNotifyTake(pdTRUE, portMAX_DELAY); + /* Perform a read */ adc_ret = adc_continuous_read(adc_handle, result, ADC_READ_LEN, &ret_num, 0); if (adc_ret == ESP_OK) { + ESP_LOGI("adc", "Got a reading"); for (int i = 0; i < ret_num; i+= SOC_ADC_DIGI_RESULT_BYTES) { /* Grab the data and channel number */ adc_digi_output_data_t *p_data = (void*)&result[i]; @@ -61,6 +62,7 @@ static void adc_read_task(void *pvParameter) } } } + vTaskDelay(1000 / portTICK_PERIOD_MS); } }