@@ -945,10 +945,10 @@ void BNO080::softReset(void)
945
945
// Read all incoming data and flush it
946
946
delay (50 );
947
947
while (receivePacket () == true )
948
- ;
948
+ ; // delay(1);
949
949
delay (50 );
950
950
while (receivePacket () == true )
951
- ;
951
+ ; // delay(1);
952
952
}
953
953
954
954
// Get the reason for the last reset
@@ -1328,7 +1328,7 @@ boolean BNO080::receivePacket(void)
1328
1328
shtpHeader[3 ] = sequenceNumber;
1329
1329
1330
1330
// Calculate the number of data bytes in this packet
1331
- uint16_t dataLength = ((uint16_t )packetMSB << 8 | packetLSB);
1331
+ uint16_t dataLength = ((( uint16_t )packetMSB) << 8 ) | (( uint16_t ) packetLSB);
1332
1332
dataLength &= ~(1 << 15 ); // Clear the MSbit.
1333
1333
// This bit indicates if this package is a continuation of the last. Ignore it for now.
1334
1334
// TODO catch this as an error and exit
@@ -1355,7 +1355,7 @@ boolean BNO080::receivePacket(void)
1355
1355
}
1356
1356
else // Do I2C
1357
1357
{
1358
- _i2cPort->requestFrom ((uint8_t )_deviceAddress, (uint8_t )4 ); // Ask for four bytes to find out how much data we need to read
1358
+ _i2cPort->requestFrom ((uint8_t )_deviceAddress, (size_t )4 ); // Ask for four bytes to find out how much data we need to read
1359
1359
if (waitForI2C () == false )
1360
1360
return (false ); // Error
1361
1361
@@ -1372,10 +1372,17 @@ boolean BNO080::receivePacket(void)
1372
1372
shtpHeader[3 ] = sequenceNumber;
1373
1373
1374
1374
// Calculate the number of data bytes in this packet
1375
- int16_t dataLength = ((uint16_t )packetMSB << 8 | packetLSB);
1375
+ uint16_t dataLength = ((( uint16_t )packetMSB) << 8 ) | (( uint16_t ) packetLSB);
1376
1376
dataLength &= ~(1 << 15 ); // Clear the MSbit.
1377
1377
// This bit indicates if this package is a continuation of the last. Ignore it for now.
1378
1378
// TODO catch this as an error and exit
1379
+
1380
+ // if (_printDebug == true)
1381
+ // {
1382
+ // _debugPort->print(F("receivePacket (I2C): dataLength is: "));
1383
+ // _debugPort->println(dataLength);
1384
+ // }
1385
+
1379
1386
if (dataLength == 0 )
1380
1387
{
1381
1388
// Packet is empty
@@ -1403,7 +1410,7 @@ boolean BNO080::getData(uint16_t bytesRemaining)
1403
1410
if (numberOfBytesToRead > (I2C_BUFFER_LENGTH - 4 ))
1404
1411
numberOfBytesToRead = (I2C_BUFFER_LENGTH - 4 );
1405
1412
1406
- _i2cPort->requestFrom ((uint8_t )_deviceAddress, (uint8_t )(numberOfBytesToRead + 4 ));
1413
+ _i2cPort->requestFrom ((uint8_t )_deviceAddress, (size_t )(numberOfBytesToRead + 4 ));
1407
1414
if (waitForI2C () == false )
1408
1415
return (0 ); // Error
1409
1416
@@ -1481,8 +1488,16 @@ boolean BNO080::sendPacket(uint8_t channelNumber, uint8_t dataLength)
1481
1488
{
1482
1489
_i2cPort->write (shtpData[i]);
1483
1490
}
1484
- if (_i2cPort->endTransmission () != 0 )
1491
+
1492
+ uint8_t i2cResult = _i2cPort->endTransmission ();
1493
+
1494
+ if (i2cResult != 0 )
1485
1495
{
1496
+ if (_printDebug == true )
1497
+ {
1498
+ _debugPort->print (F (" sendPacket(I2C): endTransmission returned: " ));
1499
+ _debugPort->println (i2cResult);
1500
+ }
1486
1501
return (false );
1487
1502
}
1488
1503
}
0 commit comments