mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 12:35:28 +00:00
Examples: Demonstrate the usage of esp_err_to_name
This commit is contained in:
@@ -49,11 +49,14 @@ void app_main(void)
|
||||
if ( r == ESP_OK ) {
|
||||
printf("%d: %d\n", output_data, read_raw );
|
||||
} else if ( r == ESP_ERR_INVALID_STATE ) {
|
||||
printf("ADC2 not initialized yet.\n");
|
||||
printf("%s: ADC2 not initialized yet.\n", esp_err_to_name(r));
|
||||
} else if ( r == ESP_ERR_TIMEOUT ) {
|
||||
//This can not happen in this example. But if WiFi is in use, such error code could be returned.
|
||||
printf("ADC2 is in use by Wi-Fi.\n");
|
||||
printf("%s: ADC2 is in use by Wi-Fi.\n", esp_err_to_name(r));
|
||||
} else {
|
||||
printf("%s\n", esp_err_to_name(r));
|
||||
}
|
||||
|
||||
vTaskDelay( 2 * portTICK_PERIOD_MS );
|
||||
}
|
||||
}
|
||||
|
@@ -238,7 +238,7 @@ static void i2c_test_task(void* arg)
|
||||
printf("data_l: %02x\n", sensor_data_l);
|
||||
printf("sensor val: %f\n", (sensor_data_h << 8 | sensor_data_l) / 1.2);
|
||||
} else {
|
||||
printf("No ack, sensor not connected...skip...\n");
|
||||
printf("%s: No ack, sensor not connected...skip...\n", esp_err_to_name(ret));
|
||||
}
|
||||
xSemaphoreGive(print_mux);
|
||||
vTaskDelay(( DELAY_TIME_BETWEEN_ITEMS_MS * ( task_idx + 1 ) ) / portTICK_RATE_MS);
|
||||
@@ -267,7 +267,7 @@ static void i2c_test_task(void* arg)
|
||||
printf("====TASK[%d] Master read ====\n", task_idx);
|
||||
disp_buf(data_rd, d_size);
|
||||
} else {
|
||||
printf("Master read slave error, IO not connected...\n");
|
||||
printf("%s: Master read slave error, IO not connected...\n", esp_err_to_name(ret));
|
||||
}
|
||||
xSemaphoreGive(print_mux);
|
||||
vTaskDelay(( DELAY_TIME_BETWEEN_ITEMS_MS * ( task_idx + 1 ) ) / portTICK_RATE_MS);
|
||||
@@ -293,7 +293,7 @@ static void i2c_test_task(void* arg)
|
||||
printf("----TASK[%d] Slave read: [%d] bytes ----\n", task_idx, size);
|
||||
disp_buf(data, size);
|
||||
} else {
|
||||
printf("TASK[%d] Master write slave error, IO not connected....\n", task_idx);
|
||||
printf("TASK[%d] %s: Master write slave error, IO not connected....\n", task_idx, esp_err_to_name(ret));
|
||||
}
|
||||
xSemaphoreGive(print_mux);
|
||||
vTaskDelay(( DELAY_TIME_BETWEEN_ITEMS_MS * ( task_idx + 1 ) ) / portTICK_RATE_MS);
|
||||
|
Reference in New Issue
Block a user