GPIO.h 873 B

12345678910111213141516171819202122232425262728293031323334
  1. #pragma once
  2. #include "AP_HAL_SITL.h"
  3. class HALSITL::GPIO : public AP_HAL::GPIO {
  4. public:
  5. explicit GPIO(SITL_State *sitlState): _sitlState(sitlState) {}
  6. void init() override;
  7. void pinMode(uint8_t pin, uint8_t output) override;
  8. uint8_t read(uint8_t pin) override;
  9. void write(uint8_t pin, uint8_t value) override;
  10. void toggle(uint8_t pin) override;
  11. /* Alternative interface: */
  12. AP_HAL::DigitalSource* channel(uint16_t n) override;
  13. /* return true if USB cable is connected */
  14. bool usb_connected(void) override;
  15. private:
  16. SITL_State *_sitlState;
  17. };
  18. class HALSITL::DigitalSource : public AP_HAL::DigitalSource {
  19. public:
  20. explicit DigitalSource(uint8_t pin);
  21. void mode(uint8_t output) override;
  22. uint8_t read() override;
  23. void write(uint8_t value) override;
  24. void toggle() override;
  25. private:
  26. uint8_t _pin;
  27. };