Skip to content

Commit

Permalink
imu/invensense: minor cleanup
Browse files Browse the repository at this point in the history
 - remove leftover Start()
 - remove "reset" from command line (stop + start is sufficient)
  • Loading branch information
dagar committed Apr 9, 2020
1 parent 8338f4e commit 74e99fa
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 142 deletions.
10 changes: 4 additions & 6 deletions src/drivers/imu/invensense/icm20602/ICM20602.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,9 @@ class ICM20602 : public device::SPI, public I2CSPIDriver<ICM20602>
int init() override;
void print_status() override;

void Start();
bool Reset();

protected:
void custom_method(const BusCLIArguments &cli) override;
void exit_and_cleanup() override;
private:
void exit_and_cleanup() override;

// Sensor Configuration
static constexpr float FIFO_SAMPLE_DT{125.f};
static constexpr uint32_t SAMPLES_PER_TRANSFER{2}; // ensure at least 1 new accel sample per transfer
Expand All @@ -100,6 +96,8 @@ class ICM20602 : public device::SPI, public I2CSPIDriver<ICM20602>

int probe() override;

bool Reset();

bool Configure();
void ConfigureAccel();
void ConfigureGyro();
Expand Down
13 changes: 1 addition & 12 deletions src/drivers/imu/invensense/icm20602/icm20602_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@
#include <px4_platform_common/getopt.h>
#include <px4_platform_common/module.h>

void
ICM20602::print_usage()
void ICM20602::print_usage()
{
PRINT_MODULE_USAGE_NAME("icm20602", "driver");
PRINT_MODULE_USAGE_SUBCATEGORY("imu");
PRINT_MODULE_USAGE_COMMAND("start");
PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(false, true);
PRINT_MODULE_USAGE_PARAM_INT('R', 0, 0, 35, "Rotation", true);
PRINT_MODULE_USAGE_COMMAND("reset");
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
}

Expand All @@ -67,11 +65,6 @@ I2CSPIDriverBase *ICM20602::instantiate(const BusCLIArguments &cli, const BusIns
return instance;
}

void ICM20602::custom_method(const BusCLIArguments &cli)
{
Reset();
}

extern "C" int icm20602_main(int argc, char *argv[])
{
int ch;
Expand Down Expand Up @@ -108,10 +101,6 @@ extern "C" int icm20602_main(int argc, char *argv[])
return ThisDriver::module_status(iterator);
}

if (!strcmp(verb, "reset")) {
return ThisDriver::module_custom_method(cli, iterator);
}

ThisDriver::print_usage();
return -1;
}
10 changes: 4 additions & 6 deletions src/drivers/imu/invensense/icm20608g/ICM20608G.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,9 @@ class ICM20608G : public device::SPI, public I2CSPIDriver<ICM20608G>
int init() override;
void print_status() override;

void Start();
bool Reset();

protected:
void custom_method(const BusCLIArguments &cli) override;
void exit_and_cleanup() override;
private:
void exit_and_cleanup() override;

// Sensor Configuration
static constexpr float FIFO_SAMPLE_DT{125.f};
static constexpr uint32_t SAMPLES_PER_TRANSFER{2}; // ensure at least 1 new accel sample per transfer
Expand All @@ -102,6 +98,8 @@ class ICM20608G : public device::SPI, public I2CSPIDriver<ICM20608G>

int probe() override;

bool Reset();

bool Configure();
void ConfigureAccel();
void ConfigureGyro();
Expand Down
13 changes: 1 addition & 12 deletions src/drivers/imu/invensense/icm20608g/icm20608g_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@
#include <px4_platform_common/getopt.h>
#include <px4_platform_common/module.h>

void
ICM20608G::print_usage()
void ICM20608G::print_usage()
{
PRINT_MODULE_USAGE_NAME("icm20608g", "driver");
PRINT_MODULE_USAGE_SUBCATEGORY("imu");
PRINT_MODULE_USAGE_COMMAND("start");
PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(false, true);
PRINT_MODULE_USAGE_PARAM_INT('R', 0, 0, 35, "Rotation", true);
PRINT_MODULE_USAGE_COMMAND("reset");
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
}

Expand All @@ -67,11 +65,6 @@ I2CSPIDriverBase *ICM20608G::instantiate(const BusCLIArguments &cli, const BusIn
return instance;
}

void ICM20608G::custom_method(const BusCLIArguments &cli)
{
Reset();
}

extern "C" int icm20608g_main(int argc, char *argv[])
{
int ch;
Expand Down Expand Up @@ -108,10 +101,6 @@ extern "C" int icm20608g_main(int argc, char *argv[])
return ThisDriver::module_status(iterator);
}

