Skip to content

Instantly share code, notes, and snippets.

@nickfox-taterli
Created October 25, 2017 03:22
Show Gist options
  • Save nickfox-taterli/330b3cf26af1ef5054d40a791e681f13 to your computer and use it in GitHub Desktop.
Save nickfox-taterli/330b3cf26af1ef5054d40a791e681f13 to your computer and use it in GitHub Desktop.
ESP32 Module GPIO Test
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
uint8_t test_io[] = {0, 2, 4, 5, 9, 12, 14, 17, 19, 22, 25, 27, 33};
void app_main()
{
gpio_config_t io_conf;
for(uint8_t i = 0; i < sizeof(test_io); i++)
{
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = ((uint64_t)(((uint64_t)1) << test_io[i]));
io_conf.pull_down_en = 0;
io_conf.pull_up_en = 0;
gpio_config(&io_conf);
}
int cnt = 0;
while(1)
{
cnt++;
printf("===========================\n");
for(uint8_t i = 0; i < sizeof(test_io); i++)
{
printf("gpio i = %d,level: %d\n", test_io[i], cnt % 2);
vTaskDelay(300 / portTICK_RATE_MS);
gpio_set_level(test_io[i], cnt % 2);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment