mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 04:33:33 +08:00
drivers: use updated I2C SPI driver interface
This commit is contained in:
@@ -46,10 +46,10 @@ using namespace time_literals;
|
||||
|
||||
static constexpr uint32_t OSD_UPDATE_RATE{50_ms}; // 20 Hz
|
||||
|
||||
OSDatxxxx::OSDatxxxx(I2CSPIBusOption bus_option, int bus, int devid, int bus_frequency, spi_mode_e spi_mode) :
|
||||
SPI(DRV_OSD_DEVTYPE_ATXXXX, MODULE_NAME, bus, devid, spi_mode, bus_frequency),
|
||||
OSDatxxxx::OSDatxxxx(const I2CSPIDriverConfig &config) :
|
||||
SPI(config),
|
||||
ModuleParams(nullptr),
|
||||
I2CSPIDriver(MODULE_NAME, px4::device_bus_to_wq(get_device_id()), bus_option, bus)
|
||||
I2CSPIDriver(config)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -84,6 +84,10 @@ OSDatxxxx::init()
|
||||
}
|
||||
}
|
||||
|
||||
if (ret == PX4_OK) {
|
||||
start();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -503,27 +507,6 @@ It can be enabled with the OSD_ATXXXX_CFG parameter.
|
||||
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
|
||||
}
|
||||
|
||||
I2CSPIDriverBase *OSDatxxxx::instantiate(const BusCLIArguments &cli, const BusInstanceIterator &iterator,
|
||||
int runtime_instance)
|
||||
{
|
||||
OSDatxxxx *instance = new OSDatxxxx(iterator.configuredBusOption(), iterator.bus(), iterator.devid(),
|
||||
cli.bus_frequency, cli.spi_mode);
|
||||
|
||||
if (!instance) {
|
||||
PX4_ERR("alloc failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (OK != instance->init()) {
|
||||
delete instance;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
instance->start();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
int
|
||||
atxxxx_main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
@@ -68,11 +68,9 @@ extern "C" __EXPORT int atxxxx_main(int argc, char *argv[]);
|
||||
class OSDatxxxx : public device::SPI, public ModuleParams, public I2CSPIDriver<OSDatxxxx>
|
||||
{
|
||||
public:
|
||||
OSDatxxxx(I2CSPIBusOption bus_option, int bus, int devid, int bus_frequency, spi_mode_e spi_mode);
|
||||
OSDatxxxx(const I2CSPIDriverConfig &config);
|
||||
virtual ~OSDatxxxx() = default;
|
||||
|
||||
static I2CSPIDriverBase *instantiate(const BusCLIArguments &cli, const BusInstanceIterator &iterator,
|
||||
int runtime_instance);
|
||||
static void print_usage();
|
||||
|
||||
int init() override;
|
||||
|
||||
Reference in New Issue
Block a user