2013-07-11 00:01:59 -03:00
|
|
|
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
#ifndef __AP_HAL_PX4_GPIO_H__
|
|
|
|
#define __AP_HAL_PX4_GPIO_H__
|
|
|
|
|
2015-08-11 03:28:43 -03:00
|
|
|
#include "AP_HAL_PX4.h"
|
2013-07-11 00:01:59 -03:00
|
|
|
|
2013-07-11 00:49:25 -03:00
|
|
|
#define PX4_GPIO_PIEZO_PIN 110
|
2013-08-28 09:37:47 -03:00
|
|
|
#define PX4_GPIO_EXT_FMU_RELAY1_PIN 111
|
|
|
|
#define PX4_GPIO_EXT_FMU_RELAY2_PIN 112
|
|
|
|
#define PX4_GPIO_EXT_IO_RELAY1_PIN 113
|
|
|
|
#define PX4_GPIO_EXT_IO_RELAY2_PIN 114
|
|
|
|
#define PX4_GPIO_EXT_IO_ACC1_PIN 115
|
|
|
|
#define PX4_GPIO_EXT_IO_ACC2_PIN 116
|
2013-07-11 00:49:25 -03:00
|
|
|
|
2014-01-19 21:56:30 -04:00
|
|
|
/*
|
|
|
|
start servo channels used as GPIO at 50. Pin 50 is
|
|
|
|
the first FMU servo pin
|
|
|
|
*/
|
|
|
|
#define PX4_GPIO_FMU_SERVO_PIN(n) (n+50)
|
|
|
|
|
2013-08-08 10:14:06 -03:00
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4
|
|
|
|
# define HAL_GPIO_A_LED_PIN 27
|
|
|
|
# define HAL_GPIO_B_LED_PIN 26
|
|
|
|
# define HAL_GPIO_C_LED_PIN 25
|
|
|
|
# define HAL_GPIO_LED_ON LOW
|
|
|
|
# define HAL_GPIO_LED_OFF HIGH
|
|
|
|
#endif
|
|
|
|
|
2013-07-11 00:01:59 -03:00
|
|
|
class PX4::PX4GPIO : public AP_HAL::GPIO {
|
|
|
|
public:
|
|
|
|
PX4GPIO();
|
|
|
|
void init();
|
|
|
|
void pinMode(uint8_t pin, uint8_t output);
|
|
|
|
int8_t analogPinToDigitalPin(uint8_t pin);
|
|
|
|
uint8_t read(uint8_t pin);
|
|
|
|
void write(uint8_t pin, uint8_t value);
|
2013-08-08 10:14:06 -03:00
|
|
|
void toggle(uint8_t pin);
|
2013-07-11 00:01:59 -03:00
|
|
|
|
|
|
|
/* Alternative interface: */
|
|
|
|
AP_HAL::DigitalSource* channel(uint16_t n);
|
|
|
|
|
|
|
|
/* Interrupt interface: */
|
|
|
|
bool attach_interrupt(uint8_t interrupt_num, AP_HAL::Proc p, uint8_t mode);
|
|
|
|
|
2013-09-19 03:23:40 -03:00
|
|
|
/* return true if USB cable is connected */
|
|
|
|
bool usb_connected(void);
|
|
|
|
|
2015-08-10 22:40:32 -03:00
|
|
|
// used by UART code to avoid a hw bug in the AUAV-X2
|
|
|
|
void set_usb_connected(void) { _usb_connected = true; }
|
|
|
|
|
2013-07-11 00:01:59 -03:00
|
|
|
private:
|
2015-11-24 22:06:43 -04:00
|
|
|
int _led_fd = -1;
|
|
|
|
int _tone_alarm_fd = -1;
|
|
|
|
int _gpio_fmu_fd = -1;
|
|
|
|
int _gpio_io_fd = -1;
|
2015-08-10 22:40:32 -03:00
|
|
|
bool _usb_connected = false;
|
2013-07-11 00:01:59 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
class PX4::PX4DigitalSource : public AP_HAL::DigitalSource {
|
|
|
|
public:
|
|
|
|
PX4DigitalSource(uint8_t v);
|
|
|
|
void mode(uint8_t output);
|
|
|
|
uint8_t read();
|
2013-08-08 10:14:06 -03:00
|
|
|
void write(uint8_t value);
|
|
|
|
void toggle();
|
2013-07-11 00:01:59 -03:00
|
|
|
private:
|
|
|
|
uint8_t _v;
|
|
|
|
};
|
|
|
|
|
2013-08-28 09:37:47 -03:00
|
|
|
#endif // __AP_HAL_PX4_GPIO_H__
|