mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-12-02 06:10:45 +08:00
fix(driver/AUAV): naming and documentation
This commit is contained in:
1 parent
3c0d848602
commit
b9b49cf8c4
6 files changed
+11
-11
No files matched your search
@@ -59,12 +59,12 @@ I2CSPIDriverBase *AUAV::instantiate(const I2CSPIDriverConfig &config, const int
|
||||
return instance;
|
||||
}
|
||||
|
||||
AUAV::AUAV(const I2CSPIDriverConfig &config, const uint8_t status_byte) :
|
||||
AUAV::AUAV(const I2CSPIDriverConfig &config, const uint8_t status_byte_expected) :
|
||||
I2C(config),
|
||||
I2CSPIDriver(config),
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": read")),
|
||||
_comms_errors(perf_alloc(PC_COUNT, MODULE_NAME": comms errors")),
|
||||
_status_byte(status_byte)
|
||||
_status_byte_expected(status_byte_expected)
|
||||
{
|
||||
I2C::_retries = 5;
|
||||
}
|
||||
@@ -126,7 +126,7 @@ int AUAV::probe()
|
||||
int status = transfer(nullptr, 0, &res_data, 1);
|
||||
|
||||
/* Check that the sensor is powered on, error free and of the expected type (mode bits) */
|
||||
if (status == PX4_OK && res_data == _status_byte) {
|
||||
if (status == PX4_OK && res_data == _status_byte_expected) {
|
||||
return PX4_OK;
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ void AUAV::handle_state_gather_measurement()
|
||||
int status = transfer(nullptr, 0, res_data, sizeof(res_data));
|
||||
|
||||
/* Continue processing if the transfer was a success and the status is as expected (powered on, not busy, no errors) */
|
||||
if (status == PX4_OK && res_data[0] == _status_byte) {
|
||||
if (status == PX4_OK && res_data[0] == _status_byte_expected) {
|
||||
const hrt_abstime timestamp_sample = hrt_absolute_time();
|
||||
|
||||
const uint32_t pressure_raw = (res_data[1] << 16) | (res_data[2] << 8) | (res_data[3]);
|
||||
|
||||
@@ -49,7 +49,7 @@ static constexpr uint32_t I2C_SPEED = 100 * 1000; // 100 kHz I2C serial interfac
|
||||
class AUAV : public device::I2C, public I2CSPIDriver<AUAV>
|
||||
{
|
||||
public:
|
||||
explicit AUAV(const I2CSPIDriverConfig &config, const uint8_t status_byte);
|
||||
explicit AUAV(const I2CSPIDriverConfig &config, const uint8_t status_byte_expected);
|
||||
virtual ~AUAV();
|
||||
|
||||
static I2CSPIDriverBase *instantiate(const I2CSPIDriverConfig &config, const int runtime_instance);
|
||||
@@ -131,12 +131,12 @@ protected:
|
||||
* bit 0: ALU error (0 = ok)
|
||||
* bit 1: reserved (0)
|
||||
* bit 2: memory error (0 = ok)
|
||||
* bit 3-4: mode (differential: 0b01, absolute: 0b00)
|
||||
* bit 3-4: mode (differential: 0b10, absolute: 0b00)
|
||||
* bit 5: busy (0 = measurement ready)
|
||||
* bit 6: power on (1)
|
||||
* bit 7: reserved (0)
|
||||
*/
|
||||
const uint8_t _status_byte;
|
||||
const uint8_t _status_byte_expected;
|
||||
|
||||
private:
|
||||
int probe() override;
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "AUAV_Absolute.hpp"
|
||||
|
||||
AUAV_Absolute::AUAV_Absolute(const I2CSPIDriverConfig &config) :
|
||||
AUAV(config, STATUS_BYTE_ABS),
|
||||
AUAV(config, STATUS_BYTE_EXPECTED_ABS),
|
||||
_baro_external(config.external)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ static_assert(ABS_CONVERSION_INTERVAL >= 7000, "Conversion interval is too fast"
|
||||
static constexpr float MBAR_TO_PA = 100.0f;
|
||||
|
||||
/* Status byte of a completed reading without error */
|
||||
static constexpr uint8_t STATUS_BYTE_ABS = 0x40;
|
||||
static constexpr uint8_t STATUS_BYTE_EXPECTED_ABS = 0x40;
|
||||
|
||||
class AUAV_Absolute : public AUAV
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <cctype>
|
||||
|
||||
AUAV_Differential::AUAV_Differential(const I2CSPIDriverConfig &config) :
|
||||
AUAV(config, STATUS_BYTE_DIFF)
|
||||
AUAV(config, STATUS_BYTE_EXPECTED_DIFF)
|
||||
{
|
||||
/* Initialize cal_range from parameter as fallback value */
|
||||
int32_t hw_model = 0;
|
||||
|
||||
@@ -56,7 +56,7 @@ static constexpr int64_t DIFF_CONVERSION_INTERVAL = (1000000 / DIFF_MEAS_RATE);
|
||||
static_assert(DIFF_CONVERSION_INTERVAL >= 7000, "Conversion interval is too fast");
|
||||
|
||||
/* Status byte of a completed reading without error */
|
||||
static constexpr uint8_t STATUS_BYTE_DIFF = 0x50;
|
||||
static constexpr uint8_t STATUS_BYTE_EXPECTED_DIFF = 0x50;
|
||||
|
||||
/* Valid AUAV types */
|
||||
static constexpr int32_t AUAV_LD_05 = 5;
|
||||
|
||||
Reference in new issue
Block a user