mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
lsm9ds1_mag: cleanup + consistency with other drivers
This commit is contained in:
@@ -68,20 +68,22 @@ int LSM9DS1_MAG::probe()
|
|||||||
return PX4_ERROR;
|
return PX4_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LSM9DS1_MAG::Init()
|
int LSM9DS1_MAG::init()
|
||||||
{
|
{
|
||||||
if (SPI::init() != PX4_OK) {
|
int ret = SPI::init();
|
||||||
return false;
|
|
||||||
|
if (ret != PX4_OK) {
|
||||||
|
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_MAG::Reset()
|
bool LSM9DS1_MAG::Reset()
|
||||||
@@ -147,16 +149,9 @@ void LSM9DS1_MAG::RegisterClearBits(Register reg, uint8_t clearbits)
|
|||||||
|
|
||||||
void LSM9DS1_MAG::Start()
|
void LSM9DS1_MAG::Start()
|
||||||
{
|
{
|
||||||
Stop();
|
|
||||||
|
|
||||||
ScheduleOnInterval(1000000 / ST_LSM9DS1_MAG::M_ODR / 2);
|
ScheduleOnInterval(1000000 / ST_LSM9DS1_MAG::M_ODR / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LSM9DS1_MAG::Stop()
|
|
||||||
{
|
|
||||||
ScheduleClear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LSM9DS1_MAG::RunImpl()
|
void LSM9DS1_MAG::RunImpl()
|
||||||
{
|
{
|
||||||
perf_count(_interval_perf);
|
perf_count(_interval_perf);
|
||||||
|
|||||||
@@ -63,9 +63,9 @@ public:
|
|||||||
|
|
||||||
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();
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ I2CSPIDriverBase *LSM9DS1_MAG::instantiate(const BusCLIArguments &cli, const Bus
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!instance->Init()) {
|
if (OK != instance->init()) {
|
||||||
delete instance;
|
delete instance;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user