-
Notifications
You must be signed in to change notification settings - Fork 450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Increase I2C Buffer Length or Provide Configurable Interface #2728
Comments
It sounds like you have a need and an idea how to make it work. Want to do a PR adding the ESP32's |
But I found a strange thing that, I copyed Wire.h and Wire.cpp into my code space, using size_t TwoWire::requestFrom(uint8_t address, size_t quantity, bool stopBit) {
if (!_running || _txBegun || !quantity || (quantity > sizeof(_buff))) {
return 0;
}
_buffLen = i2c_read_blocking_until(_i2c, address, _buff, quantity, !stopBit, make_timeout_time_ms(_timeout));
if ((_buffLen == PICO_ERROR_GENERIC) || (_buffLen == PICO_ERROR_TIMEOUT)) {
if (_buffLen == PICO_ERROR_TIMEOUT) {
_handleTimeout(_reset_with_timeout);
}
_buffLen = 0;
}
_buffOff = 0;
return _buffLen;
}
} when requesting data from a sensor that returns more than 255 bytes. Specifically, I have a sensor that returns 258 bytes of data. When I set the
|
int i2c_read_blocking_until (i2c_inst_t * i2c, uint8_t addr, uint8_t * dst, size_t len, bool nostop, absolute_time_t until) The size_t data type should be able to represent sizes larger than 255, but the function seems to have an implicit limit. Seems only uint8_t was accepted |
FWIW, we use the plain SDK code. To me it doesn't seem to have any limitations baked in...it just uses polling to fill The datasheet doesn't talk about any limitations either (there's only a 10 byte FIFO but that's busy polled in the SDK). For sanity you might want to |
okay, seems like my sensor has some problem, since i changed another one, everything works good. i will make a pr to provide a method to adjustment the buffer size of i2c |
It's been years since I implemented the code so I completely forgot that this capability already exists (taken from the ESP8266 side). Just define the new size in your platform.local.txt or P.IO INI file and you can set it to any size needed: arduino-pico/libraries/Wire/src/Wire.h Lines 33 to 35 in b4001bf
|
Hello,
I have encountered some issues while using the
arduino-pico
library, particularly when porting libraries based on ESP32. The I2C implementation in ESP32 does not have a strict buffer length limitation, whereas the arduino-pico library limits the I2C buffer length to 256 bytes. This limitation makes it difficult to port some ESP32-based libraries to arduino-pico, especially when sensors or devices return data exceeding 256 bytes in a single transaction.Suggestions:
The text was updated successfully, but these errors were encountered: