Wire library BUFFER_LENGTH - is there a good way to change it?

Status
Not open for further replies.
The wire library (Wire.h) hard codes the buffer length to 32.

I can edit wire.h but my code is hard for others to use (they have to know to edit it too). Is there some "project specific" way to change the I2C buffer length?
 
I don't see any obvious ways. It is interesting that with the i2c_t3 library the default sizes are 259 bytes and wire it is 32...

Wonder if maybe we should make the default in wire maybe depend on which processor...
 
I recently encountered this same issue. We use a LOT of Teensy devices at my company in custom dev-kits to help our customers learn how to interface to our devices. Now that we need I2C transactions that exceed 32 bytes, there is no good way to share solutions with our customers without having them go into \Program Files (x86)\Arduino\hardware\teensy\avr\libraries\Wire\ and change Wire.h and twi.h directly. We have already had customer-service issues arise when they overlooked this obscure step.

If there isn't already a solution that is constrained to the sketch's source code, I would suggest writing an overload to Wire.begin() (or adding a new Wire.assignBuffer() method) that takes a pointer to a buffer and a length parameter. Then the user can allocate their own buffer and configure Wire.h for their special cases.
 
Status
Not open for further replies.
Back
Top