Modified for compatibility with Rev.E. hardware
Fork of AkmSensor by
Diff: akmakd.cpp
- Revision:
- 38:e865dadfe54d
- Parent:
- 29:b488d2c89fba
- Child:
- 39:3821886c902e
diff -r c76d2edf3426 -r e865dadfe54d akmakd.cpp --- a/akmakd.cpp Wed May 24 20:23:22 2017 +0000 +++ b/akmakd.cpp Thu Jun 08 19:09:18 2017 +0000 @@ -84,6 +84,14 @@ ak099xx = new AK099XX(); compass = ak099xx; break; + case AkmAkd::SUB_ID_AK09917: + *devid = AkmECompass::AK09917; + AkmAkd::sensorName = "AK09917"; + if(primaryId == AKM_PRIMARY_ID_AKD_SPI) + return AkmSensor::ERROR; // No SPI support + ak099xx = new AK099XX(); + compass = ak099xx; + break; default: return AkmSensor::ERROR; } @@ -170,7 +178,8 @@ } else if( primaryId == AKM_PRIMARY_ID_AKD_I2C && (subId == AkmAkd::SUB_ID_AK09915D || - subId == AkmAkd::SUB_ID_AK09916D ) ){ + subId == AkmAkd::SUB_ID_AK09916D || + subId == AkmAkd::SUB_ID_AK09917 ) ){ ret = AkmAkd::INTERRUPT_ENABLED_OD; } else{ @@ -201,7 +210,9 @@ } // set operation mode - if( subId == AkmAkd::SUB_ID_AK09915C || subId == AkmAkd::SUB_ID_AK09915D ){ + if( subId == AkmAkd::SUB_ID_AK09915C || + subId == AkmAkd::SUB_ID_AK09915D || + subId == AkmAkd::SUB_ID_AK09917 ){ if(compass->setOperationMode(mode,nsf,sdr) != AkmECompass::SUCCESS) { MSG("#Start sensor failed %s\r\n", sensorName); return AkmSensor::ERROR; @@ -246,7 +257,9 @@ } // Puts the device into power down mode. - if( subId == AkmAkd::SUB_ID_AK09915C || subId == AkmAkd::SUB_ID_AK09915D ){ + if( subId == AkmAkd::SUB_ID_AK09915C || + subId == AkmAkd::SUB_ID_AK09915D || + subId == AkmAkd::SUB_ID_AK09917 ){ if(compass->setOperationMode(AkmECompass::MODE_POWER_DOWN,nsf,sdr) != AkmECompass::SUCCESS) { return AkmSensor::ERROR; } @@ -290,7 +303,9 @@ switch(cmd){ case Message::CMD_COMPASS_GET_OPERATION_MODE: { - if(subId == AkmAkd::SUB_ID_AK09915C || subId == AkmAkd::SUB_ID_AK09915D){ + if( subId == AkmAkd::SUB_ID_AK09915C || + subId == AkmAkd::SUB_ID_AK09915D || + subId == AkmAkd::SUB_ID_AK09917 ){ if(compass->getOperationMode(&mode, &nsf, &sdr) != AkmECompass::SUCCESS) { status = AkmSensor::ERROR; MSG("#Error set operation mode.\r\n"); @@ -321,7 +336,10 @@ case Message::CMD_COMPASS_SET_OPERATION_MODE: { mode = (AkmECompass::OperationMode)in->getArgument(0); - if(subId == AkmAkd::SUB_ID_AK09915C || subId == AkmAkd::SUB_ID_AK09915D){ + if( subId == AkmAkd::SUB_ID_AK09915C || + subId == AkmAkd::SUB_ID_AK09915D || + subId == AkmAkd::SUB_ID_AK09917 ){ + nsf = (AkmECompass::Nsf)in->getArgument(1); sdr = (AkmECompass::Sdr)in->getArgument(2); if(compass->setOperationMode(mode,nsf,sdr) != AkmECompass::SUCCESS) {