Fix: conversion buffer too large

Refs: #4
adc-init
rkcf 2023-02-21 13:21:03 -06:00
parent 25ac658b28
commit 15de31d035
1 changed files with 6 additions and 4 deletions

View File

@ -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_3_PIN 9 /* TODO Reroute from pin 46 to 9 on schematic, cant do ADC */
#define ADC_INPUT_4_PIN 10 #define ADC_INPUT_4_PIN 10
#define ADC_READ_LEN 256 #define ADC_READ_LEN 16
/* ADC channels */ /* ADC channels */
static adc_channel_t channel[4] = {ADC_CHANNEL_3, ADC_CHANNEL_5, ADC_CHANNEL_8, ADC_CHANNEL_9}; 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 */ /* Fill result with 0xcc */
memset(result, 0xcc, ADC_READ_LEN); memset(result, 0xcc, ADC_READ_LEN);
/* Wait here until notified that the conversion is done */
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
while (1) { while (1) {
/* Wait here until notified that the conversion is done */
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
/* Perform a read */ /* Perform a read */
adc_ret = adc_continuous_read(adc_handle, result, ADC_READ_LEN, &ret_num, 0); adc_ret = adc_continuous_read(adc_handle, result, ADC_READ_LEN, &ret_num, 0);
if (adc_ret == ESP_OK) { if (adc_ret == ESP_OK) {
ESP_LOGI("adc", "Got a reading");
for (int i = 0; i < ret_num; i+= SOC_ADC_DIGI_RESULT_BYTES) { for (int i = 0; i < ret_num; i+= SOC_ADC_DIGI_RESULT_BYTES) {
/* Grab the data and channel number */ /* Grab the data and channel number */
adc_digi_output_data_t *p_data = (void*)&result[i]; 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);
} }
} }