2015-08-11 03:28:43 -03:00
|
|
|
#include <AP_HAL/AP_HAL.h>
|
2014-09-18 10:35:22 -03:00
|
|
|
#include "GPIO.h"
|
2013-12-30 19:00:04 -04:00
|
|
|
|
2014-07-06 23:03:26 -03:00
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
2013-09-22 03:01:24 -03:00
|
|
|
|
|
|
|
using namespace Linux;
|
|
|
|
|
2014-06-04 05:44:57 -03:00
|
|
|
static const AP_HAL::HAL& hal = AP_HAL_BOARD_DRIVER;
|
2013-09-22 03:01:24 -03:00
|
|
|
|
|
|
|
LinuxDigitalSource::LinuxDigitalSource(uint8_t v) :
|
|
|
|
_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
|
|
|
|
|
|
|
void LinuxDigitalSource::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
|
|
|
|
2014-06-04 05:44:57 -03:00
|
|
|
uint8_t LinuxDigitalSource::read()
|
|
|
|
{
|
|
|
|
return hal.gpio->read(_v);
|
2013-09-22 03:01:24 -03:00
|
|
|
}
|
|
|
|
|
2014-06-04 05:44:57 -03:00
|
|
|
void LinuxDigitalSource::write(uint8_t value)
|
|
|
|
{
|
|
|
|
return hal.gpio->write(_v,value);
|
2013-09-22 03:01:24 -03:00
|
|
|
}
|
|
|
|
|
2014-06-04 05:44:57 -03:00
|
|
|
void LinuxDigitalSource::toggle()
|
|
|
|
{
|
2014-05-25 02:50:18 -03:00
|
|
|
write(!read());
|
2013-09-22 03:01:24 -03:00
|
|
|
}
|
2013-12-30 19:00:04 -04:00
|
|
|
|
2014-09-18 10:35:22 -03:00
|
|
|
#endif
|