1#include <driver/gpio.h> 2#include "gpio-esp32.h" 3 4static void 5lws_gpio_esp32_mode_write(_lws_plat_gpio_t gpio) 6{ 7 gpio_reset_pin(gpio); 8 gpio_set_pull_mode(gpio, GPIO_PULLUP_ONLY); 9 gpio_set_direction(gpio, GPIO_MODE_INPUT_OUTPUT); 10 gpio_set_level(gpio, 1); 11} 12static void 13lws_gpio_esp32_mode_read(_lws_plat_gpio_t gpio) 14{ 15 gpio_set_pull_mode(gpio, GPIO_PULLUP_ONLY); 16 gpio_set_direction(gpio, GPIO_MODE_INPUT); 17 gpio_set_level(gpio, 1); 18} 19static int 20lws_gpio_esp32_read(_lws_plat_gpio_t gpio) 21{ 22 return gpio_get_level(gpio); 23} 24static void 25lws_gpio_esp32_set(_lws_plat_gpio_t gpio, int val) 26{ 27 gpio_set_level(gpio, val); 28} 29 30const lws_gpio_ops_t lws_gpio_esp32 = { 31 .mode_write = lws_gpio_esp32_mode_write, 32 .mode_read = lws_gpio_esp32_mode_read, 33 .read = lws_gpio_esp32_read, 34 .set = lws_gpio_esp32_set, 35}; 36 37