// reg - the register address
// len - how many bytes to read
function read(reg,len) {
return spi.send([reg|0xC0,new Uint8Array(len)], cs).slice(1);
}
// reg - the register address
// data - the data you want to send
function write(reg,data) {
return spi.write(reg, data, cs);
}
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.
Ooops, missed the SPI part, sorry.
If you search for SPI in the docs, you get all the modules that use SPI, and you can look at the code.
For example from the LIS2DH12 that has SPI interface as well (at the bottom of the file):
The interesting part: