/** ESP32 GPIO + I2C Test
2024-02-25:
- created project
- included driver/gpio.h to enable control GPIOs
- added debug LED
**/
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#define GPIO_DEBUG_LED1 22
#define GPIO_DEBUG_LED2 25
void app_main() {
//printf("Hello, Wokwi!\n");
printf("\n--- GPIO innit ---\n");
printf("Reset GPIO_DEBUG_LED1...");
gpio_reset_pin(GPIO_DEBUG_LED1); // https://docs.espressif.com/projects/esp-idf/en/stable/esp32h2/api-reference/peripherals/gpio.html#_CPPv414gpio_reset_pin10gpio_num_t
printf("done!\n");
printf("Reset GPIO_DEBUG_LED2...");
gpio_reset_pin(GPIO_DEBUG_LED2); // https://docs.espressif.com/projects/esp-idf/en/stable/esp32h2/api-reference/peripherals/gpio.html#_CPPv414gpio_reset_pin10gpio_num_t
printf("done!\n");
printf("Set GPIO_DEBUG_LED1 to output...");
gpio_set_direction(GPIO_DEBUG_LED1, GPIO_MODE_OUTPUT); // https://docs.espressif.com/projects/esp-idf/en/stable/esp32h2/api-reference/peripherals/gpio.html#_CPPv418gpio_set_direction10gpio_num_t11gpio_mode_t
printf("done!\n");
printf("Set GPIO_DEBUG_LED2 to output...");
gpio_set_direction(GPIO_DEBUG_LED2, GPIO_MODE_OUTPUT); // https://docs.espressif.com/projects/esp-idf/en/stable/esp32h2/api-reference/peripherals/gpio.html#_CPPv418gpio_set_direction10gpio_num_t11gpio_mode_t
printf("done!\n");
printf("\n");
while (true) {
gpio_set_level(GPIO_DEBUG_LED1, 1);
gpio_set_level(GPIO_DEBUG_LED2, 1);
vTaskDelay(1000 / portTICK_PERIOD_MS);
gpio_set_level(GPIO_DEBUG_LED1, 0);
gpio_set_level(GPIO_DEBUG_LED2, 0);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
Loading
esp32-h2-devkitm-1
esp32-h2-devkitm-1