Skip to content

Wire broken #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
av1024 opened this issue May 3, 2015 · 4 comments
Closed

Wire broken #167

av1024 opened this issue May 3, 2015 · 4 comments

Comments

@av1024
Copy link

av1024 commented May 3, 2015

  1. Wire.pins(sda, scl) removed but SDA/SCL defined as const uint8_t in pins_arduino.h so can not be redefined (or I don't know how). These changes at least broke the adafruit_bmp085 module
  2. Wire.cpp does not compile in e1a6e3d (may be si2c.cpp not included somewhere).

Wire/Wire.cpp.o: In function `TwoWire::write(unsigned char)':
Wire.cpp:(.text+0x130): undefined reference to `twi_init(unsigned char, unsigned char)'
Wire.cpp:(.text+0x143): undefined reference to `twi_init(unsigned char, unsigned char)'
Wire/Wire.cpp.o: In function `TwoWire::begin()':
Wire.cpp:(.text+0x190): undefined reference to `twi_setClock(unsigned int)'
Wire/Wire.cpp.o: In function `TwoWire::begin(unsigned char)':
Wire.cpp:(.text+0x19b): undefined reference to `twi_setClock(unsigned int)'
Wire/Wire.cpp.o: In function `TwoWire::begin(int)':
Wire.cpp:(.text+0x1a8): undefined reference to `twi_readFrom(unsigned char, unsigned char*, unsigned int, unsigned char)'
Wire/Wire.cpp.o: In function `TwoWire::setClock(unsigned int)':
Wire.cpp:(.text+0x1ca): undefined reference to `twi_readFrom(unsigned char, unsigned char*, unsigned int, unsigned char)'
Wire/Wire.cpp.o: In function `TwoWire::requestFrom(int, int, int)':
Wire.cpp:(.text+0x29c): undefined reference to `twi_writeTo(unsigned char, unsigned char*, unsigned int, unsigned char)'
Wire/Wire.cpp.o: In function `TwoWire::beginTransmission(unsigned char)':
Wire.cpp:(.text+0x2ba): undefined reference to `twi_writeTo(unsigned char, unsigned char*, unsigned int, unsigned char)'
collect2: error: ld returned 1 exit status
Error compiling.
@igrr
Copy link
Member

igrr commented May 4, 2015

Should be fixed in 2e3e98b

@av1024
Copy link
Author

av1024 commented May 4, 2015

Compilation success but TWI not worked. The test code in BMP085.begin() fails (read8 returns 0xFF instead of 0x55)

  1. deprecated pins() realization is not valid because does not store passed values and next begin() uses pre-defined SDA/SCL constants, not passed to pins()
  2. Looks like something else broken for me: at least reading from Serial (I use it for CLI-configuration) causes wdt reset :(

The read8() code from adafruit_BMP085:

    uint8_t Adafruit_BMP085::read8(uint8_t a) {
      uint8_t ret;

      Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device 
    #if (ARDUINO >= 100)
      Wire.write(a); // sends register address to read from
    #else
      Wire.send(a); // sends register address to read from
    #endif
      Wire.endTransmission(); // end transmission

      Wire.beginTransmission(BMP085_I2CADDR); // start transmission to device 
      Wire.requestFrom(BMP085_I2CADDR, 1);// send data n-bytes read
    #if (ARDUINO >= 100)
      ret = Wire.read(); // receive DATA
    #else
      ret = Wire.receive(); // receive DATA
    #endif
      Wire.endTransmission(); // end transmission

      return ret;
    }

The Serial handler implementation (called from loop()):

    void onSerial() {
      while(Serial.available()) {
        char c = (char) Serial.read();
        Serial.write(c);
        cli.putch(c);
        if (cli.isDone()) {
          Serial.println();
          break;
        }
      } 
      if (cli.isDone()) {
       if (!cli.handle(Serial)) {
         Serial.println("\nERR");
       }
     }
    }

igrr added a commit that referenced this issue May 5, 2015
@igrr
Copy link
Member

igrr commented May 5, 2015

Wire.pins should be fixed now (but it's better to use Wire.begin(sda, scl))

@av1024
Copy link
Author

av1024 commented May 6, 2015

pins() fix confirmed.
But TWI still not work for me on 4e387e4
Unfortunately I burned my sensor during reflashing it back so I can't test anymore at least two weeks ((

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants