2016-02-17 21:25:26 -04:00
|
|
|
#pragma once
|
2015-08-18 00:29:58 -03:00
|
|
|
|
|
|
|
#include "AP_HAL_Linux.h"
|
|
|
|
|
|
|
|
#include "UARTDriver.h"
|
2016-04-26 15:17:35 -03:00
|
|
|
#include <AP_HAL/SPIDevice.h>
|
2015-08-18 00:29:58 -03:00
|
|
|
|
2016-07-29 16:14:02 -03:00
|
|
|
namespace Linux {
|
2015-08-18 00:29:58 -03:00
|
|
|
|
2016-07-29 16:14:02 -03:00
|
|
|
class RPIOUARTDriver : public UARTDriver {
|
2015-08-18 00:29:58 -03:00
|
|
|
public:
|
2015-10-20 18:13:25 -03:00
|
|
|
RPIOUARTDriver();
|
2015-09-13 15:28:02 -03:00
|
|
|
|
2015-10-20 18:13:25 -03:00
|
|
|
static RPIOUARTDriver *from(AP_HAL::UARTDriver *uart) {
|
|
|
|
return static_cast<RPIOUARTDriver*>(uart);
|
2015-09-13 15:28:02 -03:00
|
|
|
}
|
|
|
|
|
2015-08-18 00:29:58 -03:00
|
|
|
void begin(uint32_t b, uint16_t rxS, uint16_t txS);
|
|
|
|
void _timer_tick(void);
|
|
|
|
bool isExternal(void);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int _write_fd(const uint8_t *buf, uint16_t n);
|
|
|
|
int _read_fd(uint8_t *buf, uint16_t n);
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool _in_timer;
|
|
|
|
|
2016-11-17 21:05:30 -04:00
|
|
|
bool _bus_timer(void);
|
2016-04-26 15:17:35 -03:00
|
|
|
|
|
|
|
AP_HAL::OwnPtr<AP_HAL::SPIDevice> _dev;
|
2015-08-18 00:29:58 -03:00
|
|
|
|
|
|
|
bool _external;
|
2016-11-17 21:05:30 -04:00
|
|
|
bool _registered_callback;
|
2015-08-18 00:29:58 -03:00
|
|
|
|
|
|
|
bool _need_set_baud;
|
|
|
|
uint32_t _baudrate;
|
|
|
|
};
|
2016-07-29 16:14:02 -03:00
|
|
|
|
|
|
|
}
|