Library of routines to drive a MD25 motor control board
Dependents: Nucleo_motors HTU21D_HELLOWORLD Major_dHome pixyMajordhome ... more
Diff: md25.cpp
- Revision:
- 1:8046f460a725
- Parent:
- 0:e7f4a9247af2
diff -r e7f4a9247af2 -r 8046f460a725 md25.cpp --- a/md25.cpp Thu May 19 12:42:06 2011 +0000 +++ b/md25.cpp Fri May 20 21:18:59 2011 +0000 @@ -41,7 +41,7 @@ * Public Methods */ -int32_t MD25::getEncoder1() { +int32_t MD25::getEncoder1(void) { union { char buffer[4]; int32_t data; @@ -56,7 +56,7 @@ return value.data; } -int32_t MD25::getEncoder2() { +int32_t MD25::getEncoder2(void) { union { uint8_t buffer[4]; int32_t data; @@ -71,11 +71,11 @@ return value.data; } -uint32_t MD25::getSoftwareVersion() { +uint32_t MD25::getSoftwareVersion(void) { return readRegisterbyte(MD25_SOFTWAREVER_REG); } -float MD25::getBatteryVolts() { +float MD25::getBatteryVolts(void) { return (float)(readRegisterbyte(MD25_VOLTAGE_REG))/10.0; } @@ -83,23 +83,23 @@ return readRegisterbyte(MD25_ACCELRATE_REG); } -uint8_t MD25::getMotor1Speed() { +uint8_t MD25::getMotor1Speed(void) { return readRegisterbyte(MD25_SPEED1_REG); } -uint8_t MD25::getMotor2Speed() { +uint8_t MD25::getMotor2Speed(void) { return readRegisterbyte(MD25_SPEED2_REG); } -uint8_t MD25::getMotor1Current() { +uint8_t MD25::getMotor1Current(void) { return readRegisterbyte(MD25_CURRENT1_REG); } -uint8_t MD25::getMotor2Current() { +uint8_t MD25::getMotor2Current(void) { return readRegisterbyte(MD25_CURRENT2_REG); } -uint8_t MD25::getMode() { +uint8_t MD25::getMode(void) { return readRegisterbyte(MD25_MODE_REG); } @@ -108,7 +108,7 @@ writeRegisterbyte(MD25_SPEED2_REG, speed_2); } -void MD25::stopMotor1() { +void MD25::stopMotor1(void) { switch (current_mode) { case MODE_0 : case MODE_2 : @@ -121,7 +121,7 @@ } } -void MD25::stopMotor2() { +void MD25::stopMotor2(void) { switch (current_mode) { case MODE_0 : case MODE_2 : @@ -134,13 +134,14 @@ } } -void MD25::stopMotors() { +void MD25::stopMotors(void) { stopMotor1(); stopMotor2(); } void MD25::setMode(uint8_t mode) { writeRegisterbyte(MD25_MODE_REG, mode); + current_mode = mode; } void MD25::setAccelerationRate(uint8_t rate) {