Modified for compatibility with Rev.E. hardware
Fork of AkmSensor by
Diff: ak7451ctrl.cpp
- Revision:
- 39:3821886c902e
- Parent:
- 34:1ea3357c8d9a
- Child:
- 43:45225713cd58
--- a/ak7451ctrl.cpp Thu Jun 08 19:09:18 2017 +0000 +++ b/ak7451ctrl.cpp Tue Jul 18 23:20:26 2017 +0000 @@ -40,7 +40,7 @@ // Set to User Mode status = ak7451->setOperationMode(AK7451::AK7451_USER_MODE); if( status != AK7451::SUCCESS ){ - MSG("#AK7451 user mode failed.\r\n"); + MSG("#Error: AK7451 user mode failed.\r\n"); return AkmSensor::ERROR; } MSG("#AK7451 user mode succeed.\r\n"); @@ -54,10 +54,10 @@ status = ak7451->writeEEPROM(0x07,data); // set clockwise if( status != AK7451::SUCCESS ){ - MSG("#AK7451 write EEPROM failed.\r\n"); + MSG("#Error: AK7451 write EEPROM failed.\r\n"); return AkmSensor::ERROR; } - MSG("#AK7451 write EEPROM succeed.\r\n"); + MSG("#Error: AK7451 write EEPROM succeed.\r\n"); /* // Set to Normal Mode @@ -80,7 +80,7 @@ AkmSensor::Status Ak7451Ctrl::startSensor(){ AK7451::Status status = ak7451->setOperationMode(AK7451::AK7451_NORMAL_MODE); if( status != AK7451::SUCCESS ){ - MSG("#AK7451 normal mode failed.\r\n"); + MSG("#Error: AK7451 normal mode failed.\r\n"); return AkmSensor::ERROR; } ticker.attach(callback(this, &AkmSensor::setEvent), interval); @@ -90,7 +90,7 @@ AkmSensor::Status Ak7451Ctrl::startSensor(const float sec){ AK7451::Status status = ak7451->setOperationMode(AK7451::AK7451_NORMAL_MODE); if( status != AK7451::SUCCESS ){ - MSG("#AK7451 normal mode failed.\r\n"); + MSG("#Error: AK7451 normal mode failed.\r\n"); return AkmSensor::ERROR; } @@ -104,7 +104,7 @@ AK7451::Status status; status = ak7451->setOperationMode(AK7451::AK7451_USER_MODE); if( status != AK7451::SUCCESS ){ - MSG("#AK7451 user mode failed.\r\n"); + MSG("#Error: AK7451 user mode failed.\r\n"); return AkmSensor::ERROR; } ticker.detach(); @@ -143,7 +143,7 @@ char abnormal = 0x00; if( ak7451->readAngleMeasureCommand(angle, &density, &abnormal) != AK7451::SUCCESS ){ - MSG("#Error read angle\r\n"); + MSG("#Error: read angle\r\n"); status = AkmSensor::ERROR; } out->setCommand(Message::CMD_ANGLE_READ); @@ -166,20 +166,20 @@ mode = AK7451::AK7451_NORMAL_MODE; st = ak7451->setOperationMode(AK7451::AK7451_USER_MODE); if( st != AK7451::SUCCESS ){ - MSG("#Error when set user mode\r\n"); + MSG("#Error: when set user mode\r\n"); status = AkmSensor::ERROR; } } */ st = ak7451->setAngleZero(); // reset ZP data if( st != AK7451::SUCCESS ){ - MSG("#Error setAngleZero: code=%d\r\n",st); + MSG("#Error: setAngleZero: code=%d\r\n",st); status = AkmSensor::ERROR; } /* st = ak7451->setOperationMode(mode); if( st != AK7451::SUCCESS ){ - MSG("#Error when set mode:%d\r\n",mode); + MSG("#Error: when set mode:%d\r\n",mode); status = AkmSensor::ERROR; } */ @@ -196,12 +196,12 @@ char address = in->getArgument(0); int len = in->getArgument(1); if(len != 2){ - MSG("#Error length=%d. Only support 2byte length\r\n",len); + MSG("#Error: length=%d. Only support 2byte length\r\n",len); status = AkmSensor::ERROR; return status; } if(in->getArgNum() != len+2){ - MSG("#Error argument num. Args=%d\r\n",in->getArgNum()); + MSG("#Error: argument num. Args=%d\r\n",in->getArgNum()); status = AkmSensor::ERROR; out->setArgument(0,(char)status); return status; @@ -213,11 +213,11 @@ } if( ak7451->writeRegister(address, data) != AK7451::SUCCESS) { status = AkmSensor::ERROR; - MSG("#Error register write.\r\n"); + MSG("#Error: register write.\r\n"); } if( ak7451->writeEEPROM(address, data) != AK7451::SUCCESS) { status = AkmSensor::ERROR; - MSG("#Error EEPROM write.\r\n"); + MSG("#Error: EEPROM write.\r\n"); } out->setArgument(0,(char)status); break; @@ -226,7 +226,7 @@ case Message::CMD_REG_READN: { if(in->getArgNum() != 2){ - MSG("#Error argument num. Args=%d\r\n",in->getArgNum()); + MSG("#Error: argument num. Args=%d\r\n",in->getArgNum()); status = AkmSensor::ERROR; return status; } @@ -234,14 +234,14 @@ char address = in->getArgument(0); int len = in->getArgument(1); if(len != 2){ - MSG("#Error length=%d. Only support 2byte length\r\n",len); + MSG("#Error: length=%d. Only support 2byte length\r\n",len); status = AkmSensor::ERROR; return status; } char data[len]; if( ak7451->readRegister(address, data) != AK7451::SUCCESS) { status = AkmSensor::ERROR; - MSG("#Error register read.\r\n"); + MSG("#Error: register read.\r\n"); } for(int i=0; i<len; i++){ out->setArgument(i, data[i]); @@ -250,7 +250,7 @@ } default: { - MSG("#Error no command.\r\n"); + MSG("#Error: no command.\r\n"); status = AkmSensor::ERROR; break; }