ardupilot/libraries/AP_HAL_Linux/GPIO.cpp

34 lines
445 B
C++
Raw Normal View History

#include <AP_HAL/AP_HAL.h>
#include "GPIO.h"
2013-12-30 19:00:04 -04:00
2013-09-22 03:01:24 -03:00
using namespace Linux;
extern const AP_HAL::HAL& hal;
2013-09-22 03:01:24 -03:00
DigitalSource::DigitalSource(uint8_t v) :
2013-09-22 03:01:24 -03:00
_v(v)
{
}
2013-09-22 03:01:24 -03:00
void DigitalSource::mode(uint8_t output)
{
hal.gpio->pinMode(_v, output);
}
2013-09-22 03:01:24 -03:00
uint8_t DigitalSource::read()
{
return hal.gpio->read(_v);
2013-09-22 03:01:24 -03:00
}
void DigitalSource::write(uint8_t value)
{
return hal.gpio->write(_v,value);
2013-09-22 03:01:24 -03:00
}
void DigitalSource::toggle()
{
write(!read());
2013-09-22 03:01:24 -03:00
}