简体   繁体   中英

I2C communication between RP2040 and adxl357 accelerometer ( C/C++ SDK )

I need to communicate via I2C to the adxl357 accelerometer and a few questions have arisen. Looking at the RP2040 sdk documentation I see that there is a special method to send data to a certain address, such as i2c_write_blocking() . Its arguments include a 7-bit address and the data to be sent. My question is, since the accelerometer needs a Read/Write bit, is it still possible to use this function? Or should I go to the alternative i2c_write_raw_blocking() ?

Also, I don't understand the notation of the Read / Write bit, it is reported with R/#W, would that mean that 1 is Read while 0 is write?

Thanks in advance for the help.

I2C addresses have 7 bits: these are sent in the high 7 bits of an 8-bit byte, and remaining bit (the least significant bit) is set to 1 for read, 0 for write.

The reason the documentation says it wants a 7-bit address is because it is telling you that the write function will left-shift the address by one and add a 1, and the read function function will left-shift the address by one and add a 0.

If it didn't tell you this you might pre-shift the address yourself, which would be wrong.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM