Introduction
Cette fiche résume l’ensemble des fonctions ESP-IDF permettant de manipuler les périphériques internes de l’ESP32-WROOM-32 via l’API native (non via Arduino).
GPIO – Entrées/Sorties
| Fonctionnalité | Fonctions ESP-IDF |
| Configuration | gpio_config |
| Écriture | gpio_set_level |
| Lecture | gpio_get_level |
| Interruption | gpio_install_isr_service, gpio_isr_handler_add |
UART
| Fonctionnalité | Fonctions ESP-IDF |
| Initialisation | uart_driver_install, uart_param_config |
| Transmission | uart_write_bytes |
| Réception | uart_read_bytes |
SPI
| Fonctionnalité | Fonctions ESP-IDF |
| Initialisation du bus | spi_bus_initialize |
| Ajout périphérique | spi_bus_add_device |
| Transfert de données | spi_device_transmit |
I2C
| Fonctionnalité | Fonctions ESP-IDF |
| Configuration | i2c_param_config, i2c_driver_install |
| Communication maître | i2c_master_write_read_device |
I2S
| Fonctionnalité | Fonctions ESP-IDF |
| Initialisation | i2s_driver_install, i2s_set_pin |
| Transmission / Réception | i2s_write, i2s_read |
PWM (LEDC)
| Fonctionnalité | Fonctions ESP-IDF |
| Configuration timer & canal | ledc_timer_config, ledc_channel_config |
| Mise à jour du duty cycle | ledc_set_duty, ledc_update_duty |
Exemple PWM
#include "driver/ledc.h"
// Configuration des timers et canaux PWM
void pwm_init(gpio_num_t gpio_num, ledc_channel_t channel, uint32_t freq_hz, uint8_t resolution_bits) {
// Configuration du timer PWM
ledc_timer_config_t ledc_timer = {
.speed_mode = LEDC_HIGH_SPEED_MODE,
.timer_num = LEDC_TIMER_0,
.duty_resolution = resolution_bits, // Résolution (ex: 13 bits)
.freq_hz = freq_hz, // Fréquence du PWM (en Hz)
.clk_cfg = LEDC_APB_CLK_SRC
};
ledc_timer_config(&ledc_timer);
// Configuration du canal PWM
ledc_channel_config_t ledc_channel = {
.gpio_num = gpio_num, // GPIO spécifié par l'utilisateur
.speed_mode = LEDC_HIGH_SPEED_MODE,
.channel = channel, // Canal PWM
.intr_type = LEDC_INTR_DISABLE,
.timer_sel = LEDC_TIMER_0,
.duty = 0, // Initialisation avec un duty cycle de 0
.hpoint = 0
};
ledc_channel_config(&ledc_channel);
}
// Configure le canal PWM pour un périphérique spécifique.
static void set_pwm_device(ledc_channel_t channel, uint8_t brightness) {
uint32_t duty = (LEDC_TIMER_MAX_DUTY * (100 - brightness)) / 100;
ledc_set_duty(LEDC_HIGH_SPEED_MODE, channel, duty);
ledc_update_duty(LEDC_HIGH_SPEED_MODE, channel);
}
// Exemple du réglage d'une LED rouge
void red_led(uint8_t brightness) {
set_pwm_device(LEDC_CHANNEL_0, brightness);
}
ADC (12 bits)
| Fonctionnalité | Fonctions ESP-IDF |
| Configuration | adc1_config_width, adc1_config_channel_atten |
| Lecture brute | adc1_get_raw |
DAC (8 bits)
| Fonctionnalité | Fonctions ESP-IDF |
| Activation / sortie | dac_output_enable, dac_output_voltage |
Touch Pad
| Fonctionnalité | Fonctions ESP-IDF |
| Initialisation | touch_pad_init, touch_pad_config |
| Lecture | touch_pad_read |
CAN (TWAI)
| Fonctionnalité | Fonctions ESP-IDF |
| Installation pilote | twai_driver_install |
| Transmission | twai_transmit |
| Réception | twai_receive |
Timers matériels
| Fonctionnalité | Fonctions ESP-IDF |
| Configuration & démarrage | timer_config, timer_init, timer_start |
| Lecture du compteur | timer_get_counter_value |
RTC & Deep Sleep
| Fonctionnalité | Fonctions ESP-IDF |
| Wakeup timer / GPIO | esp_sleep_enable_timer_wakeup, esp_sleep_enable_ext0_wakeup |
| Entrer en deep sleep | esp_deep_sleep_start |
Watchdog
| Fonctionnalité | Fonctions ESP-IDF |
| Configuration globale | esp_task_wdt_init |
| Surveiller une tâche | esp_task_wdt_add, esp_task_wdt_reset |
Wi-Fi
| Fonctionnalité | Fonctions ESP-IDF |
| Initialisation | esp_wifi_init, esp_wifi_set_mode, esp_wifi_start |
| Connexion | esp_wifi_set_config, esp_wifi_connect |
Bluetooth (Classic & BLE)
| Fonctionnalité | Fonctions ESP-IDF |
| Init contrôleur | esp_bt_controller_init, esp_bt_controller_enable |
| BLE GAP / GATT | esp_ble_gap_*, esp_ble_gatt_* |
Cryptographie & RNG
| Fonctionnalité | Fonctions ESP-IDF |
| Générateur aléatoire | esp_random |
| Chiffrement AES | esp_aes_encrypt, mbedtls_aes_* |
| Hash SHA / RSA / ECC | mbedtls_sha256_*, esp_ecdsa_sign, mbedtls_rsa_* |
Secure Boot / Flash Encryption
| Fonctionnalité | Fonctions ESP-IDF |
| Configuration via menuconfig | CONFIG_SECURE_BOOT, CONFIG_FLASH_ENCRYPTION_ENABLED |
| Fonctions internes / OTA | esp_secure_boot_*, esp_flash_encrypt_* |
Capteurs internes
| Fonctionnalité | Fonctions ESP-IDF |
| Capteur Hall | hall_sensor_read |
| Température | (via ADC, pas directement exposé) |
Source