Modified for compatibility with Rev.E. hardware
Fork of AkmSensor by
Diff: akmakd.cpp
- Revision:
- 18:b7182d5ad8d5
- Parent:
- 16:d85be9bafb80
- Child:
- 19:8dcc4f323bdc
--- a/akmakd.cpp Wed Jan 18 21:40:53 2017 +0000 +++ b/akmakd.cpp Tue Feb 21 23:46:12 2017 +0000 @@ -88,6 +88,12 @@ compass = ak099xx; AkmAkd::sensorName = "AK09916D"; break; + case AkmAkd::SUB_ID_AK09918: + type = AkmECompass::AK09918; + ak099xx = new AK099XX(); + compass = ak099xx; + AkmAkd::sensorName = "AK09918"; + break; default: return AkmSensor::ERROR; // break; @@ -116,8 +122,8 @@ } // read a data to reset DRDY - AkmECompass::MagneticVector mag; - compass->getMagneticVector(&mag); +// AkmECompass::MagneticVector mag; +// compass->getMagneticVector(&mag); }else if(primaryId == AKM_PRIMARY_ID_AKD_SPI){ @@ -156,6 +162,8 @@ break; case AkmAkd::SUB_ID_AK09915D: type = AkmECompass::AK09915; + ak099xx = new AK099XX(); + compass = ak099xx; AkmAkd::sensorName = "AK09915D"; break; case AkmAkd::SUB_ID_AK09916C: @@ -168,6 +176,11 @@ AkmAkd::sensorName = "AK09916D"; // doesn't support SPI return AkmSensor::ERROR; + case AkmAkd::SUB_ID_AK09918: + type = AkmECompass::AK09918; + AkmAkd::sensorName = "AK09918"; + // doesn't support SPI + return AkmSensor::ERROR; default: return AkmSensor::ERROR; // break; @@ -183,8 +196,8 @@ return AkmSensor::ERROR; } // read a data to reset DRDY - AkmECompass::MagneticVector mag; - compass->getMagneticVector(&mag); +// AkmECompass::MagneticVector mag; +// compass->getMagneticVector(&mag); } MSG("#%s detected.\r\n", AkmAkd::sensorName); @@ -316,11 +329,31 @@ switch(cmd){ case Message::CMD_COMPASS_GET_OPERATION_MODE: { - if(compass->getOperationMode(&mode) != AkmECompass::SUCCESS) { - status = AkmSensor::ERROR; - MSG("#Error set operation mode.\r\n"); + if(subId == AkmAkd::SUB_ID_AK09915C || subId == AkmAkd::SUB_ID_AK09915D){ + if(compass->getOperationMode(&mode, &nsf, &sdr) != AkmECompass::SUCCESS) { + status = AkmSensor::ERROR; + MSG("#Error set operation mode.\r\n"); + }else{ + out->setArgument(0,mode); + out->setArgument(1,nsf); + out->setArgument(2,sdr); + } + + }else if(subId == AkmAkd::SUB_ID_AK09912C){ + if(compass->getOperationMode(&mode, &nsf) != AkmECompass::SUCCESS) { + status = AkmSensor::ERROR; + MSG("#Error set operation mode.\r\n"); + }else{ + out->setArgument(0,mode); + out->setArgument(1,nsf); + } }else{ - out->setArgument(0,mode); + if(compass->getOperationMode(&mode) != AkmECompass::SUCCESS) { + status = AkmSensor::ERROR; + MSG("#Error set operation mode.\r\n"); + }else{ + out->setArgument(0,mode); + } } break; }