diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index e1cb586..04e00a6 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRCS "hello_world_main.c" - PRIV_REQUIRES spi_flash esp_driver_gpio + PRIV_REQUIRES spi_flash esp_driver_gpio vfs esp_vfs_console INCLUDE_DIRS "") diff --git a/main/hello_world_main.c b/main/hello_world_main.c index 026ac41..d48438c 100644 --- a/main/hello_world_main.c +++ b/main/hello_world_main.c @@ -8,27 +8,41 @@ #include "esp_flash.h" #include "esp_system.h" #include "driver/gpio.h" +#include "esp_vfs_dev.h" +#include "esp_vfs_cdcacm.h" #define LED_GPIO 15 void app_main(void) { + // Initialisation explicite du CDC-ACM pour ESP32-S2 +#if CONFIG_ESP_CONSOLE_USB_CDC + esp_err_t ret = esp_vfs_dev_cdcacm_register(); + if (ret != ESP_OK) { + // Si l'initialisation échoue, on continue quand même + } +#endif + + // Délai pour permettre l'initialisation USB-CDC + vTaskDelay(pdMS_TO_TICKS(1000)); + + printf("\n\n=== Démarrage ESP32-S2 avec USB-CDC ===\n\n"); gpio_config_t io_conf = { - .pin_bit_mask = LED_GPIO, + .pin_bit_mask = (1ULL << 15), .mode = GPIO_MODE_OUTPUT, .pull_up_en = GPIO_PULLUP_DISABLE, .pull_down_en = GPIO_PULLDOWN_DISABLE, .intr_type = GPIO_INTR_DISABLE, // No interrupt for now }; - esp_err_t ret = gpio_config(&io_conf); + gpio_config(&io_conf); while(1) { - printf("hello"); - vTaskDelay(1000 / portTICK_PERIOD_MS); + printf("loop from ESP32-S2 via USB-CDC!\n"); gpio_set_level(LED_GPIO, 1); vTaskDelay(1000 / portTICK_PERIOD_MS); gpio_set_level(LED_GPIO, 0); + vTaskDelay(1000 / portTICK_PERIOD_MS); } }