mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-14 02:49:20 +00:00
I2C device manager (#2282)
* message on dev list change * dc detect * added sht3x sensor. * separete environment data from light * max17055 moved to i2c dev * sht fix, goterror detection fix * fix ext sensor app display for a lot of devices. * added bh1750 driver * autoscan on main view * added devlist mutex * better timing * fix h2 sw8 on poweron by usb
This commit is contained in:
@@ -29,6 +29,21 @@ void I2C::stop() {
|
||||
i2cStop(_driver);
|
||||
}
|
||||
|
||||
bool I2C::probe(i2caddr_t addr, systime_t timeout) {
|
||||
i2cAcquireBus(_driver);
|
||||
chSysLock();
|
||||
_driver->errors = I2CD_NO_ERROR;
|
||||
_driver->state = I2C_ACTIVE_TX;
|
||||
msg_t rdymsg = i2c_lld_master_transmit_timeout(_driver, addr, nullptr, 0, nullptr, 0, timeout);
|
||||
if (rdymsg == RDY_TIMEOUT)
|
||||
_driver->state = I2C_LOCKED;
|
||||
else
|
||||
_driver->state = I2C_READY;
|
||||
chSysUnlock();
|
||||
i2cReleaseBus(_driver);
|
||||
return (rdymsg == RDY_OK);
|
||||
}
|
||||
|
||||
bool I2C::transfer(
|
||||
const address_t slave_address,
|
||||
const uint8_t* const data_tx,
|
||||
|
Reference in New Issue
Block a user