File tree Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Original file line number Diff line number Diff line change 57
57
// #define I2C_DELAY(x) {uint32 time=micros(); while(time>(micros()+x));}
58
58
#define I2C_DELAY (x ) do {for (int i=0 ;i<x;i++) {asm volatile (" nop" );}}while (0 )
59
59
60
- # define BUFFER_LENGTH 32
60
+
61
61
62
62
63
63
class TwoWire : public WireBase {
Original file line number Diff line number Diff line change @@ -78,8 +78,8 @@ uint8 WireBase::endTransmission(){
78
78
// call, allows for the Arduino style to stay while also giving the flexibility
79
79
// to bulk send
80
80
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 ;
83
83
}
84
84
itc_msg.addr = address;
85
85
itc_msg.flags = I2C_MSG_READ;
@@ -96,7 +96,7 @@ uint8 WireBase::requestFrom(int address, int numBytes) {
96
96
}
97
97
98
98
void WireBase::write (uint8 value) {
99
- if (tx_buf_idx == WIRE_BUFSIZ ) {
99
+ if (tx_buf_idx == BUFFER_LENGTH ) {
100
100
tx_buf_overflow = true ;
101
101
return ;
102
102
}
Original file line number Diff line number Diff line change 44
44
#include " wirish.h"
45
45
#include < libmaple/i2c.h>
46
46
47
- #define WIRE_BUFSIZ 32
47
+ #define BUFFER_LENGTH 32
48
48
49
49
/* return codes from endTransmission() */
50
50
#define SUCCESS 0 /* transmission was successful */
56
56
class WireBase { // Abstraction is awesome!
57
57
protected:
58
58
i2c_msg itc_msg;
59
- uint8 rx_buf[WIRE_BUFSIZ ]; /* receive buffer */
59
+ uint8 rx_buf[BUFFER_LENGTH ]; /* receive buffer */
60
60
uint8 rx_buf_idx; /* first unread idx in rx_buf */
61
61
uint8 rx_buf_len; /* number of bytes read */
62
62
63
- uint8 tx_buf[WIRE_BUFSIZ ]; /* transmit buffer */
63
+ uint8 tx_buf[BUFFER_LENGTH ]; /* transmit buffer */
64
64
uint8 tx_buf_idx; // next idx available in tx_buf, -1 overflow
65
65
boolean tx_buf_overflow;
66
66
You can’t perform that action at this time.
0 commit comments