This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Need an equivalent for an arduino code

hello everyone I am trying to implement a Library from Arduino to nordic but I have a problem : 

this is the Arduino code :

Wire.beginTransmission(dev_id);
  Wire.write(reg_addr);   // Accès au registre
  Wire.endTransmission(false);
  Wire.requestFrom(dev_id, len);
  if (len<=Wire.available()){
    for(int i=0;i<len;i++){
        data[i] = Wire.read();        
    }
  }else{
    result=5;
  }

I replace by that :

uint8_t reg[1]={reg_addr};
  nrf_drv_twi_tx(&m_twi, dev_id, reg, 1,false);
  nrf_drv_twi_rx(&m_twi, dev_id, data, len);

But I Don't know how to do the control : len <= Wire.available().

Thank you have a good day.

Arnaud

Related