2016-02-17 21:25:26 -04:00
|
|
|
#pragma once
|
2014-11-07 06:17:50 -04:00
|
|
|
|
2015-08-11 03:28:43 -03:00
|
|
|
#include "AP_HAL_Linux.h"
|
2014-11-07 06:17:50 -04:00
|
|
|
|
|
|
|
#include "UARTDriver.h"
|
|
|
|
|
|
|
|
|
2015-10-20 18:13:25 -03:00
|
|
|
class Linux::SPIUARTDriver : public Linux::UARTDriver {
|
2014-11-07 06:17:50 -04:00
|
|
|
public:
|
2015-10-20 18:13:25 -03:00
|
|
|
SPIUARTDriver();
|
2014-11-07 06:17:50 -04:00
|
|
|
void begin(uint32_t b, uint16_t rxS, uint16_t txS);
|
|
|
|
void _timer_tick(void);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int _write_fd(const uint8_t *buf, uint16_t n);
|
|
|
|
int _read_fd(uint8_t *buf, uint16_t n);
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool sem_take_nonblocking();
|
|
|
|
void sem_give();
|
|
|
|
|
|
|
|
AP_HAL::SPIDeviceDriver *_spi;
|
|
|
|
AP_HAL::Semaphore *_spi_sem;
|
|
|
|
|
|
|
|
uint32_t _last_update_timestamp;
|
|
|
|
|
|
|
|
uint8_t *_buffer;
|
|
|
|
bool _external;
|
|
|
|
};
|