I need to burst write the DMP library into the mpu6050 but not succeed.
The following is the function that I've been using to burst write.
uint32_t nrf_drv_mpu_write_registers(uint8_t reg, uint8_t * p_data, uint32_t length) { // This burst write function is not optimal and needs improvement. // The new SDK 11 TWI driver is not able to do two transmits without repeating the ADDRESS + Write bit byte uint32_t err_code; uint32_t timeout = MPU_TWI_TIMEOUT; // Merging MPU register address and p_data into one buffer. merge_register_and_data(twi_tx_buffer, reg, p_data, length); // Setting up transfer nrf_drv_twi_xfer_desc_t xfer_desc; xfer_desc.address = MPU_ADDRESS; xfer_desc.type = NRF_DRV_TWI_XFER_TX; xfer_desc.primary_length = length + 1; xfer_desc.p_primary_buf = twi_tx_buffer; // Transferring err_code = nrf_drv_twi_xfer(&m_twi_instance, &xfer_desc, 0); while((!twi_tx_done) && --timeout); if(!timeout) return NRF_ERROR_TIMEOUT; twi_tx_done = false; return err_code; }
I have researched on the following function:
bool i2cdev_writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t* data) { /* if (NRF_SUCCESS!=nrf_drv_twi_tx(&m_twi,devAddr,®Addr,1,true)) return false; return NRF_SUCCESS==nrf_drv_twi_tx(&m_twi,devAddr,data,length,false); */ //TODO: This could be improved... uint8_t buffer[32]; buffer[0] = regAddr; uint8_t i = 1; while(i < (length + 1)) buffer[i++] = *data++; return NRF_SUCCESS==nrf_drv_twi_tx(&m_twi,devAddr,buffer,length+1,false); }
I see this function is for continuous write of bytes but to consecutive addresses.
Can I do the burst write by changing the no_stop parameter to true. The attached photo is the definition for the nrf_drv_twi_tx function