Modified for compatibility with Rev.E. hardware
Fork of AkmSensor by
Diff: ak7401ctrl.cpp
- Revision:
- 11:cef8dc1cf010
- Parent:
- 10:5c69b067d88a
- Child:
- 13:d008249f0359
--- a/ak7401ctrl.cpp Fri Jul 08 22:26:26 2016 +0000 +++ b/ak7401ctrl.cpp Fri Jul 22 22:54:11 2016 +0000 @@ -35,25 +35,27 @@ status = ak7401->setOperationMode(AK7401::AK7401_USER_MODE); if( status != AK7401::SUCCESS ){ - MSG("#AK7401 user mode failed.\n"); + MSG("#AK7401 user mode failed.\r\n"); return AkmSensor::ERROR; } - MSG("#AK7401 user mode succeed.\n"); + MSG("#AK7401 user mode succeed.\r\n"); char data[2] = {0x00,0x07}; // set clockwise rotation status = ak7401->writeEEPROM(0x05,data); // set clockwise if( status != AK7401::SUCCESS ){ - MSG("#AK7401 write EEPROM failed.\n"); + MSG("#AK7401 write EEPROM failed.\r\n"); return AkmSensor::ERROR; } - MSG("#AK7401 write EEPROM succeed.\n"); + MSG("#AK7401 write EEPROM succeed.\r\n"); status = ak7401->setOperationMode(AK7401::AK7401_NORMAL_MODE); if( status != AK7401::SUCCESS ){ - MSG("#AK7401 normal mode failed.\n"); + MSG("#AK7401 normal mode failed.\r\n"); return AkmSensor::ERROR; } - MSG("#AK7401 normal mode succeed.\n"); + MSG("#AK7401 normal mode succeed.\r\n"); + + interval = SENSOR_SAMPLING_RATE; // 10Hz } else{ return AkmSensor::ERROR; @@ -71,7 +73,6 @@ } AkmSensor::Status Ak7401Ctrl::startSensor(){ - interval = 0.1; // 10Hz ticker.attach(this, &Ak7401Ctrl::eventCallback, interval); return AkmSensor::SUCCESS; } @@ -114,33 +115,33 @@ { AK7401::Status st; if( Ak7401Ctrl::stopSensor() != AkmSensor::SUCCESS ){ - MSG("#Error stop sensor\n"); + MSG("#Error stop sensor\r\n"); status = AkmSensor::ERROR; } st = ak7401->setOperationMode(AK7401::AK7401_USER_MODE); if( st != AK7401::SUCCESS ){ - MSG("#Error when set user mode\n"); + MSG("#Error when set user mode\r\n"); status = AkmSensor::ERROR; } char temp[2] = {0x00,0x00}; st = ak7401->writeRegister(0x06,temp); if( st != AK7401::SUCCESS ){ - MSG("#Error temp read: code=%d\n",st); + MSG("#Error temp read: code=%d\r\n",st); status = AkmSensor::ERROR; } st = ak7401->setAngleZero(); // reset ZP data if( st != AK7401::SUCCESS ){ - MSG("#Error setAngleZero: code=%d\n",st); + MSG("#Error setAngleZero: code=%d\r\n",st); status = AkmSensor::ERROR; } st = ak7401->setOperationMode(AK7401::AK7401_NORMAL_MODE); if( st != AK7401::SUCCESS ){ - MSG("#Error when set normal mode\n"); + MSG("#Error when set normal mode\r\n"); status = AkmSensor::ERROR; } if( Ak7401Ctrl::startSensor(interval) != AkmSensor::SUCCESS ){ - MSG("#Error start sensor\n"); + MSG("#Error start sensor\r\n"); status = AkmSensor::ERROR; } if( status == AkmSensor::ERROR ){ @@ -152,7 +153,7 @@ } default: { - MSG("#Error no command.\n"); + MSG("#Error no command.\r\n"); status = AkmSensor::ERROR; break; }