• I think @AkosLukacs has hit it on the head. SPI should be pretty straight forward. The main gotchas are:

    • The register is usually sent as the first byte
    • When you read, you need to send the register and then another byte (usually 0 or 255). The first byte you get back is then basically garbage and what comes after is the data.
    • Often devices set the top bit of the register to indicate a read or write (so reg|0x80 - the code above uses 0xC0 which I think is specific to the LIS2DH12. You'd have to check your chip's datasheet.

    If you post the code you have up here we might be able to help you a bit more.

About

Avatar for Gordon @Gordon started