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 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
6363class TwoWire : public WireBase {
Original file line number Diff line number Diff 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
8080uint8 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
9898void 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 }
Original file line number Diff line number Diff line change 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 */
5656class WireBase { // Abstraction is awesome!
5757protected:
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
You can’t perform that action at this time.
0 commit comments