mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 07:53:34 +08:00
mpu9250:reset the mag on the reset operation
This commit fixed a bug were the mag was orphened on a reset. That resulted in MAG timeouts on reset or test operations and left the mag in a broken state.
This commit is contained in:
committed by
Lorenz Meier
parent
8bd044e80e
commit
fbf6532c25
@@ -297,11 +297,7 @@ MPU9250_mag::ioctl(struct file *filp, int cmd, unsigned long arg)
|
|||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
|
|
||||||
case SENSORIOCRESET:
|
case SENSORIOCRESET:
|
||||||
/*
|
return ak8963_reset();
|
||||||
* TODO: we could implement a reset of the AK8963 registers
|
|
||||||
*/
|
|
||||||
//return reset();
|
|
||||||
return _parent->ioctl(filp, cmd, arg);
|
|
||||||
|
|
||||||
case SENSORIOCSPOLLRATE: {
|
case SENSORIOCSPOLLRATE: {
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
@@ -508,10 +504,23 @@ MPU9250_mag::write_reg(unsigned reg, uint8_t value)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
int
|
||||||
MPU9250_mag::ak8963_reset(void)
|
MPU9250_mag::ak8963_reset(void)
|
||||||
{
|
{
|
||||||
write_reg(AK8963REG_CNTL2, AK8963_RESET);
|
// First initialize it to use the bus
|
||||||
|
|
||||||
|
int rv = ak8963_setup();
|
||||||
|
|
||||||
|
if (rv == OK) {
|
||||||
|
|
||||||
|
// Now reset the mag
|
||||||
|
write_reg(AK8963REG_CNTL2, AK8963_RESET);
|
||||||
|
// Then re-initialize the bus/mag
|
||||||
|
rv = ak8963_setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|||||||
@@ -720,8 +720,15 @@ MPU9250::ioctl(struct file *filp, int cmd, unsigned long arg)
|
|||||||
{
|
{
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
|
|
||||||
case SENSORIOCRESET:
|
case SENSORIOCRESET: {
|
||||||
return reset();
|
int ret = reset();
|
||||||
|
|
||||||
|
if (_whoami == MPU_WHOAMI_9250) {
|
||||||
|
return (ret == OK ? _mag->ioctl(filp, cmd, arg) : ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
case SENSORIOCSPOLLRATE: {
|
case SENSORIOCSPOLLRATE: {
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
|
|||||||
Reference in New Issue
Block a user