MediaTek-Labs / Arduino-Add-On-for-LinkIt-SDK

Arduino board support package for LinkIt 7697
https://docs.labs.mediatek.com/resource/linkit7697-arduino/en
34 stars 33 forks source link

Problem with Wire Library #110

Open st9040215 opened 5 years ago

st9040215 commented 5 years ago

I want to achieve I2C Read by using Wire library Wire.endTransmission(false) always return 4 this code is OK with MEGA 2560 Board

I check this website: https://www.arduino.cc/en/Reference/WireEndTransmission 0:success 1:data too long to fit in transmit buffer 2:received NACK on transmit of address 3:received NACK on transmit of data 4:other error

7697 does not support wire library?

include

void setup() { Wire.begin(); Wire.setClock(50000L); Serial.begin(9600); }

uint8_t address = 0x0A; uint8_t reg = 0x01; uint8_t numBtyes = 2; uint8_t R_code = 0; uint8_t Buffer[64];

void loop() { int i = 0; Wire.beginTransmission(address); Wire.write(reg); Serial.print(Wire.endTransmission(false)); delay(1); Wire.requestFrom(address, numBtyes ); while(Wire.available()) { Wire.read(); i++; }

delay(1000);

}

Environment

Thanks