small changes and many new sensors
This commit is contained in:
40
io/SoftI2C.h
40
io/SoftI2C.h
@@ -157,7 +157,7 @@ public:
|
||||
Log::addInfo(NAME, "found %d", i);
|
||||
}
|
||||
waitLong();
|
||||
if (i%16 == 0) {delay(10);}
|
||||
//if (i%16 == 0) {DELAY_MS(10);}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,6 +219,44 @@ public:
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/** similar to readReg() but without actually selecting a register */
|
||||
bool readRaw(const uint8_t addr, const uint8_t len, uint8_t* dst) {
|
||||
|
||||
bool ok;
|
||||
|
||||
ok = startWrite(addr);
|
||||
if (!ok) {Log::addInfo(NAME, "failed start read(1)"); return false;}
|
||||
stop();
|
||||
|
||||
ok = startRead(addr);
|
||||
if (!ok) {Log::addInfo(NAME, "failed start read(2)"); return false;}
|
||||
readBytes(dst, len);
|
||||
stop();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** similar to writeReg() but without actually selecting a register */
|
||||
bool writeRaw(const uint8_t addr, const uint8_t len, const uint8_t* src) {
|
||||
|
||||
bool ok;
|
||||
|
||||
// address the slave in write mode and select the first register to read
|
||||
ok = startWrite(addr);
|
||||
if (!ok) {Log::addInfo(NAME, "failed start write"); return false;}
|
||||
ok = writeBytesAndCheck(src, len);
|
||||
if (!ok) {Log::addInfo(NAME, "failed to write register contents"); return false;}
|
||||
|
||||
stop();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user