finani / ICM42688

Arduino library for communicating with the InvenSense ICM42688 nine-axis IMUs.
MIT License
47 stars 21 forks source link

fix: use SPI_MODE3 for communication with ICM #4

Closed plusk01 closed 1 year ago

plusk01 commented 1 year ago

ICM 42688-p device expects SPI Mode 3 protocol (idle clock high; sample data on rising edge)

closes #3

finani commented 1 year ago

Thank you for your pull request. I tested the repo with only Teensy 4.0. At that time, It worked fine. So, please comment about this fact. (or split the code using the board type)

plusk01 commented 1 year ago

Thanks for the context. SPI mode should be a board independent setting - it depends on what the ICM device expects. According to the reset value of the DEVICE_CONFIG register, the default expected SPI mode is mode 0 or 3.

I am not sure why it worked on the T4 (maybe some code elsewhere was changing the relevant bit in the DEVICE_CONFIG reg?), but given what the datasheet says I vote to use either mode 0 or 3 in this repo.

I suppose whether or not to use mode 0 or 3 is up for discussion - i tried both with my esp32 and they both work, whereas modes 1 and 2 do not.

image

finani commented 1 year ago

LGTM!