GPIO.cpp 465 B

123456789101112131415161718192021222324252627282930313233
  1. #include <AP_HAL/AP_HAL.h>
  2. #include "GPIO.h"
  3. using namespace Linux;
  4. static const AP_HAL::HAL& hal = AP_HAL::get_HAL();
  5. DigitalSource::DigitalSource(uint8_t v) :
  6. _v(v)
  7. {
  8. }
  9. void DigitalSource::mode(uint8_t output)
  10. {
  11. hal.gpio->pinMode(_v, output);
  12. }
  13. uint8_t DigitalSource::read()
  14. {
  15. return hal.gpio->read(_v);
  16. }
  17. void DigitalSource::write(uint8_t value)
  18. {
  19. return hal.gpio->write(_v,value);
  20. }
  21. void DigitalSource::toggle()
  22. {
  23. write(!read());
  24. }