APM:Libraries
RCOutput_Disco.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "AP_HAL_Linux.h"
4 #include "RCOutput_Sysfs.h"
5 #include "RCOutput_Bebop.h"
6 
7 namespace Linux {
8 
10 public:
13 
15  {
16  // this is used by AP_BattMonitor_Bebop to get obs data. We
17  // need to return the Bebop output, not ourselves
18  RCOutput_Disco *d = static_cast<RCOutput_Disco *>(rcoutput);
19  return static_cast<RCOutput_Bebop *>(&d->bebop_out);
20  }
21 
22  void init() override;
23  void set_freq(uint32_t chmask, uint16_t freq_hz) override;
24  uint16_t get_freq(uint8_t ch) override;
25  void enable_ch(uint8_t ch) override;
26  void disable_ch(uint8_t ch) override;
27  void write(uint8_t ch, uint16_t period_us) override;
28  uint16_t read(uint8_t ch) override;
29  void read(uint16_t *period_us, uint8_t len) override;
30  void cork() override;
31  void push() override;
32  void set_esc_scaling(uint16_t min_pwm, uint16_t max_pwm) override;
33 
34 private:
35  // Disco RC output combines methods from Sysfs and Bebop
38 
39  /*
40  use a table to provide the mapping to channel numbers in each
41  backend
42  */
43  typedef struct {
45  uint8_t channel;
48  /*
49  servo rail pin numbers are from left to right when looking
50  at the CHUCK from the back, so pin1 on the servo rail is
51  closest to the first 'C' in 'C.H.U.C.K' on the case
52  */
53  { sysfs_out, 3 }, // chan1, servo rail pin 1
54  { sysfs_out, 2 }, // chan2, servo rail pin 6
55  { bebop_out, 0 }, // I2C motor output
56  { sysfs_out, 4 }, // chan4, servo rail pin 2
57  { sysfs_out, 1 }, // chan5, servo rail pin 5
58  { sysfs_out, 5 }, // chan6, servo rail pin 3
59  { sysfs_out, 0 }, // chan7, servo rail pin 4
60  };
61 };
62 
63 }
uint16_t get_freq(uint8_t ch) override
const output_table_t output_table[7]
void write(uint8_t ch, uint16_t period_us) override
RCOutput_Disco(AP_HAL::OwnPtr< AP_HAL::I2CDevice > dev)
void set_esc_scaling(uint16_t min_pwm, uint16_t max_pwm) override
uint16_t read(uint8_t ch) override
void set_freq(uint32_t chmask, uint16_t freq_hz) override
void enable_ch(uint8_t ch) override
static AP_HAL::OwnPtr< AP_HAL::Device > dev
Definition: ICM20789.cpp:16
static RCOutput_Bebop * from(AP_HAL::RCOutput *rcoutput)
void init() override
RCOutput_Sysfs sysfs_out
RCOutput_Bebop bebop_out
void disable_ch(uint8_t ch) override
void cork() override