You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.3 KiB
52 lines
1.3 KiB
9 years ago
|
#pragma once
|
||
|
|
||
|
#include "AP_HAL_Linux.h"
|
||
|
#include "RCOutput_Sysfs.h"
|
||
|
#include "RCOutput_Bebop.h"
|
||
|
|
||
|
class Linux::RCOutput_Disco : public AP_HAL::RCOutput {
|
||
|
public:
|
||
|
RCOutput_Disco(void) {}
|
||
|
~RCOutput_Disco() {}
|
||
|
|
||
|
static RCOutput_Disco *from(AP_HAL::RCOutput *rcoutput)
|
||
|
{
|
||
|
return static_cast<RCOutput_Disco *>(rcoutput);
|
||
|
}
|
||
|
|
||
|
void init() override;
|
||
|
void set_freq(uint32_t chmask, uint16_t freq_hz) override;
|
||
|
uint16_t get_freq(uint8_t ch) override;
|
||
|
void enable_ch(uint8_t ch) override;
|
||
|
void disable_ch(uint8_t ch) override;
|
||
|
void write(uint8_t ch, uint16_t period_us) override;
|
||
|
uint16_t read(uint8_t ch) override;
|
||
|
void read(uint16_t *period_us, uint8_t len) override;
|
||
|
void cork() override;
|
||
|
void push() override;
|
||
|
|
||
|
private:
|
||
|
// Disco RC output combines methods from Sysfs and Bebop
|
||
|
RCOutput_Sysfs sysfs_out{0, 1, 6};
|
||
|
RCOutput_Bebop bebop_out;
|
||
|
|
||
|
/*
|
||
|
use a table to provide the mapping to channel numbers in each
|
||
|
backend
|
||
|
*/
|
||
|
typedef struct {
|
||
|
RCOutput &output;
|
||
|
uint8_t channel;
|
||
|
} output_table_t;
|
||
|
const output_table_t output_table[7] = {
|
||
|
{ sysfs_out, 3 },
|
||
|
{ sysfs_out, 2 },
|
||
|
{ bebop_out, 0 },
|
||
|
{ sysfs_out, 4 },
|
||
|
{ sysfs_out, 1 },
|
||
|
{ sysfs_out, 5 },
|
||
|
{ sysfs_out, 0 },
|
||
|
};
|
||
|
|
||
|
};
|