mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
lsm9ds1_mag: cleanup + consistency with other drivers
This commit is contained in:
parent
74db018012
commit
2fa289bbad
@ -68,20 +68,22 @@ int LSM9DS1_MAG::probe()
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
bool LSM9DS1_MAG::Init()
|
||||
int LSM9DS1_MAG::init()
|
||||
{
|
||||
if (SPI::init() != PX4_OK) {
|
||||
return false;
|
||||
int ret = SPI::init();
|
||||
|
||||
if (ret != PX4_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!Reset()) {
|
||||
PX4_ERR("reset failed");
|
||||
return false;
|
||||
return PX4_ERROR;
|
||||
}
|
||||
|
||||
Start();
|
||||
|
||||
return true;
|
||||
return PX4_OK;
|
||||
}
|
||||
|
||||
bool LSM9DS1_MAG::Reset()
|
||||
@ -147,16 +149,9 @@ void LSM9DS1_MAG::RegisterClearBits(Register reg, uint8_t clearbits)
|
||||
|
||||
void LSM9DS1_MAG::Start()
|
||||
{
|
||||
Stop();
|
||||
|
||||
ScheduleOnInterval(1000000 / ST_LSM9DS1_MAG::M_ODR / 2);
|
||||
}
|
||||
|
||||
void LSM9DS1_MAG::Stop()
|
||||
{
|
||||
ScheduleClear();
|
||||
}
|
||||
|
||||
void LSM9DS1_MAG::RunImpl()
|
||||
{
|
||||
perf_count(_interval_perf);
|
||||
|
||||
@ -63,9 +63,9 @@ public:
|
||||
|
||||
void print_status();
|
||||
|
||||
bool Init();
|
||||
int init() override;
|
||||
|
||||
void Start();
|
||||
void Stop();
|
||||
bool Reset();
|
||||
|
||||
void RunImpl();
|
||||
|
||||
@ -58,7 +58,7 @@ I2CSPIDriverBase *LSM9DS1_MAG::instantiate(const BusCLIArguments &cli, const Bus
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!instance->Init()) {
|
||||
if (OK != instance->init()) {
|
||||
delete instance;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user