CDC
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
idf_component_register(SRCS "hello_world_main.c"
|
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 "")
|
INCLUDE_DIRS "")
|
||||||
|
|||||||
@@ -8,27 +8,41 @@
|
|||||||
#include "esp_flash.h"
|
#include "esp_flash.h"
|
||||||
#include "esp_system.h"
|
#include "esp_system.h"
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
|
#include "esp_vfs_dev.h"
|
||||||
|
#include "esp_vfs_cdcacm.h"
|
||||||
|
|
||||||
#define LED_GPIO 15
|
#define LED_GPIO 15
|
||||||
|
|
||||||
void app_main(void)
|
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 = {
|
gpio_config_t io_conf = {
|
||||||
.pin_bit_mask = LED_GPIO,
|
.pin_bit_mask = (1ULL << 15),
|
||||||
.mode = GPIO_MODE_OUTPUT,
|
.mode = GPIO_MODE_OUTPUT,
|
||||||
.pull_up_en = GPIO_PULLUP_DISABLE,
|
.pull_up_en = GPIO_PULLUP_DISABLE,
|
||||||
.pull_down_en = GPIO_PULLDOWN_DISABLE,
|
.pull_down_en = GPIO_PULLDOWN_DISABLE,
|
||||||
.intr_type = GPIO_INTR_DISABLE, // No interrupt for now
|
.intr_type = GPIO_INTR_DISABLE, // No interrupt for now
|
||||||
};
|
};
|
||||||
|
|
||||||
esp_err_t ret = gpio_config(&io_conf);
|
gpio_config(&io_conf);
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
printf("hello");
|
printf("loop from ESP32-S2 via USB-CDC!\n");
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
|
||||||
gpio_set_level(LED_GPIO, 1);
|
gpio_set_level(LED_GPIO, 1);
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
gpio_set_level(LED_GPIO, 0);
|
gpio_set_level(LED_GPIO, 0);
|
||||||
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user