forked from espressif/esp-idf
refactor(esp_adc): reformat code with astyle_py 2
This commit is contained in:
@@ -46,38 +46,38 @@ static int test_adc_io;
|
|||||||
static bool test_list[TEST_NUM] = {1, 1, 0, 0, 1, 0, 1, 0};
|
static bool test_list[TEST_NUM] = {1, 1, 0, 0, 1, 0, 1, 0};
|
||||||
|
|
||||||
static void wifi_event_handler(void* arg, esp_event_base_t event_base,
|
static void wifi_event_handler(void* arg, esp_event_base_t event_base,
|
||||||
int32_t event_id, void* event_data)
|
int32_t event_id, void* event_data)
|
||||||
{
|
{
|
||||||
printf("ev_handle_called.\n");
|
printf("ev_handle_called.\n");
|
||||||
switch(event_id) {
|
switch (event_id) {
|
||||||
case WIFI_EVENT_STA_START:
|
case WIFI_EVENT_STA_START:
|
||||||
ESP_LOGI(TAG, "WIFI_EVENT_STA_START");
|
ESP_LOGI(TAG, "WIFI_EVENT_STA_START");
|
||||||
//do not actually connect in test case
|
//do not actually connect in test case
|
||||||
//;
|
//;
|
||||||
break;
|
break;
|
||||||
case WIFI_EVENT_STA_DISCONNECTED:
|
case WIFI_EVENT_STA_DISCONNECTED:
|
||||||
ESP_LOGI(TAG, "WIFI_EVENT_STA_DISCONNECTED");
|
ESP_LOGI(TAG, "WIFI_EVENT_STA_DISCONNECTED");
|
||||||
TEST_ESP_OK(esp_wifi_connect());
|
TEST_ESP_OK(esp_wifi_connect());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ip_event_handler(void* arg, esp_event_base_t event_base,
|
static void ip_event_handler(void* arg, esp_event_base_t event_base,
|
||||||
int32_t event_id, void* event_data)
|
int32_t event_id, void* event_data)
|
||||||
{
|
{
|
||||||
ip_event_got_ip_t *event;
|
ip_event_got_ip_t *event;
|
||||||
printf("ev_handle_called.\n");
|
printf("ev_handle_called.\n");
|
||||||
switch(event_id) {
|
switch (event_id) {
|
||||||
case IP_EVENT_STA_GOT_IP:
|
case IP_EVENT_STA_GOT_IP:
|
||||||
event = (ip_event_got_ip_t*)event_data;
|
event = (ip_event_got_ip_t*)event_data;
|
||||||
ESP_LOGI(TAG, "IP_EVENT_STA_GOT_IP");
|
ESP_LOGI(TAG, "IP_EVENT_STA_GOT_IP");
|
||||||
ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip));
|
ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
@@ -133,7 +133,7 @@ __attribute__((unused)) static void adc_work_with_wifi(adc_unit_t unit_id, adc_c
|
|||||||
TEST_ESP_OK(nvs_flash_erase());
|
TEST_ESP_OK(nvs_flash_erase());
|
||||||
r = nvs_flash_init();
|
r = nvs_flash_init();
|
||||||
}
|
}
|
||||||
TEST_ESP_OK( r);
|
TEST_ESP_OK(r);
|
||||||
esp_netif_init();
|
esp_netif_init();
|
||||||
event_init();
|
event_init();
|
||||||
esp_netif_create_default_wifi_sta();
|
esp_netif_create_default_wifi_sta();
|
||||||
@@ -179,13 +179,11 @@ __attribute__((unused)) static void adc_work_with_wifi(adc_unit_t unit_id, adc_c
|
|||||||
test_adc_set_io_level(unit_id, channel, test_list[i]);
|
test_adc_set_io_level(unit_id, channel, test_list[i]);
|
||||||
target_value = test_list[i] ? ADC_TEST_HIGH_VAL : ADC_TEST_LOW_VAL;
|
target_value = test_list[i] ? ADC_TEST_HIGH_VAL : ADC_TEST_LOW_VAL;
|
||||||
|
|
||||||
|
|
||||||
/* ADC single read before WIFI start */
|
/* ADC single read before WIFI start */
|
||||||
TEST_ESP_OK(adc_oneshot_read(adc_handle, channel, &read_raw));
|
TEST_ESP_OK(adc_oneshot_read(adc_handle, channel, &read_raw));
|
||||||
printf("Before WiFi starts, ADC read: %d (target_value: %d)\n", read_raw, target_value);
|
printf("Before WiFi starts, ADC read: %d (target_value: %d)\n", read_raw, target_value);
|
||||||
TEST_ASSERT_INT_WITHIN(ADC_ERROR_THRES, target_value, read_raw);
|
TEST_ASSERT_INT_WITHIN(ADC_ERROR_THRES, target_value, read_raw);
|
||||||
|
|
||||||
|
|
||||||
/* ADC single read when WIFI is on */
|
/* ADC single read when WIFI is on */
|
||||||
TEST_ESP_OK(esp_wifi_start());
|
TEST_ESP_OK(esp_wifi_start());
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
@@ -220,7 +218,7 @@ __attribute__((unused)) static void adc_work_with_wifi(adc_unit_t unit_id, adc_c
|
|||||||
#if CONFIG_IDF_TARGET_ESP32C6
|
#if CONFIG_IDF_TARGET_ESP32C6
|
||||||
// On ESP32C6, ADC need to call two modem clocks: modem_syscon_ll_enable_fe_80m_clock and modem_syscon_ll_enable_fe_apb_clock.
|
// On ESP32C6, ADC need to call two modem clocks: modem_syscon_ll_enable_fe_80m_clock and modem_syscon_ll_enable_fe_apb_clock.
|
||||||
// Without calling these two clocks, PWDET mode will not take into effect, so ADC readings will be wrong.
|
// Without calling these two clocks, PWDET mode will not take into effect, so ADC readings will be wrong.
|
||||||
TEST_CASE("ADC1 work with WiFi","[adc]")
|
TEST_CASE("ADC1 work with WiFi", "[adc]")
|
||||||
{
|
{
|
||||||
adc_work_with_wifi(ADC_UNIT_1, ADC1_WIFI_TEST_CHAN0);
|
adc_work_with_wifi(ADC_UNIT_1, ADC1_WIFI_TEST_CHAN0);
|
||||||
}
|
}
|
||||||
@@ -228,7 +226,7 @@ TEST_CASE("ADC1 work with WiFi","[adc]")
|
|||||||
|
|
||||||
#if (SOC_ADC_PERIPH_NUM >= 2) && !CONFIG_IDF_TARGET_ESP32C3
|
#if (SOC_ADC_PERIPH_NUM >= 2) && !CONFIG_IDF_TARGET_ESP32C3
|
||||||
// On ESP32C3, ADC2 is no longer supported, due to its HW limitation.
|
// On ESP32C3, ADC2 is no longer supported, due to its HW limitation.
|
||||||
TEST_CASE("ADC2 work with WiFi","[adc]")
|
TEST_CASE("ADC2 work with WiFi", "[adc]")
|
||||||
{
|
{
|
||||||
adc_work_with_wifi(ADC_UNIT_2, ADC2_WIFI_TEST_CHAN0);
|
adc_work_with_wifi(ADC_UNIT_2, ADC2_WIFI_TEST_CHAN0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user