mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 14:38:30 -04:00
AP_HAL_ChibiOS: use AP_ESC_Telem to record erpm data and error rate
don't output RPM data if bi-dir dshot is not enabled
This commit is contained in:
parent
4f547d2acc
commit
6447bd1cdd
@ -1353,9 +1353,17 @@ void RCOutput::dshot_send(pwm_group &group, uint32_t time_out_us)
|
||||
for (uint8_t i=0; i<4; i++) {
|
||||
uint8_t chan = group.chan[i];
|
||||
if (group.is_chan_enabled(i)) {
|
||||
#ifdef HAL_WITH_BIDIR_DSHOT
|
||||
// retrieve the last erpm values
|
||||
_bdshot.erpm[chan] = group.bdshot.erpm[i];
|
||||
const uint16_t erpm = group.bdshot.erpm[i];
|
||||
|
||||
// update the ESC telemetry data
|
||||
if (erpm < 0xFFFF && group.bdshot.enabled) {
|
||||
update_rpm(chan, erpm * 200 / _bdshot.motor_poles, get_erpm_error_rate(chan));
|
||||
}
|
||||
|
||||
_bdshot.erpm[chan] = erpm;
|
||||
#endif
|
||||
uint16_t pwm = period[chan];
|
||||
|
||||
if (safety_on && !(safety_mask & (1U<<(chan+chan_offset)))) {
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#include "AP_HAL_ChibiOS.h"
|
||||
#include <AP_HAL/Semaphores.h>
|
||||
#include <AP_ESC_Telem/AP_ESC_Telem.h>
|
||||
|
||||
#include "shared_dma.h"
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
@ -30,7 +32,11 @@
|
||||
|
||||
#define RCOU_DSHOT_TIMING_DEBUG 0
|
||||
|
||||
class ChibiOS::RCOutput : public AP_HAL::RCOutput {
|
||||
class ChibiOS::RCOutput : public AP_HAL::RCOutput
|
||||
#ifdef HAL_WITH_BIDIR_DSHOT
|
||||
, AP_ESC_Telem_Backend
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
// disabled channel marker
|
||||
const static uint8_t CHAN_DISABLED = 255;
|
||||
@ -151,6 +157,8 @@ public:
|
||||
with Dshot to get telemetry feedback
|
||||
*/
|
||||
void set_bidir_dshot_mask(uint16_t mask) override;
|
||||
|
||||
void set_motor_poles(uint8_t poles) override { _bdshot.motor_poles = poles; }
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -458,6 +466,7 @@ private:
|
||||
uint16_t erpm_errors[max_channels];
|
||||
uint16_t erpm_clean_frames[max_channels];
|
||||
uint32_t erpm_last_stats_ms[max_channels];
|
||||
uint8_t motor_poles;
|
||||
#endif
|
||||
} _bdshot;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user