/* * 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 . */ #pragma once #include "AP_HAL_ESP32.h" class ESP32::GPIO : public AP_HAL::GPIO { public: GPIO(); void init() override; void pinMode(uint8_t pin, uint8_t output) override; uint8_t read(uint8_t pin) override; void write(uint8_t pin, uint8_t value) override; void toggle(uint8_t pin) override; /* Alternative interface: */ AP_HAL::DigitalSource* channel(uint16_t n) override; /* return true if USB cable is connected */ bool usb_connected(void) override; }; class ESP32::DigitalSource : public AP_HAL::DigitalSource { public: DigitalSource(uint8_t pin); void mode(uint8_t output) override; uint8_t read() override; void write(uint8_t value) override; void toggle() override; private: uint8_t _pin; };