3.4AP_HAL::RCInput and AP_HAL::RCOutput

前言

 前面梳理了AP_HAL的硬件抽象层,包括串口、调度器、I2C等等,这次涉及到增加电机的输出口,所以有必要RC的输入输出的框架梳理一遍

AP_HAL::RCInput

 这里是对RCinput进行了抽象,具体的实现我们参看AP_HAL_PX4下的RCInput.cpp的实现
#define RC_INPUT_MIN_PULSEWIDTH 900
#define RC_INPUT_MAX_PULSEWIDTH 2100

class AP_HAL::RCInput {
public:
  /**
  * Call init from the platform hal instance init, so that both the type of
  * the RCInput implementation and init argument (e.g. ISRRegistry) are
  * known to the programmer. (It's too difficult to describe this dependency
  * in the C++ type system.)
  */
  virtual void init() = 0;// 初始化订阅 orb_subscribe(ORB_ID(input_rc))消息
  virtual void teardown() {};

  /**
  * Return true if there has been new input since the last call to new_input()
  * 通过_rcin.timestamp_last_signal来判断是否有新的数值更新上来
  */
  virtual bool new_input(void) = 0;

  /**
  * Return the number of valid channels in the last read
  * 返回_rcin.channel_count的通道数目
  */
  virtual uint8_t num_channels() = 0;

  /* Read a single channel at a time */优先返回 _override[ch]的值,没有的情况下返回_rcin.values[ch]的值
  virtual uint16_t read(uint8_t ch) = 0;

  /* Read an array of channels, return the valid count */从_rcin.values[ch]中读取len个channel的值
  virtual uint8_t read(uint16_t* periods, uint8_t len) = 0;

  /**
  * Overrides: these are really grody and don't
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值