2015-08-11 03:28:43 -03:00
|
|
|
#include <AP_HAL/AP_HAL.h>
|
2016-05-17 23:26:57 -03:00
|
|
|
|
2014-09-18 10:35:22 -03:00
|
|
|
#include "GPIO.h"
|
2013-12-30 19:00:04 -04:00
|
|
|
|
2013-09-22 03:01:24 -03:00
|
|
|
using namespace Linux;
|
|
|
|
|
2020-03-01 19:50:34 -04:00
|
|
|
extern const AP_HAL::HAL& hal;
|
2013-09-22 03:01:24 -03:00
|
|
|
|
2015-10-20 18:13:25 -03:00
|
|
|
DigitalSource::DigitalSource(uint8_t v) :
|
2013-09-22 03:01:24 -03:00
|
|
|
_v(v)
|
2014-05-25 02:50:18 -03:00
|
|
|
{
|
2014-06-04 05:44:57 -03:00
|
|
|
|
2014-05-25 02:50:18 -03:00
|
|
|
}
|
2013-09-22 03:01:24 -03:00
|
|
|
|
2015-10-20 18:13:25 -03:00
|
|
|
void DigitalSource::mode(uint8_t output)
|
2014-05-25 02:50:18 -03:00
|
|
|
{
|
2014-06-04 05:44:57 -03:00
|
|
|
hal.gpio->pinMode(_v, output);
|
2014-05-25 02:50:18 -03:00
|
|
|
}
|
2013-09-22 03:01:24 -03:00
|
|
|
|
2015-10-20 18:13:25 -03:00
|
|
|
uint8_t DigitalSource::read()
|
2014-06-04 05:44:57 -03:00
|
|
|
{
|
|
|
|
return hal.gpio->read(_v);
|
2013-09-22 03:01:24 -03:00
|
|
|
}
|
|
|
|
|
2015-10-20 18:13:25 -03:00
|
|
|
void DigitalSource::write(uint8_t value)
|
2014-06-04 05:44:57 -03:00
|
|
|
{
|
|
|
|
return hal.gpio->write(_v,value);
|
2013-09-22 03:01:24 -03:00
|
|
|
}
|
|
|
|
|
2015-10-20 18:13:25 -03:00
|
|
|
void DigitalSource::toggle()
|
2014-06-04 05:44:57 -03:00
|
|
|
{
|
2014-05-25 02:50:18 -03:00
|
|
|
write(!read());
|
2013-09-22 03:01:24 -03:00
|
|
|
}
|