2012-08-20 15:37:46 -03:00
|
|
|
|
|
|
|
#ifndef __AP_HAL_GPIO_H__
|
|
|
|
#define __AP_HAL_GPIO_H__
|
|
|
|
|
2012-08-23 19:22:24 -03:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2012-08-20 15:37:46 -03:00
|
|
|
#include "AP_HAL_Namespace.h"
|
|
|
|
|
2012-08-23 19:22:24 -03:00
|
|
|
#define GPIO_INPUT 0
|
|
|
|
#define GPIO_OUTPUT 1
|
2012-12-21 02:41:08 -04:00
|
|
|
#define GPIO_INTERRUPT_LOW 0
|
|
|
|
#define GPIO_INTERRUPT_HIGH 1
|
|
|
|
#define GPIO_INTERRUPT_FALLING 2
|
|
|
|
#define GPIO_INTERRUPT_RISING 3
|
2012-08-23 19:22:24 -03:00
|
|
|
|
2012-10-02 01:55:52 -03:00
|
|
|
class AP_HAL::DigitalSource {
|
|
|
|
public:
|
|
|
|
virtual void mode(uint8_t output) = 0;
|
|
|
|
virtual uint8_t read() = 0;
|
|
|
|
virtual void write(uint8_t value) = 0;
|
|
|
|
};
|
|
|
|
|
2012-08-20 15:37:46 -03:00
|
|
|
class AP_HAL::GPIO {
|
|
|
|
public:
|
|
|
|
GPIO() {}
|
2012-08-23 19:22:24 -03:00
|
|
|
virtual void init() = 0;
|
|
|
|
virtual void pinMode(uint8_t pin, uint8_t output) = 0;
|
|
|
|
virtual uint8_t read(uint8_t pin) = 0;
|
|
|
|
virtual void write(uint8_t pin, uint8_t value) = 0;
|
2013-03-21 22:31:14 -03:00
|
|
|
virtual int8_t analogPinToDigitalPin(uint8_t pin) = 0;
|
|
|
|
|
2012-10-02 01:55:52 -03:00
|
|
|
/* Alternative interface: */
|
2012-12-06 14:45:45 -04:00
|
|
|
virtual AP_HAL::DigitalSource* channel(uint16_t n) = 0;
|
2012-10-11 21:24:56 -03:00
|
|
|
|
|
|
|
/* Interrupt interface: */
|
2012-12-06 14:45:45 -04:00
|
|
|
virtual bool attach_interrupt(uint8_t interrupt_num, AP_HAL::Proc p,
|
|
|
|
uint8_t mode) = 0;
|
2012-08-20 15:37:46 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __AP_HAL_GPIO_H__
|