Skip to content

Commit

Permalink
Merge pull request adafruit#117 from adafruit/timingtweaks
Browse files Browse the repository at this point in the history
Timing tweaks for RP2040 & ESP
  • Loading branch information
caternuson authored Nov 14, 2022
2 parents 8a978b3 + df1b9a3 commit 7d6600f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
20 changes: 18 additions & 2 deletions Adafruit_BNO055.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,26 @@ Adafruit_BNO055::Adafruit_BNO055(int32_t sensorID, uint8_t address,
* @return true if process is successful
*/
bool Adafruit_BNO055::begin(adafruit_bno055_opmode_t mode) {
// Start without a detection
i2c_dev->begin(false);

if (!i2c_dev->begin()) {
return false;
#if defined(TARGET_RP2040)
// philhower core seems to work with this speed?
i2c_dev->setSpeed(50000);
#endif

// can take 850 ms to boot!
int timeout = 850; // in ms
while (timeout > 0) {
if (i2c_dev->begin()) {
break;
}
// wasnt detected... we'll retry!
delay(10);
timeout -= 10;
}
if (timeout <= 0)
return false;

/* Make sure we have the right device */
uint8_t id = read8(BNO055_CHIP_ID_ADDR);
Expand Down
3 changes: 3 additions & 0 deletions examples/position/position.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Adafruit_BNO055 bno = Adafruit_BNO055(55, 0x28);
void setup(void)
{
Serial.begin(115200);

while (!Serial) delay(10); // wait for serial port to open!

if (!bno.begin())
{
Serial.print("No BNO055 detected");
Expand Down
5 changes: 4 additions & 1 deletion examples/rawdata/rawdata.ino
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

// Check I2C device address and correct line below (by default address is 0x29 or 0x28)
// id, address
Adafruit_BNO055 bno = Adafruit_BNO055(-1, 0x28);
Adafruit_BNO055 bno = Adafruit_BNO055(-1, 0x28, &Wire);

/**************************************************************************/
/*
Expand All @@ -32,6 +32,9 @@ Adafruit_BNO055 bno = Adafruit_BNO055(-1, 0x28);
void setup(void)
{
Serial.begin(115200);

while (!Serial) delay(10); // wait for serial port to open!

Serial.println("Orientation Sensor Raw Data Test"); Serial.println("");

/* Initialise the sensor */
Expand Down
5 changes: 4 additions & 1 deletion examples/read_all_data/read_all_data.ino
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ uint16_t BNO055_SAMPLERATE_DELAY_MS = 100;

// Check I2C device address and correct line below (by default address is 0x29 or 0x28)
// id, address
Adafruit_BNO055 bno = Adafruit_BNO055(55, 0x28);
Adafruit_BNO055 bno = Adafruit_BNO055(55, 0x28, &Wire);

void setup(void)
{
Serial.begin(115200);

while (!Serial) delay(10); // wait for serial port to open!

Serial.println("Orientation Sensor Test"); Serial.println("");

/* Initialise the sensor */
Expand Down
3 changes: 2 additions & 1 deletion examples/sensorapi/sensorapi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

// Check I2C device address and correct line below (by default address is 0x29 or 0x28)
// id, address
Adafruit_BNO055 bno = Adafruit_BNO055(55, 0x28);
Adafruit_BNO055 bno = Adafruit_BNO055(55, 0x28, &Wire);

/**************************************************************************/
/*
Expand Down Expand Up @@ -121,6 +121,7 @@ void displayCalStatus(void)
void setup(void)
{
Serial.begin(115200);

while (!Serial) delay(10); // wait for serial port to open!

Serial.println("Orientation Sensor Test"); Serial.println("");
Expand Down

0 comments on commit 7d6600f

Please sign in to comment.