Skip to content

Commit

Permalink
Additional formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
justinnuwin committed Apr 11, 2021
1 parent 2bb4bf3 commit 91ae8fa
Showing 1 changed file with 47 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ namespace CubeRover {
err = writeMotorControlRegister(REG_P_CURRENT,
FRONT_LEFT_MC_I2C_ADDR,
(uint8_t*) &P_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand All @@ -224,7 +224,7 @@ namespace CubeRover {
err = writeMotorControlRegister(REG_I_CURRENT,
FRONT_LEFT_MC_I2C_ADDR,
(uint8_t*) &I_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand All @@ -237,7 +237,7 @@ namespace CubeRover {
err = writeMotorControlRegister(REG_P_CURRENT,
FRONT_RIGHT_MC_I2C_ADDR,
(uint8_t*) &P_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand All @@ -246,7 +246,7 @@ namespace CubeRover {
err = writeMotorControlRegister(REG_I_CURRENT,
FRONT_LEFT_MC_I2C_ADDR,
(uint8_t*) &I_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand All @@ -259,7 +259,7 @@ namespace CubeRover {
err = writeMotorControlRegister(REG_P_CURRENT,
REAR_RIGHT_MC_I2C_ADDR,
(uint8_t*) &P_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand All @@ -268,7 +268,7 @@ namespace CubeRover {
err = writeMotorControlRegister(REG_I_CURRENT,
REAR_RIGHT_MC_I2C_ADDR,
(uint8_t*) &I_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand All @@ -281,7 +281,7 @@ namespace CubeRover {
err = writeMotorControlRegister(REG_P_CURRENT,
REAR_LEFT_MC_I2C_ADDR,
(uint8_t*) &P_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand All @@ -290,7 +290,7 @@ namespace CubeRover {
err = writeMotorControlRegister(REG_I_CURRENT,
REAR_LEFT_MC_I2C_ADDR,
(uint8_t*) &I_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand All @@ -301,15 +301,15 @@ namespace CubeRover {
// TODO again, need to find out how to pass int8*
err = sendAllMotorsData(REG_P_CURRENT,
(uint8_t*) &P_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
}

err = sendAllMotorsData(REG_I_CURRENT,
(uint8_t*) &I_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand Down Expand Up @@ -353,7 +353,7 @@ namespace CubeRover {
err = writeMotorControlRegister(REG_P_SPEED,
FRONT_LEFT_MC_I2C_ADDR,
(uint8_t*) &P_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand All @@ -362,7 +362,7 @@ namespace CubeRover {
err = writeMotorControlRegister(REG_I_SPEED,
FRONT_LEFT_MC_I2C_ADDR,
(uint8_t*) &I_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand All @@ -375,7 +375,7 @@ namespace CubeRover {
err = writeMotorControlRegister(REG_P_SPEED,
FRONT_RIGHT_MC_I2C_ADDR,
(uint8_t*) &P_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand All @@ -384,7 +384,7 @@ namespace CubeRover {
err = writeMotorControlRegister(REG_I_SPEED,
FRONT_LEFT_MC_I2C_ADDR,
(uint8_t*) &I_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand All @@ -397,7 +397,7 @@ namespace CubeRover {
err = writeMotorControlRegister(REG_P_SPEED,
REAR_RIGHT_MC_I2C_ADDR,
(uint8_t*) &P_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand All @@ -406,7 +406,7 @@ namespace CubeRover {
err = writeMotorControlRegister(REG_I_SPEED,
REAR_RIGHT_MC_I2C_ADDR,
(uint8_t*) &I_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand All @@ -419,7 +419,7 @@ namespace CubeRover {
err = writeMotorControlRegister(REG_P_SPEED,
REAR_LEFT_MC_I2C_ADDR,
(uint8_t*) &P_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand All @@ -428,7 +428,7 @@ namespace CubeRover {
err = writeMotorControlRegister(REG_I_SPEED,
REAR_LEFT_MC_I2C_ADDR,
(uint8_t*) &I_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand All @@ -439,15 +439,15 @@ namespace CubeRover {
// TODO again, need to find out how to pass int8*
err = sendAllMotorsData(REG_P_SPEED,
(uint8_t*) &P_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
}

err = sendAllMotorsData(REG_I_SPEED,
(uint8_t*) &I_Value);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand Down Expand Up @@ -521,9 +521,9 @@ namespace CubeRover {

if (Value == 4)
{
for(int i = 0; i < 4; i++)
for (int i = 0; i < 4; i++)
{
if(Value == 0xFF)
if (Value == 0xFF)
m_stallDetectectionEnabled[i] = true;
else
m_stallDetectectionEnabled[i] = false;
Expand All @@ -532,7 +532,7 @@ namespace CubeRover {

else
{
if(Value == 0xFF)
if (Value == 0xFF)
m_stallDetectectionEnabled[Motor_ID] = true;
else
m_stallDetectectionEnabled[Motor_ID] = false;
Expand Down Expand Up @@ -612,7 +612,7 @@ namespace CubeRover {
// Forward Spin
case 0:
err = moveAllMotorsStraight(MAX_SPIN_DISTANCE, 0);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand All @@ -622,7 +622,7 @@ namespace CubeRover {
// Backwards Spin
case 1:
err = moveAllMotorsStraight(-1*MAX_SPIN_DISTANCE, 0);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand All @@ -632,7 +632,7 @@ namespace CubeRover {
// Stop
case 2:
err = moveAllMotorsStraight(0, 0);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
{
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_EXECUTION_ERROR);
return;
Expand Down Expand Up @@ -706,7 +706,7 @@ namespace CubeRover {
void MotorControlComponentImpl :: MC_UpdateTelemetry_cmdHandler(const FwOpcodeType opCode,
const U32 cmdSeq)
{
if(updateTelemetry())
if (updateTelemetry())
this->cmdResponse_out(opCode,cmdSeq,Fw::COMMAND_OK);

else
Expand Down Expand Up @@ -830,25 +830,25 @@ namespace CubeRover {
err = writeMotorControlRegister(reg,
FRONT_LEFT_MC_I2C_ADDR,
data);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
return err;

err = writeMotorControlRegister(reg,
FRONT_RIGHT_MC_I2C_ADDR,
data);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
return err;

err = writeMotorControlRegister(reg,
REAR_LEFT_MC_I2C_ADDR,
data);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
return err;

err = writeMotorControlRegister(reg,
REAR_RIGHT_MC_I2C_ADDR,
data);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
return err;

return MC_NO_ERROR;
Expand Down Expand Up @@ -877,7 +877,7 @@ namespace CubeRover {
// Required to send this before the setpoint (or else the MC will start spinning before speed was set)
err = sendAllMotorsData(REG_TARGET_SPEED,
(uint8_t*) &motor_speed);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
return err;
}

Expand All @@ -902,19 +902,19 @@ namespace CubeRover {
err = writeMotorControlRegister(REG_RELATIVE_TARGET_POSITION,
FRONT_LEFT_MC_I2C_ADDR,
(uint8_t*) &Left_Wheels_Relative_ticks);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
return err;

err = writeMotorControlRegister(REG_RELATIVE_TARGET_POSITION,
FRONT_RIGHT_MC_I2C_ADDR,
(uint8_t*) &Right_Wheels_Relative_ticks);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
return err;

err = writeMotorControlRegister(REG_RELATIVE_TARGET_POSITION,
REAR_RIGHT_MC_I2C_ADDR,
(uint8_t*) &Right_Wheels_Relative_ticks);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
return err;

err = writeMotorControlRegister(REG_RELATIVE_TARGET_POSITION,
Expand Down Expand Up @@ -947,7 +947,7 @@ namespace CubeRover {
// Send the speed to all the motors
err = sendAllMotorsData(REG_CURRENT_SPEED,
(uint8_t*) &motor_speed);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
return err;
}

Expand All @@ -957,19 +957,19 @@ namespace CubeRover {
err = writeMotorControlRegister(REG_CURRENT_POSITION,
FRONT_LEFT_MC_I2C_ADDR,
(uint8_t*) &Relative_ticks);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
return err;

err = writeMotorControlRegister(REG_CURRENT_POSITION,
FRONT_RIGHT_MC_I2C_ADDR,
(uint8_t*) &Relative_ticks);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
return err;

err = writeMotorControlRegister(REG_CURRENT_POSITION,
REAR_RIGHT_MC_I2C_ADDR,
(uint8_t*) &Relative_ticks);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
return err;

err = writeMotorControlRegister(REG_CURRENT_POSITION,
Expand Down Expand Up @@ -1004,19 +1004,19 @@ namespace CubeRover {
err = writeMotorControlRegister(REG_CURRENT_POSITION,
FRONT_LEFT_MC_I2C_ADDR,
(uint8_t*) &Left_Wheels_Relative_ticks);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
return err;

err = writeMotorControlRegister(REG_CURRENT_POSITION,
FRONT_RIGHT_MC_I2C_ADDR,
(uint8_t*) &Right_Wheels_Relative_ticks);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
return err;

err = writeMotorControlRegister(REG_CURRENT_POSITION,
REAR_RIGHT_MC_I2C_ADDR,
(uint8_t*) &Right_Wheels_Relative_ticks);
if(err != MC_NO_ERROR)
if (err != MC_NO_ERROR)
return err;

err = writeMotorControlRegister(REG_CURRENT_POSITION,
Expand Down Expand Up @@ -1046,15 +1046,15 @@ namespace CubeRover {
uint8_t reg_buffer[1];
reg_buffer[0] = (uint8_t)reg;

if(dataLength <= 0)
if (dataLength <= 0)
return MC_UNEXPECTED_ERROR;

// Inform the MSP of the desired register
i2cMasterTransmit(m_i2c, addr, 1, reg_buffer);
// TODO: If error on above (currently returns void) return

// If we want something, receive
if(expectingReturnMessage(reg))
if (expectingReturnMessage(reg))
i2cMasterReceive(m_i2c, addr, dataLength, data);

// Else, tell the data you have
Expand Down Expand Up @@ -1160,11 +1160,11 @@ namespace CubeRover {
// Update all of them
else
{
if(!updateSpeed())
if (!updateSpeed())
return false;
if(!updateCurrent())
if (!updateCurrent())
return false;
if(updateEncoder())
if (updateEncoder())
return false;
}

Expand Down

0 comments on commit 91ae8fa

Please sign in to comment.