mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 11:59:17 +08:00
vtrantech Rename to match V1.1 vcm5883->vcm1193l
This commit is contained in:
committed by
Daniel Agar
parent
b264577daa
commit
2feb096fb9
@@ -20,7 +20,7 @@ then
|
|||||||
else
|
else
|
||||||
# Internal SPI bus ICM20649
|
# Internal SPI bus ICM20649
|
||||||
icm20649 -s -R 4 start
|
icm20649 -s -R 4 start
|
||||||
vcm5883 -I -b 4 -R 6 start
|
vcm1193l -I -b 4 -R 6 start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Internal SPI bus ICM42688p
|
# Internal SPI bus ICM42688p
|
||||||
@@ -43,7 +43,7 @@ else
|
|||||||
else
|
else
|
||||||
# Internal SPI bus ICM20649
|
# Internal SPI bus ICM20649
|
||||||
icm20649 -s -R 6 start
|
icm20649 -s -R 6 start
|
||||||
vcm5883 -I -b 4 start
|
vcm1193l -I -b 4 start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Internal SPI bus ICM42688p
|
# Internal SPI bus ICM42688p
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
#define DRV_MAG_DEVTYPE_RM3100 0x07
|
#define DRV_MAG_DEVTYPE_RM3100 0x07
|
||||||
#define DRV_MAG_DEVTYPE_QMC5883L 0x08
|
#define DRV_MAG_DEVTYPE_QMC5883L 0x08
|
||||||
#define DRV_MAG_DEVTYPE_AK09916 0x09
|
#define DRV_MAG_DEVTYPE_AK09916 0x09
|
||||||
#define DRV_MAG_DEVTYPE_VCM5883 0x0A
|
#define DRV_MAG_DEVTYPE_VCM1193L 0x0A
|
||||||
|
|
||||||
#define DRV_MAG_DEVTYPE_IST8308 0x0B
|
#define DRV_MAG_DEVTYPE_IST8308 0x0B
|
||||||
#define DRV_MAG_DEVTYPE_LIS2MDL 0x0C
|
#define DRV_MAG_DEVTYPE_LIS2MDL 0x0C
|
||||||
|
|||||||
@@ -31,4 +31,4 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
add_subdirectory(vcm5883)
|
add_subdirectory(vcm1193l)
|
||||||
|
|||||||
+6
-6
@@ -32,14 +32,14 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
px4_add_module(
|
px4_add_module(
|
||||||
MODULE drivers__magnetometer__vcm5883
|
MODULE drivers__magnetometer__vcm1193l
|
||||||
MAIN vcm5883
|
MAIN vcm1193l
|
||||||
COMPILE_FLAGS
|
COMPILE_FLAGS
|
||||||
SRCS
|
SRCS
|
||||||
VCM5883.cpp
|
VCM1193L.cpp
|
||||||
VCM5883.hpp
|
VCM1193L.hpp
|
||||||
vcm5883_main.cpp
|
vcm1193l_main.cpp
|
||||||
VTT_VCM5883_registers.hpp
|
VTT_VCM1193L_registers.hpp
|
||||||
DEPENDS
|
DEPENDS
|
||||||
drivers_magnetometer
|
drivers_magnetometer
|
||||||
px4_work_queue
|
px4_work_queue
|
||||||
+14
-14
@@ -31,7 +31,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "VCM5883.hpp"
|
#include "VCM1193L.hpp"
|
||||||
|
|
||||||
using namespace time_literals;
|
using namespace time_literals;
|
||||||
|
|
||||||
@@ -40,22 +40,22 @@ static constexpr int16_t combine(uint8_t msb, uint8_t lsb)
|
|||||||
return (msb << 8u) | lsb;
|
return (msb << 8u) | lsb;
|
||||||
}
|
}
|
||||||
|
|
||||||
VCM5883::VCM5883(I2CSPIBusOption bus_option, int bus, int bus_frequency, enum Rotation rotation) :
|
VCM1193L::VCM1193L(I2CSPIBusOption bus_option, int bus, int bus_frequency, enum Rotation rotation) :
|
||||||
I2C(DRV_MAG_DEVTYPE_VCM5883, MODULE_NAME, bus, I2C_ADDRESS_DEFAULT, bus_frequency),
|
I2C(DRV_MAG_DEVTYPE_VCM1193L, MODULE_NAME, bus, I2C_ADDRESS_DEFAULT, bus_frequency),
|
||||||
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus),
|
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus),
|
||||||
_px4_mag(get_device_id(), rotation)
|
_px4_mag(get_device_id(), rotation)
|
||||||
{
|
{
|
||||||
_px4_mag.set_external(external());
|
_px4_mag.set_external(external());
|
||||||
}
|
}
|
||||||
|
|
||||||
VCM5883::~VCM5883()
|
VCM1193L::~VCM1193L()
|
||||||
{
|
{
|
||||||
perf_free(_reset_perf);
|
perf_free(_reset_perf);
|
||||||
perf_free(_bad_register_perf);
|
perf_free(_bad_register_perf);
|
||||||
perf_free(_bad_transfer_perf);
|
perf_free(_bad_transfer_perf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int VCM5883::init()
|
int VCM1193L::init()
|
||||||
{
|
{
|
||||||
int ret = I2C::init();
|
int ret = I2C::init();
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ int VCM5883::init()
|
|||||||
return Reset() ? 0 : -1;
|
return Reset() ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VCM5883::Reset()
|
bool VCM1193L::Reset()
|
||||||
{
|
{
|
||||||
_state = STATE::RESET;
|
_state = STATE::RESET;
|
||||||
ScheduleClear();
|
ScheduleClear();
|
||||||
@@ -75,7 +75,7 @@ bool VCM5883::Reset()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VCM5883::print_status()
|
void VCM1193L::print_status()
|
||||||
{
|
{
|
||||||
I2CSPIDriverBase::print_status();
|
I2CSPIDriverBase::print_status();
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ void VCM5883::print_status()
|
|||||||
perf_print_counter(_bad_transfer_perf);
|
perf_print_counter(_bad_transfer_perf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int VCM5883::probe()
|
int VCM1193L::probe()
|
||||||
{
|
{
|
||||||
_retries = 1;
|
_retries = 1;
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ int VCM5883::probe()
|
|||||||
return PX4_ERROR;
|
return PX4_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VCM5883::RunImpl()
|
void VCM1193L::RunImpl()
|
||||||
{
|
{
|
||||||
const hrt_abstime now = hrt_absolute_time();
|
const hrt_abstime now = hrt_absolute_time();
|
||||||
|
|
||||||
@@ -233,7 +233,7 @@ void VCM5883::RunImpl()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VCM5883::Configure()
|
bool VCM1193L::Configure()
|
||||||
{
|
{
|
||||||
// first set and clear all configured register bits
|
// first set and clear all configured register bits
|
||||||
|
|
||||||
@@ -255,7 +255,7 @@ bool VCM5883::Configure()
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VCM5883::RegisterCheck(const register_config_t ®_cfg)
|
bool VCM1193L::RegisterCheck(const register_config_t ®_cfg)
|
||||||
{
|
{
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
@@ -275,7 +275,7 @@ bool VCM5883::RegisterCheck(const register_config_t ®_cfg)
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t VCM5883::RegisterRead(Register reg)
|
uint8_t VCM1193L::RegisterRead(Register reg)
|
||||||
{
|
{
|
||||||
const uint8_t cmd = static_cast<uint8_t>(reg);
|
const uint8_t cmd = static_cast<uint8_t>(reg);
|
||||||
uint8_t buffer{};
|
uint8_t buffer{};
|
||||||
@@ -283,13 +283,13 @@ uint8_t VCM5883::RegisterRead(Register reg)
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VCM5883::RegisterWrite(Register reg, uint8_t value)
|
void VCM1193L::RegisterWrite(Register reg, uint8_t value)
|
||||||
{
|
{
|
||||||
uint8_t buffer[2] { (uint8_t)reg, value };
|
uint8_t buffer[2] { (uint8_t)reg, value };
|
||||||
transfer(buffer, sizeof(buffer), nullptr, 0);
|
transfer(buffer, sizeof(buffer), nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VCM5883::RegisterSetAndClearBits(Register reg, uint8_t setbits, uint8_t clearbits)
|
void VCM1193L::RegisterSetAndClearBits(Register reg, uint8_t setbits, uint8_t clearbits)
|
||||||
{
|
{
|
||||||
const uint8_t orig_val = RegisterRead(reg);
|
const uint8_t orig_val = RegisterRead(reg);
|
||||||
uint8_t val = (orig_val & ~clearbits) | setbits;
|
uint8_t val = (orig_val & ~clearbits) | setbits;
|
||||||
+7
-7
@@ -32,15 +32,15 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file VCM5883.hpp
|
* @file VCM1193L.hpp
|
||||||
*
|
*
|
||||||
* Driver for the VCM5883 connected via I2C.
|
* Driver for the VCM1193L connected via I2C.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "VTT_VCM5883_registers.hpp"
|
#include "VTT_VCM1193L_registers.hpp"
|
||||||
|
|
||||||
#include <drivers/drv_hrt.h>
|
#include <drivers/drv_hrt.h>
|
||||||
#include <lib/drivers/device/i2c.h>
|
#include <lib/drivers/device/i2c.h>
|
||||||
@@ -48,13 +48,13 @@
|
|||||||
#include <lib/perf/perf_counter.h>
|
#include <lib/perf/perf_counter.h>
|
||||||
#include <px4_platform_common/i2c_spi_buses.h>
|
#include <px4_platform_common/i2c_spi_buses.h>
|
||||||
|
|
||||||
using namespace VTT_VCM5883;
|
using namespace VTT_VCM1193L;
|
||||||
|
|
||||||
class VCM5883 : public device::I2C, public I2CSPIDriver<VCM5883>
|
class VCM1193L : public device::I2C, public I2CSPIDriver<VCM1193L>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VCM5883(I2CSPIBusOption bus_option, int bus, int bus_frequency, enum Rotation rotation = ROTATION_NONE);
|
VCM1193L(I2CSPIBusOption bus_option, int bus, int bus_frequency, enum Rotation rotation = ROTATION_NONE);
|
||||||
~VCM5883() override;
|
~VCM1193L() override;
|
||||||
|
|
||||||
static I2CSPIDriverBase *instantiate(const BusCLIArguments &cli, const BusInstanceIterator &iterator,
|
static I2CSPIDriverBase *instantiate(const BusCLIArguments &cli, const BusInstanceIterator &iterator,
|
||||||
int runtime_instance);
|
int runtime_instance);
|
||||||
+4
-4
@@ -32,9 +32,9 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file VTT_VCM5883_registers.hpp
|
* @file VTT_VCM1193L_registers.hpp
|
||||||
*
|
*
|
||||||
* QST VCM5883 registers.
|
* QST VCM1193L registers.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace VTT_VCM5883
|
namespace VTT_VCM1193L
|
||||||
{
|
{
|
||||||
|
|
||||||
// TODO: move to a central header
|
// TODO: move to a central header
|
||||||
@@ -98,4 +98,4 @@ enum CNTL1_BIT : uint8_t {
|
|||||||
SET_RESET = Bit1 | Bit0, // Set Reset (Cleared)
|
SET_RESET = Bit1 | Bit0, // Set Reset (Cleared)
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VCM5883
|
} // namespace VCM1193L
|
||||||
+8
-8
@@ -33,12 +33,12 @@
|
|||||||
|
|
||||||
#include <px4_platform_common/getopt.h>
|
#include <px4_platform_common/getopt.h>
|
||||||
#include <px4_platform_common/module.h>
|
#include <px4_platform_common/module.h>
|
||||||
#include "VCM5883.hpp"
|
#include "VCM1193L.hpp"
|
||||||
|
|
||||||
I2CSPIDriverBase *
|
I2CSPIDriverBase *
|
||||||
VCM5883::instantiate(const BusCLIArguments &cli, const BusInstanceIterator &iterator, int runtime_instance)
|
VCM1193L::instantiate(const BusCLIArguments &cli, const BusInstanceIterator &iterator, int runtime_instance)
|
||||||
{
|
{
|
||||||
VCM5883 *instance = new VCM5883(iterator.configuredBusOption(), iterator.bus(), cli.bus_frequency, cli.rotation);
|
VCM1193L *instance = new VCM1193L(iterator.configuredBusOption(), iterator.bus(), cli.bus_frequency, cli.rotation);
|
||||||
|
|
||||||
if (!instance) {
|
if (!instance) {
|
||||||
PX4_ERR("alloc failed");
|
PX4_ERR("alloc failed");
|
||||||
@@ -54,9 +54,9 @@ VCM5883::instantiate(const BusCLIArguments &cli, const BusInstanceIterator &iter
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VCM5883::print_usage()
|
void VCM1193L::print_usage()
|
||||||
{
|
{
|
||||||
PRINT_MODULE_USAGE_NAME("vcm5883", "driver");
|
PRINT_MODULE_USAGE_NAME("vcm1193l", "driver");
|
||||||
PRINT_MODULE_USAGE_SUBCATEGORY("magnetometer");
|
PRINT_MODULE_USAGE_SUBCATEGORY("magnetometer");
|
||||||
PRINT_MODULE_USAGE_COMMAND("start");
|
PRINT_MODULE_USAGE_COMMAND("start");
|
||||||
PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(true, false);
|
PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(true, false);
|
||||||
@@ -64,10 +64,10 @@ void VCM5883::print_usage()
|
|||||||
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
|
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int vcm5883_main(int argc, char *argv[])
|
extern "C" int vcm1193l_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int ch;
|
int ch;
|
||||||
using ThisDriver = VCM5883;
|
using ThisDriver = VCM1193L;
|
||||||
BusCLIArguments cli{true, false};
|
BusCLIArguments cli{true, false};
|
||||||
cli.default_i2c_frequency = I2C_SPEED;
|
cli.default_i2c_frequency = I2C_SPEED;
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ extern "C" int vcm5883_main(int argc, char *argv[])
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
BusInstanceIterator iterator(MODULE_NAME, cli, DRV_MAG_DEVTYPE_VCM5883);
|
BusInstanceIterator iterator(MODULE_NAME, cli, DRV_MAG_DEVTYPE_VCM1193L);
|
||||||
|
|
||||||
if (!strcmp(verb, "start")) {
|
if (!strcmp(verb, "start")) {
|
||||||
return ThisDriver::module_start(cli, iterator);
|
return ThisDriver::module_start(cli, iterator);
|
||||||
Reference in New Issue
Block a user