Browse Source

trone: added support for WHOAMI register

sbg
parallels 10 years ago committed by Lorenz Meier
parent
commit
7ca2553da2
  1. 17
      src/drivers/trone/trone.cpp

17
src/drivers/trone/trone.cpp

@ -79,6 +79,9 @@ @@ -79,6 +79,9 @@
/* TRONE Registers addresses */
#define TRONE_MEASURE_REG 0x00 /* Measure range register */
#define TRONE_WHO_AM_I_REG 0x01 /* Who am I test register */
#define TRONE_WHO_AM_I_REG_VAL 0xA1
/* Device limits */
#define TRONE_MIN_DISTANCE (0.20f)
@ -308,7 +311,20 @@ out: @@ -308,7 +311,20 @@ out:
int
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();
}
debug("WHO_AM_I byte mismatch 0x%02x should be 0x%02x\n",
(unsigned)who_am_i,
TRONE_WHO_AM_I_REG_VAL);
// not found on any address
return -EIO;
}
void
@ -643,7 +659,6 @@ TRONE::cycle() @@ -643,7 +659,6 @@ TRONE::cycle()
* Is there a collect->measure gap?
*/
if (_measure_ticks > USEC2TICK(TRONE_CONVERSION_INTERVAL)) {
/* schedule a fresh cycle call when we are ready to measure again */
work_queue(HPWORK,
&_work,

Loading…
Cancel
Save