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.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I think @AkosLukacs has hit it on the head. SPI should be pretty straight forward. The main gotchas are:
reg|0x80
- the code above uses0xC0
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.