lsm9ds1: cleanup + consistency with other drivers

This commit is contained in:
Beat Küng
2020-03-18 17:26:37 +01:00
committed by Daniel Agar
parent 00280d55c2
commit 2d6a9ae1fb
3 changed files with 11 additions and 15 deletions
+8 -12
View File
@@ -73,20 +73,23 @@ int LSM9DS1::probe()
return PX4_ERROR; return PX4_ERROR;
} }
bool LSM9DS1::Init() int LSM9DS1::init()
{ {
if (SPI::init() != PX4_OK) { int ret = SPI::init();
return false;
if (ret != OK) {
DEVICE_DEBUG("SPI init failed (%i)", ret);
return ret;
} }
if (!Reset()) { if (!Reset()) {
PX4_ERR("reset failed"); PX4_ERR("reset failed");
return false; return PX4_ERROR;
} }
Start(); Start();
return true; return PX4_OK;
} }
bool LSM9DS1::Reset() bool LSM9DS1::Reset()
@@ -172,18 +175,11 @@ void LSM9DS1::RegisterClearBits(Register reg, uint8_t clearbits)
void LSM9DS1::Start() void LSM9DS1::Start()
{ {
Stop();
ResetFIFO(); ResetFIFO();
ScheduleOnInterval(_fifo_interval / 2, _fifo_interval); ScheduleOnInterval(_fifo_interval / 2, _fifo_interval);
} }
void LSM9DS1::Stop()
{
ScheduleClear();
}
void LSM9DS1::RunImpl() void LSM9DS1::RunImpl()
{ {
perf_count(_interval_perf); perf_count(_interval_perf);
+2 -2
View File
@@ -66,9 +66,9 @@ public:
static void print_usage(); static void print_usage();
void print_status(); void print_status();
bool Init(); int init() override;
void Start(); void Start();
void Stop();
bool Reset(); bool Reset();
void RunImpl(); void RunImpl();
+1 -1
View File
@@ -47,7 +47,7 @@ I2CSPIDriverBase *LSM9DS1::instantiate(const BusCLIArguments &cli, const BusInst
return nullptr; return nullptr;
} }
if (!instance->Init()) { if (OK != instance->init()) {
delete instance; delete instance;
return nullptr; return nullptr;
} }