I am trying to get multiple bytes from my sensor and I am not sure what is the correct sequence that Intel Edison use to store data to a buffer array.
Specifically, I am trying to use this method to get data from Ublox gps module stored in address # 0xFD and # 0xFE:
uint8_t buf ;
mraa_i2c_read_bytes_data(m_i2c, 0xFD, buf, 2); //this should give me data from address # 0xFE as well because of auto-increment of address counter
Now, the following code is from upm ADIS16448 library.
So this code suggests that the upper byte is stored inside buf instead of buf. Does that mean that in my case, the data from # 0xFE is stored in buf and data from # 0xFD is stored in buf? And What will happen if I declare buf size to be 3 for example?
Thanks in advance
There's something I don't understand about your question. You mention that you need to understand how buffers are "filled" and you mention the mraa command to read I2C bytes but then you post a section of the ADIS16448 library which works with SPI.
Nevertheless, the way the bytes "enter" in the ADIS16448 library is not through buf, but instead they are received through x and then ordered into _dataOut which is what's returned.
I am sorry for the confusion in my code, The code of ADIS16448 suggests that the x stores the upper byte while x stores the lower byte. So I assume that in my case, if I run mraa_i2c_read_bytes_data(m_i2c, 0xFD, buf, 2), buf stores data from # 0xFD and buf stores data from # 0xFE, I am just asking to confirm my speculation.
Thank you very much.
I am posting this as clarification as I finally realized what caused me the confusion.
I have recently discovered that ADIS16448 actually stores upper byte at an address higher than the address of the lower byte. That is the reason why buf contains upper byte while buff contains the lower byte. So if I run the mraa_i2c_read on another device which stores the data in its registers using the reverse order, the data I get in my buffer will be in reverse order as well.