I need to read 4 bytes of data from MAX30100 chip using c/c++ and I2C on raspberry Pi. I tried doing it with python. And it worked. But the problem was the data rate is too slow, I need to update the data at least 250 times/sec, which means the frequency of reading is >= 250Hz. So, i switched the reading from python to c/c++.
There is no problem when just read or write one byte with wiringPi. However, I need to read 4 bytes from fifo (address of the fifo is 0x04), wiringPi doesn't provide a function to do the block data reading. There are only read byte/word functions.
Then, I tried use SMBus to do the block reading, which can be found here:
https://github.com/leon-anavi/rpi-examp ... /c/smbus.c
But, as soon as I call the i2c_smbus_read_block_data(), my raspberry Pi freezes completely.
Anyone knows what's going on there? Or has a better solution?