/* * This file is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This file is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * * Code by Bayu Laksono */ #include "AP_HAL_ESP32.h" #include "GPIO.h" #include "hal/gpio_types.h" #include "driver/gpio.h" using namespace ESP32; static gpio_num_t gpio_by_pin_num(uint8_t pin) { if (pin < GPIO_NUM_MAX) { return (gpio_num_t)pin; } return GPIO_NUM_NC; } GPIO::GPIO() {} void GPIO::init() {} void GPIO::pinMode(uint8_t pin, uint8_t output) { gpio_num_t g = gpio_by_pin_num(pin); if (g != GPIO_NUM_NC) { gpio_config_t io_conf = {}; io_conf.intr_type = GPIO_INTR_DISABLE; io_conf.mode = output ? GPIO_MODE_OUTPUT : GPIO_MODE_INPUT; io_conf.pin_bit_mask = 1ULL<