This makes the library compatible with Particle MCUs (or at any rate the Argon I tested it on).
Every vendor seems to have their own special way of sizing their I2C transmit buffers, and the Particle HAL has yet another way and #define that exposes their default size. Annoyingly, their default buffer length (I2C_BUFFER_LENGH = 32) is different from their default serial buffer length (SERIAL_BUFFER_SIZE = 64), so the #else fallback to 32 doesn't pan out.
Suggestions for future work:
The optimization to use SERIAL_BUFFER_SIZEmay not be warranted for all MCUs - consider just letting those fall back on 32 maybe?
This may want to be a runtime-configurable parameter, with the #define-based values as fallbacks, since one can (in theory) create multiple Wire objects which may (at least on Particle) have different buffer sizes.
It would awesome if the standard Wire protocol exposed its dang buffer size, but that's for another day...
Test coverage: tested on my Particle Argon with an Adafruit 128x32 OLED Featherwing.
This makes the library compatible with Particle MCUs (or at any rate the Argon I tested it on).
Every vendor seems to have their own special way of sizing their I2C transmit buffers, and the Particle HAL has yet another way and #define that exposes their default size. Annoyingly, their default buffer length (
I2C_BUFFER_LENGH
= 32) is different from their default serial buffer length (SERIAL_BUFFER_SIZE
= 64), so the#else
fallback to 32 doesn't pan out.Suggestions for future work:
SERIAL_BUFFER_SIZE
may not be warranted for all MCUs - consider just letting those fall back on 32 maybe?Wire
objects which may (at least on Particle) have different buffer sizes.It would awesome if the standard Wire protocol exposed its dang buffer size, but that's for another day...
Test coverage: tested on my Particle Argon with an Adafruit 128x32 OLED Featherwing.