mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
drivers: add perf counters and documentation to ads7953
This commit is contained in:
parent
7d8e79c49d
commit
0cefd74fee
@ -765,6 +765,7 @@
|
||||
- [Rpm Sensor](modules/modules_driver_rpm_sensor.md)
|
||||
- [Radio Control](modules/modules_driver_radio_control.md)
|
||||
- [Transponder](modules/modules_driver_transponder.md)
|
||||
- [adc](modules/modules_driver_adc.md)
|
||||
- [Estimators](modules/modules_estimator.md)
|
||||
- [Simulations](modules/modules_simulation.md)
|
||||
- [System](modules/modules_system.md)
|
||||
|
||||
@ -154,6 +154,7 @@ If enabled, internal ADCs are not used.
|
||||
)DESCR_STR");
|
||||
|
||||
PRINT_MODULE_USAGE_NAME("ads1115", "driver");
|
||||
PRINT_MODULE_USAGE_SUBCATEGORY("adc");
|
||||
PRINT_MODULE_USAGE_COMMAND("start");
|
||||
PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(true, false);
|
||||
PRINT_MODULE_USAGE_PARAMS_I2C_ADDRESS(0x48);
|
||||
|
||||
@ -8,11 +8,20 @@
|
||||
ADS7953::ADS7953(const I2CSPIDriverConfig &config) :
|
||||
SPI(config),
|
||||
I2CSPIDriver(config),
|
||||
ModuleParams(nullptr)
|
||||
ModuleParams(nullptr),
|
||||
_cycle_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": single-sample")),
|
||||
_comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comms errors"))
|
||||
{
|
||||
static_assert(arraySize(adc_report_s::channel_id) >= NUM_CHANNELS, "ADS7953 reports 16 channels");
|
||||
}
|
||||
|
||||
ADS7953::~ADS7953()
|
||||
{
|
||||
ScheduleClear();
|
||||
perf_free(_cycle_perf);
|
||||
perf_free(_comms_errors);
|
||||
}
|
||||
|
||||
int ADS7953::init()
|
||||
{
|
||||
int ret = SPI::init();
|
||||
@ -30,7 +39,7 @@ int ADS7953::init()
|
||||
_adc_report.channel_id[i] = -1;
|
||||
}
|
||||
|
||||
ScheduleOnInterval(10_ms);
|
||||
ScheduleOnInterval(SAMPLE_INTERVAL, SAMPLE_INTERVAL);
|
||||
return PX4_OK;
|
||||
}
|
||||
|
||||
@ -56,7 +65,6 @@ int ADS7953::probe()
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
PX4_INFO("ADS7953 was found");
|
||||
return PX4_OK;
|
||||
}
|
||||
|
||||
@ -94,6 +102,9 @@ int ADS7953::get_measurements()
|
||||
_adc_report.channel_id[ch_id] = ch_id;
|
||||
_adc_report.raw_data[ch_id] = ((((uint16_t) recv_data[0]) & 0x0F) << 8) | recv_data[1];
|
||||
}
|
||||
|
||||
} else {
|
||||
perf_count(_comms_errors);
|
||||
}
|
||||
|
||||
// Find index to measure next
|
||||
@ -112,9 +123,11 @@ int ADS7953::get_measurements()
|
||||
|
||||
void ADS7953::RunImpl()
|
||||
{
|
||||
perf_begin(_cycle_perf);
|
||||
get_measurements();
|
||||
_adc_report.timestamp = hrt_absolute_time();
|
||||
_adc_report_pub.publish(_adc_report);
|
||||
perf_end(_cycle_perf);
|
||||
|
||||
for (unsigned i = 0; i < PX4_MAX_ADC_CHANNELS; ++i) {
|
||||
_adc_report.channel_id[i] = -1;
|
||||
|
||||
@ -19,7 +19,7 @@ class ADS7953 : public device::SPI, public I2CSPIDriver<ADS7953>, public ModuleP
|
||||
{
|
||||
public:
|
||||
ADS7953(const I2CSPIDriverConfig &config);
|
||||
virtual ~ADS7953() = default;
|
||||
~ADS7953() override;
|
||||
static void print_usage();
|
||||
|
||||
int init() override;
|
||||
@ -31,7 +31,9 @@ private:
|
||||
static constexpr int NUM_CHANNELS = 16;
|
||||
uORB::PublicationMulti<adc_report_s> _adc_report_pub{ORB_ID(adc_report)};
|
||||
|
||||
static const hrt_abstime SAMPLE_INTERVAL{50_ms};
|
||||
static const hrt_abstime SAMPLE_INTERVAL{10_ms};
|
||||
perf_counter_t _cycle_perf;
|
||||
perf_counter_t _comms_errors;
|
||||
|
||||
DEFINE_PARAMETERS(
|
||||
(ParamFloat<px4::params::ADC_ADS7953_REFV>) _adc_ads7953_refv
|
||||
|
||||
@ -410,6 +410,7 @@ ADC driver.
|
||||
)DESCR_STR");
|
||||
|
||||
PRINT_MODULE_USAGE_NAME("adc", "driver");
|
||||
PRINT_MODULE_USAGE_SUBCATEGORY("adc");
|
||||
PRINT_MODULE_USAGE_COMMAND("start");
|
||||
PRINT_MODULE_USAGE_COMMAND("test");
|
||||
PRINT_MODULE_USAGE_PARAM_FLAG('n', "Do not publish ADC report, only system power", true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user