if (!strcmp(verb, "reset")) {
return ThisDriver::module_custom_method(cli, iterator);
}

ThisDriver::print_usage();
return -1;
}
10 changes: 4 additions & 6 deletions src/drivers/imu/invensense/icm20689/ICM20689.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,9 @@ class ICM20689 : public device::SPI, public I2CSPIDriver<ICM20689>
int init() override;
void print_status() override;

void Start();
bool Reset();

protected:
void custom_method(const BusCLIArguments &cli) override;
void exit_and_cleanup() override;
private:
void exit_and_cleanup() override;

// Sensor Configuration
static constexpr float FIFO_SAMPLE_DT{125.f};
static constexpr uint32_t SAMPLES_PER_TRANSFER{2}; // ensure at least 1 new accel sample per transfer
Expand All @@ -102,6 +98,8 @@ class ICM20689 : public device::SPI, public I2CSPIDriver<ICM20689>

int probe() override;

bool Reset();

bool Configure();
void ConfigureAccel();
void ConfigureGyro();
Expand Down
13 changes: 1 addition & 12 deletions src/drivers/imu/invensense/icm20689/icm20689_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@
#include <px4_platform_common/getopt.h>
#include <px4_platform_common/module.h>

void
ICM20689::print_usage()
void ICM20689::print_usage()
{
PRINT_MODULE_USAGE_NAME("icm20689", "driver");
PRINT_MODULE_USAGE_SUBCATEGORY("imu");
PRINT_MODULE_USAGE_COMMAND("start");
PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(false, true);
PRINT_MODULE_USAGE_PARAM_INT('R', 0, 0, 35, "Rotation", true);
PRINT_MODULE_USAGE_COMMAND("reset");
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
}

Expand All @@ -67,11 +65,6 @@ I2CSPIDriverBase *ICM20689::instantiate(const BusCLIArguments &cli, const BusIns
return instance;
}

void ICM20689::custom_method(const BusCLIArguments &cli)
{
Reset();
}

extern "C" int icm20689_main(int argc, char *argv[])
{
int ch;
Expand Down Expand Up @@ -108,10 +101,6 @@ extern "C" int icm20689_main(int argc, char *argv[])
return ThisDriver::module_status(iterator);
}

if (!strcmp(verb, "reset")) {
return ThisDriver::module_custom_method(cli, iterator);
}

ThisDriver::print_usage();
return -1;
}
10 changes: 4 additions & 6 deletions src/drivers/imu/invensense/icm40609d/ICM40609D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,9 @@ class ICM40609D : public device::SPI, public I2CSPIDriver<ICM40609D>
int init() override;
void print_status() override;

void Start();
bool Reset();

protected:
void custom_method(const BusCLIArguments &cli) override;
void exit_and_cleanup() override;
private:
void exit_and_cleanup() override;

// Sensor Configuration
static constexpr float FIFO_SAMPLE_DT{125.f};
static constexpr uint32_t SAMPLES_PER_TRANSFER{1}; // ensure at least 1 new accel sample per transfer
Expand Down Expand Up @@ -103,6 +99,8 @@ class ICM40609D : public device::SPI, public I2CSPIDriver<ICM40609D>

int probe() override;

bool Reset();

bool Configure();
void ConfigureAccel();
void ConfigureGyro();
Expand Down
10 changes: 0 additions & 10 deletions src/drivers/imu/invensense/icm40609d/icm40609d_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ void ICM40609D::print_usage()
PRINT_MODULE_USAGE_COMMAND("start");
PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(false, true);
PRINT_MODULE_USAGE_PARAM_INT('R', 0, 0, 35, "Rotation", true);
PRINT_MODULE_USAGE_COMMAND("reset");
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
}

Expand All @@ -66,11 +65,6 @@ I2CSPIDriverBase *ICM40609D::instantiate(const BusCLIArguments &cli, const BusIn
return instance;
}

void ICM40609D::custom_method(const BusCLIArguments &cli)
{
Reset();
}

extern "C" int icm40609d_main(int argc, char *argv[])
{
int ch;
Expand Down Expand Up @@ -107,10 +101,6 @@ extern "C" int icm40609d_main(int argc, char *argv[])
return ThisDriver::module_status(iterator);
}

if (!strcmp(verb, "reset")) {
return ThisDriver::module_custom_method(cli, iterator);
}

ThisDriver::print_usage();
return -1;
}
10 changes: 4 additions & 6 deletions src/drivers/imu/invensense/icm42688p/ICM42688P.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,9 @@ class ICM42688P : public device::SPI, public I2CSPIDriver<ICM42688P>
int init() override;
void print_status() override;

