From 49b1d30ab9e7c6f7dcffac633fc5aa5022a849cf Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Fri, 3 Jan 2020 17:35:44 +0100 Subject: [PATCH] I2C: allow static redefinition of buffer size Default buffer size is still 32, but it is now possible to redefine compilation switch: I2C_TXRX_BUFFER_SIZE It's maximum value is 255 --- libraries/Wire/src/utility/twi.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/Wire/src/utility/twi.h b/libraries/Wire/src/utility/twi.h index c686998807..07d22a0949 100644 --- a/libraries/Wire/src/utility/twi.h +++ b/libraries/Wire/src/utility/twi.h @@ -61,7 +61,11 @@ extern "C" { #endif /* I2C Tx/Rx buffer size */ +#if !defined(I2C_TXRX_BUFFER_SIZE) #define I2C_TXRX_BUFFER_SIZE 32 +#elif (I2C_TXRX_BUFFER_SIZE >= 256) +#error I2C buffer size cannot exceed 255 +#endif /* Redefinition of IRQ for F0/G0/L0 families */ #if defined(STM32F0xx) || defined(STM32G0xx) || defined(STM32L0xx)