From 70bfb42956ff601b0f68fb5c19f6f52ab22fa1e1 Mon Sep 17 00:00:00 2001 From: Luis Rodrigues Date: Sun, 31 May 2015 21:09:21 +0200 Subject: [PATCH] fixed timming issued in I2C whoami communication --- src/drivers/trone/trone.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/drivers/trone/trone.cpp b/src/drivers/trone/trone.cpp index 82122a3ff7..70455b7d77 100644 --- a/src/drivers/trone/trone.cpp +++ b/src/drivers/trone/trone.cpp @@ -319,10 +319,16 @@ TRONE::probe() uint8_t who_am_i=0; const uint8_t cmd = TRONE_WHO_AM_I_REG; - if (transfer(&cmd, 1, &who_am_i, 1) == OK && who_am_i == TRONE_WHO_AM_I_REG_VAL) { - // it is responding correctly to a WHO_AM_I - return measure(); - } + + // set the I2C bus address + set_address(TRONE_BASEADDR); + + // can't use a single transfer as TROne need a bit of time for internal processing + if (transfer(&cmd, 1, nullptr, 0) == OK) { + if ( transfer(nullptr, 0, &who_am_i, 1) == OK && who_am_i == TRONE_WHO_AM_I_REG_VAL){ + return measure(); + } + } debug("WHO_AM_I byte mismatch 0x%02x should be 0x%02x\n", (unsigned)who_am_i,