49 lines
1.2 KiB
C
49 lines
1.2 KiB
C
|
|
#include <stdio.h>
|
|
#include <inttypes.h>
|
|
#include "sdkconfig.h"
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "esp_chip_info.h"
|
|
#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 = (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
|
|
};
|
|
|
|
gpio_config(&io_conf);
|
|
|
|
while(1) {
|
|
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);
|
|
}
|
|
}
|