Update Wire.cpp
Adds a check to verify if the port had been already enabled, and only in that case disables/re-enables the port. This also solves the issue of setClock being called after begin(), but doesn't not enable the port if begin() had not been called yet.
This commit is contained in:
parent
799f2b3b8a
commit
a530b6a3d4
|
@ -97,8 +97,10 @@ void HardWire::setClock(uint32_t frequencyHz)
|
|||
dev_flags &= ~I2C_FAST_MODE;// clear FAST_MODE bit
|
||||
break;
|
||||
}
|
||||
i2c_disable(sel_hard);
|
||||
i2c_master_enable(sel_hard, dev_flags);
|
||||
if (sel_hard->regs->CR1 & I2C_CR1_PE){
|
||||
i2c_disable(sel_hard);
|
||||
i2c_master_enable(sel_hard, dev_flags);
|
||||
}
|
||||
}
|
||||
|
||||
HardWire Wire(1);
|
||||
|
|
Loading…
Reference in New Issue