void Start();
bool Reset();

protected:
void custom_method(const BusCLIArguments &cli) override;
void exit_and_cleanup() override;
private:
void exit_and_cleanup() override;

// Sensor Configuration
static constexpr float FIFO_SAMPLE_DT{125.f};
static constexpr uint32_t SAMPLES_PER_TRANSFER{1}; // ensure at least 1 new accel sample per transfer
Expand Down Expand Up @@ -103,6 +99,8 @@ class ICM42688P : public device::SPI, public I2CSPIDriver<ICM42688P>

int probe() override;

bool Reset();

bool Configure();
void ConfigureAccel();
void ConfigureGyro();
Expand Down
10 changes: 0 additions & 10 deletions src/drivers/imu/invensense/icm42688p/icm42688p_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ void ICM42688P::print_usage()
PRINT_MODULE_USAGE_COMMAND("start");
PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(false, true);
PRINT_MODULE_USAGE_PARAM_INT('R', 0, 0, 35, "Rotation", true);
PRINT_MODULE_USAGE_COMMAND("reset");
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
}

Expand All @@ -66,11 +65,6 @@ I2CSPIDriverBase *ICM42688P::instantiate(const BusCLIArguments &cli, const BusIn
return instance;
}

void ICM42688P::custom_method(const BusCLIArguments &cli)
{
Reset();
}

extern "C" int icm42688p_main(int argc, char *argv[])
{
int ch;
Expand Down Expand Up @@ -107,10 +101,6 @@ extern "C" int icm42688p_main(int argc, char *argv[])
return ThisDriver::module_status(iterator);
}

if (!strcmp(verb, "reset")) {
return ThisDriver::module_custom_method(cli, iterator);
}

ThisDriver::print_usage();
return -1;
}
10 changes: 4 additions & 6 deletions src/drivers/imu/invensense/mpu6000/MPU6000.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,9 @@ class MPU6000 : public device::SPI, public I2CSPIDriver<MPU6000>
int init() override;
void print_status() override;

void Start();
bool Reset();

protected:
void custom_method(const BusCLIArguments &cli) override;
void exit_and_cleanup() override;
private:
void exit_and_cleanup() override;

// Sensor Configuration
static constexpr float FIFO_SAMPLE_DT{125.f};
static constexpr uint32_t SAMPLES_PER_TRANSFER{8}; // ensure at least 1 new accel sample per transfer
Expand All @@ -100,6 +96,8 @@ class MPU6000 : public device::SPI, public I2CSPIDriver<MPU6000>

int probe() override;

bool Reset();

bool Configure();
void ConfigureAccel();
void ConfigureGyro();
Expand Down
15 changes: 2 additions & 13 deletions src/drivers/imu/invensense/mpu6000/mpu6000_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@
#include <px4_platform_common/getopt.h>
#include <px4_platform_common/module.h>

void
MPU6000::print_usage()
void MPU6000::print_usage()
{
PRINT_MODULE_USAGE_NAME("mpu6000", "driver");
PRINT_MODULE_USAGE_SUBCATEGORY("imu");
PRINT_MODULE_USAGE_COMMAND("start");
PRINT_MODULE_USAGE_PARAMS_I2C_SPI_DRIVER(false, true);
PRINT_MODULE_USAGE_PARAM_INT('R', 0, 0, 35, "Rotation", true);
PRINT_MODULE_USAGE_COMMAND("reset");
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
}

Expand All @@ -67,17 +65,12 @@ I2CSPIDriverBase *MPU6000::instantiate(const BusCLIArguments &cli, const BusInst
return instance;
}

void MPU6000::custom_method(const BusCLIArguments &cli)
{
Reset();
}

extern "C" int mpu6000_main(int argc, char *argv[])
{
int ch;
using ThisDriver = MPU6000;
BusCLIArguments cli{false, true};
cli.default_spi_frequency = InvenSense_MPU6000::SPI_SPEED;
cli.default_spi_frequency = SPI_SPEED;

while ((ch = cli.getopt(argc, argv, "R:")) != EOF) {
switch (ch) {
Expand Down Expand Up @@ -108,10 +101,6 @@ extern "C" int mpu6000_main(int argc, char *argv[])
return ThisDriver::module_status(iterator);
}

if (!strcmp(verb, "reset")) {
return ThisDriver::module_custom_method(cli, iterator);
}

ThisDriver::print_usage();
return -1;
}

0 comments on commit 74e99fa

Please sign in to comment.