Closed
Description
Board
Any
Device Description
Not specific to a device.
Hardware Configuration
Any I2C device connected
Version
v2.0.2
IDE Name
CLion + platformio
Operating System
Linux
Flash frequency
N/A
PSRAM enabled
no
Upload speed
N/A
Description
The Wire::begin
method has confusing overload:
bool begin(int sda=-1, int scl=-1, uint32_t frequency=0); // returns true, if successful init of i2c bus
bool begin(uint8_t slaveAddr, int sda=-1, int scl=-1, uint32_t frequency=0);
The sda
and scl
arguments are of type int
, while the SDA
and SCL
constants from d32_core.h
have type uint8_t
. A "naive" user might try to call begin(SDA, SCL)
and get mysterious "could not acquire lock"
error on first attempt to use the bus.
To make the problem worse, this code worked fine before the "slave" overload was introduced.
As a solution I want to propose renaming the "slave" function to something like begin_slave
.
Sketch
int setup(){
// have to explicitly specify the pins to provide the frequency
Wire.begin(SDA, SCL, 4000);
Wire.beginTransmission();
}
Debug Message
[ 238][E][Wire.cpp:319] beginTransmission(): could not acquire lock
[ 239][E][esp32-hal-i2c.c:142] i2cWrite(): could not acquire lock
### Other Steps to Reproduce
_No response_
### I have checked existing issues, online documentation and the Troubleshooting Guide
- [X] I confirm I have checked existing issues, online documentation and Troubleshooting guide.
Metadata
Metadata
Assignees
Type
Projects
Status
Done