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

Port Arduino I2C code with nrf TWI Driver

I am in the process of porting arduino library VL53LX01 to the nrf51822 using nrf_drv_twi functions. I will use this with S130 and thinking of using blocking mode.

I initialized without giving interrupt handler and hope it will run on blocking mode.

err_code = nrf_drv_twi_init(&m_twi, &twi_Vl530x_config, NULL, NULL);

I am thinking of using

err_code = nrf_drv_twi_tx(&m_twi, address, val, 1, false);

for the below code block in Arduino library to write.

  Wire.beginTransmission(address);
  Wire.write(reg);
  Wire.write(value);
  last_status = Wire.endTransmission();

Similary

ret_code_t err_code = nrf_drv_twi_rx(&m_twi, address, &value, 1);

for read byte instead the below code segment

  Wire.requestFrom(address, (uint8_t)1);
  value = Wire.read();

Anyone have any idea whether its correct to do it this way?

Is there any effect on using blocking mode for s130 functions ?

Pls help

Parents Reply Children
No Data
Related