parent
25ac658b28
commit
15de31d035
|
|
@ -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);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
/* Wait here until notified that the conversion is done */
|
/* Wait here until notified that the conversion is done */
|
||||||
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
|
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
|
||||||
|
|
||||||
while (1) {
|
|
||||||
/* 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue