Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
KomaGR authored Jul 30, 2024
1 parent b4c82d3 commit 20e5068
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 53 deletions.
4 changes: 2 additions & 2 deletions src/boot/ksdk1.1.0/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -3976,7 +3976,7 @@ repeatRegisterReadForDeviceAndAddress(WarpSensorDevice warpSensorDevice, uint8_t

break;
}
case kWarpSensorBNO055:
case kWarpSensorBNO055:
{
/*
* BNO055: VDD 1.95--3.6
Expand Down Expand Up @@ -4004,7 +4004,7 @@ case kWarpSensorBNO055:

break;
}
case kWarpSensorRF430CL331H:
case kWarpSensorRF430CL331H:
{
/*
* BNO055: VDD 1.95--3.6
Expand Down
2 changes: 1 addition & 1 deletion src/boot/ksdk1.1.0/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,5 @@ typedef enum
kWarpDefaultSupplyVoltageMillivoltsAT45DB = 1800,
kWarpDefaultSupplyVoltageMillivoltsICE40 = 1800,
kWarpDefaultSupplyVoltageMillivoltsBNO055 = 2500,
kWarpDefaultSupplyVoltageMillivoltsRF430CL331H = 2500,
kWarpDefaultSupplyVoltageMillivoltsRF430CL331H = 2500,
} WarpDefaults;
1 change: 1 addition & 0 deletions src/boot/ksdk1.1.0/devBME680.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ appendSensorDataBME680(uint8_t* buf)
*/
return index;
}

WarpStatus
StateBME680()
{
Expand Down
101 changes: 53 additions & 48 deletions src/boot/ksdk1.1.0/devBNO055.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ readSensorRegisterBNO055(uint8_t deviceRegister, int numberOfBytes)

void
printSensorDataBNO055(bool hexModeFlag) {
int16_t readSensorRegisterValueLSB;
int16_t readSensorRegisterValueLSB;
int16_t readSensorRegisterValueMSB;
int16_t readSensorRegisterValueCombined;
WarpStatus i2cReadStatus;
Expand All @@ -139,7 +139,7 @@ printSensorDataBNO055(bool hexModeFlag) {
accY = (int16_t)((deviceBNO055State.i2cBuffer[3] << 8) | deviceBNO055State.i2cBuffer[2]);
accZ = (int16_t)((deviceBNO055State.i2cBuffer[5] << 8) | deviceBNO055State.i2cBuffer[4]);

if (i2cReadStatus != kWarpStatusOK)
if (i2cReadStatus != kWarpStatusOK)
{
warpPrint(" ----,");
}
Expand All @@ -155,13 +155,13 @@ printSensorDataBNO055(bool hexModeFlag) {
}
}

i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Mag_Data_X_LSB, 6);
i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Mag_Data_X_LSB, 6);

magX = (int16_t)((deviceBNO055State.i2cBuffer[1] << 8) | deviceBNO055State.i2cBuffer[0]);
magY = (int16_t)((deviceBNO055State.i2cBuffer[3] << 8) | deviceBNO055State.i2cBuffer[2]);
magZ = (int16_t)((deviceBNO055State.i2cBuffer[5] << 8) | deviceBNO055State.i2cBuffer[4]);
magX = (int16_t)((deviceBNO055State.i2cBuffer[1] << 8) | deviceBNO055State.i2cBuffer[0]);
magY = (int16_t)((deviceBNO055State.i2cBuffer[3] << 8) | deviceBNO055State.i2cBuffer[2]);
magZ = (int16_t)((deviceBNO055State.i2cBuffer[5] << 8) | deviceBNO055State.i2cBuffer[4]);

if (i2cReadStatus != kWarpStatusOK)
if (i2cReadStatus != kWarpStatusOK)
{
warpPrint(" ----,");
}
Expand All @@ -177,14 +177,14 @@ printSensorDataBNO055(bool hexModeFlag) {
}
}

warpScaleSupplyVoltage(deviceBNO055State.operatingVoltageMillivolts);
warpScaleSupplyVoltage(deviceBNO055State.operatingVoltageMillivolts);
i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Gyro_Data_X_LSB, 6);

gyrX = (int16_t)((deviceBNO055State.i2cBuffer[1] << 8) | deviceBNO055State.i2cBuffer[0]);
gyrY = (int16_t)((deviceBNO055State.i2cBuffer[3] << 8) | deviceBNO055State.i2cBuffer[2]);
gyrZ = (int16_t)((deviceBNO055State.i2cBuffer[5] << 8) | deviceBNO055State.i2cBuffer[4]);
gyrX = (int16_t)((deviceBNO055State.i2cBuffer[1] << 8) | deviceBNO055State.i2cBuffer[0]);
gyrY = (int16_t)((deviceBNO055State.i2cBuffer[3] << 8) | deviceBNO055State.i2cBuffer[2]);
gyrZ = (int16_t)((deviceBNO055State.i2cBuffer[5] << 8) | deviceBNO055State.i2cBuffer[4]);

if (i2cReadStatus != kWarpStatusOK)
if (i2cReadStatus != kWarpStatusOK)
{
warpPrint(" ----,");
}
Expand Down Expand Up @@ -230,9 +230,9 @@ appendSensorDataBNO055(uint8_t* buf)
*/

i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Accel_Data_X_LSB, 2);
readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0];
readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1];
readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB;
readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0];
readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1];
readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB;


if ((i2cReadStatus != kWarpStatusOK))
Expand All @@ -254,11 +254,11 @@ appendSensorDataBNO055(uint8_t* buf)
}

i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Accel_Data_Y_LSB, 2);
readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0];
readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1];
readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB;
readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0];
readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1];
readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB;

if ((i2cReadStatus != kWarpStatusOK))
if ((i2cReadStatus != kWarpStatusOK))
{
buf[index] = 0;
index += 1;
Expand All @@ -276,12 +276,12 @@ appendSensorDataBNO055(uint8_t* buf)

}

i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Accel_Data_Z_LSB, 2);
readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0];
readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1];
readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB;
i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Accel_Data_Z_LSB, 2);
readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0];
readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1];
readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB;

if ((i2cReadStatus != kWarpStatusOK))
if ((i2cReadStatus != kWarpStatusOK))
{
buf[index] = 0;
index += 1;
Expand All @@ -300,11 +300,11 @@ appendSensorDataBNO055(uint8_t* buf)
}

i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Mag_Data_X_LSB, 2);
readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0];
readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1];
readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB;
readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0];
readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1];
readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB;

if ((i2cReadStatus != kWarpStatusOK))
if ((i2cReadStatus != kWarpStatusOK))
{
buf[index] = 0;
index += 1;
Expand All @@ -321,12 +321,13 @@ appendSensorDataBNO055(uint8_t* buf)
index += 1;

}

i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Mag_Data_Y_LSB, 2);
readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0];
readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1];
readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB;
readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0];
readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1];
readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB;

if ((i2cReadStatus != kWarpStatusOK))
if ((i2cReadStatus != kWarpStatusOK))
{
buf[index] = 0;
index += 1;
Expand All @@ -343,12 +344,13 @@ appendSensorDataBNO055(uint8_t* buf)
index += 1;

}

i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Mag_Data_Z_LSB, 2);
readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0];
readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1];
readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB;
readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0];
readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1];
readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB;

if ((i2cReadStatus != kWarpStatusOK))
if ((i2cReadStatus != kWarpStatusOK))
{
buf[index] = 0;
index += 1;
Expand All @@ -365,12 +367,13 @@ appendSensorDataBNO055(uint8_t* buf)
index += 1;

}

i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Gyro_Data_X_LSB, 2);
readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0];
readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1];
readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB;
readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0];
readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1];
readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB;

if ((i2cReadStatus != kWarpStatusOK))
if ((i2cReadStatus != kWarpStatusOK))
{
buf[index] = 0;
index += 1;
Expand All @@ -387,12 +390,13 @@ appendSensorDataBNO055(uint8_t* buf)
index += 1;

}

i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Gyro_Data_Y_LSB, 2);
readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0];
readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1];
readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB;
readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0];
readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1];
readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB;

if ((i2cReadStatus != kWarpStatusOK))
if ((i2cReadStatus != kWarpStatusOK))
{
buf[index] = 0;
index += 1;
Expand All @@ -410,12 +414,13 @@ appendSensorDataBNO055(uint8_t* buf)
index += 1;

}

i2cReadStatus = readSensorRegisterBNO055(kWarpSensourOutputRegisterBNO055Gyro_Data_Z_LSB, 2);
readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0];
readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1];
readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB;
readSensorRegisterValueLSB = deviceBNO055State.i2cBuffer[0];
readSensorRegisterValueMSB = deviceBNO055State.i2cBuffer[1];
readSensorRegisterValueCombined = (readSensorRegisterValueMSB << 8) | readSensorRegisterValueLSB;

if ((i2cReadStatus != kWarpStatusOK))
if ((i2cReadStatus != kWarpStatusOK))
{
buf[index] = 0;
index += 1;
Expand Down
4 changes: 2 additions & 2 deletions src/boot/ksdk1.1.0/devBNO055.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
void initBNO055(const uint8_t i2cAddress, uint16_t operatingVoltageMillivolts);
WarpStatus readSensorRegisterBNO055(uint8_t deviceRegister, int numberOfBytes);
WarpStatus writeSensorRegisterBNO055(uint8_t deviceRegister, uint8_t payload);
WarpStatus configureSensorRegisterBNO055(uint8_t payloadOP_Mode, uint8_t payloadPWR_Mode);
WarpStatus configureSensorRegisterBNO055(uint8_t payloadOP_Mode, uint8_t payloadPWR_Mode);
void printSensorDataBNO055(bool hexModeFlag);
WarpStatus StateBNO055();
WarpStatus StateBNO055();
uint8_t appendSensorDataBNO055(uint8_t* buf);


0 comments on commit 20e5068

Please sign in to comment.