Skip to content

Commit 71d5ab9

Browse files
Wire lib change buffer size definition to BUFFER_LENGTH for better AVR compatibility
1 parent 30e5aea commit 71d5ab9

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

STM32F1/libraries/Wire/SoftWire.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
//#define I2C_DELAY(x) {uint32 time=micros(); while(time>(micros()+x));}
5858
#define I2C_DELAY(x) do{for(int i=0;i<x;i++) {asm volatile("nop");}}while(0)
5959

60-
#define BUFFER_LENGTH 32
60+
6161

6262

6363
class TwoWire : public WireBase {

STM32F1/libraries/Wire/WireBase.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ uint8 WireBase::endTransmission(){
7878
// call, allows for the Arduino style to stay while also giving the flexibility
7979
// to bulk send
8080
uint8 WireBase::requestFrom(uint8 address, int num_bytes) {
81-
if (num_bytes > WIRE_BUFSIZ) {
82-
num_bytes = WIRE_BUFSIZ;
81+
if (num_bytes > BUFFER_LENGTH) {
82+
num_bytes = BUFFER_LENGTH;
8383
}
8484
itc_msg.addr = address;
8585
itc_msg.flags = I2C_MSG_READ;
@@ -96,7 +96,7 @@ uint8 WireBase::requestFrom(int address, int numBytes) {
9696
}
9797

9898
void WireBase::write(uint8 value) {
99-
if (tx_buf_idx == WIRE_BUFSIZ) {
99+
if (tx_buf_idx == BUFFER_LENGTH) {
100100
tx_buf_overflow = true;
101101
return;
102102
}

STM32F1/libraries/Wire/WireBase.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#include "wirish.h"
4545
#include <libmaple/i2c.h>
4646

47-
#define WIRE_BUFSIZ 32
47+
#define BUFFER_LENGTH 32
4848

4949
/* return codes from endTransmission() */
5050
#define SUCCESS 0 /* transmission was successful */
@@ -56,11 +56,11 @@
5656
class WireBase { // Abstraction is awesome!
5757
protected:
5858
i2c_msg itc_msg;
59-
uint8 rx_buf[WIRE_BUFSIZ]; /* receive buffer */
59+
uint8 rx_buf[BUFFER_LENGTH]; /* receive buffer */
6060
uint8 rx_buf_idx; /* first unread idx in rx_buf */
6161
uint8 rx_buf_len; /* number of bytes read */
6262

63-
uint8 tx_buf[WIRE_BUFSIZ]; /* transmit buffer */
63+
uint8 tx_buf[BUFFER_LENGTH]; /* transmit buffer */
6464
uint8 tx_buf_idx; // next idx available in tx_buf, -1 overflow
6565
boolean tx_buf_overflow;
6666

0 commit comments

Comments
 (0)