overrange interrupt
This commit is contained in:
parent
671a9d4439
commit
7b926dce6a
@ -7,18 +7,22 @@
|
|||||||
#include "esp_adc/adc_cali.h"
|
#include "esp_adc/adc_cali.h"
|
||||||
#include "esp_adc/adc_continuous.h"
|
#include "esp_adc/adc_continuous.h"
|
||||||
#include "esp_adc/adc_oneshot.h"
|
#include "esp_adc/adc_oneshot.h"
|
||||||
|
#include "esp_intr_alloc.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "freertos/portmacro.h"
|
#include "freertos/portmacro.h"
|
||||||
|
|
||||||
#include "hal/adc_types.h"
|
#include "hal/adc_types.h"
|
||||||
|
#include "hal/gpio_types.h"
|
||||||
#include "resistor_ranges.h"
|
#include "resistor_ranges.h"
|
||||||
#include "measure.h"
|
#include "measure.h"
|
||||||
#include "soc/soc_caps.h"
|
#include "soc/soc_caps.h"
|
||||||
|
|
||||||
#define TAG "main"
|
#define TAG "main"
|
||||||
|
|
||||||
|
#define OVERRANGE_PIN 4
|
||||||
|
|
||||||
enum ranges {R1, R10, R100, R_NUM};
|
enum ranges {R1, R10, R100, R_NUM};
|
||||||
|
|
||||||
resistor_range ranges[] = {
|
resistor_range ranges[] = {
|
||||||
@ -87,7 +91,27 @@ static bool IRAM_ATTR on_conv_done(adc_continuous_handle_t handle, const adc_con
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char overrange_flag = 0;
|
||||||
|
|
||||||
|
static void IRAM_ATTR overrange_handler(void* arg)
|
||||||
|
{
|
||||||
|
overrange_flag = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void app_main(void){
|
void app_main(void){
|
||||||
|
gpio_config_t overrange_input = {
|
||||||
|
.intr_type = GPIO_INTR_POSEDGE,
|
||||||
|
.mode = GPIO_MODE_INPUT,
|
||||||
|
.pin_bit_mask = 1ULL << OVERRANGE_PIN,
|
||||||
|
.pull_down_en = 0,
|
||||||
|
.pull_up_en = 0,
|
||||||
|
};
|
||||||
|
gpio_config(&overrange_input);
|
||||||
|
|
||||||
|
gpio_install_isr_service(0);
|
||||||
|
|
||||||
|
gpio_isr_handler_add(OVERRANGE_PIN, overrange_handler, NULL);
|
||||||
|
|
||||||
set_resistor_gpio(ranges, R100);
|
set_resistor_gpio(ranges, R100);
|
||||||
|
|
||||||
activate_range(ranges, R100, R100);
|
activate_range(ranges, R100, R100);
|
||||||
@ -128,6 +152,9 @@ void app_main(void){
|
|||||||
ESP_LOGI(TAG, "IN %d : %d mV (%d / %d)", i, mv, meas_res_buff[i], meas_nb_buff[i]);
|
ESP_LOGI(TAG, "IN %d : %d mV (%d / %d)", i, mv, meas_res_buff[i], meas_nb_buff[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "overrange %d", overrange_flag);
|
||||||
|
overrange_flag = 0;
|
||||||
|
|
||||||
//activate_range(ranges, r_ind, R100);
|
//activate_range(ranges, r_ind, R100);
|
||||||
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
||||||
r_ind = (r_ind + 1) % R_NUM;
|
r_ind = (r_ind + 1) % R_NUM;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user