Hi, I recently started working with the NRF51822 and PCA1001 I need to read data from MPU9150 accelerometer via I2C and transmit the results over BLE.
I connected the MPU wires SCL to P0.24 and SDA to P0.25 I added "sd_twi_hw_master.c" as a library file
I am trying to read data from the sensor on a timed event in this manner : in the main() function I call "twi_master_init()" after the advertising starts and it returns that it was successfull(true)
however when I try to read some data, the problems begin.
I previously tried to use this sensor with an RFduino, in order to test the connection I used to use this function :
accelgyro.testConnection() It actually uses this command : I2Cdev::readBits(devAddr, 0x75, 6, 6, buffer);
and compares it with 0x34
I tried to implement something like that on the NRF51822, this is my code :
bool transfer_succeeded = true; uint8_t register_address = 0x75; transfer_succeeded &= twi_master_transfer((m_device_address<<1) | 0x01, ®ister_address, 1, false); nrf_delay_us(400); if (transfer_succeeded) { transfer_succeeded &= twi_master_transfer(m_device_address<<1, value, 1, true); nrf_delay_us(400); }
now it seems that the first transfer always returns false.
what is the problem, how should I implement it?
thanks