Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 9 months ago.
The register write by SPI communication
hi all! I am a student of Japan. It is not good at English. I'm sorry if there is wrong terms.
I have been learning about the mbed SPI I am learning in the SPI and mbed.
Use mbed and LPS331AP module.
I can read Register but can't write Register. How do I, do I write to register?
please help me...
my program ↓
- include "mbed.h"
SPI spi(p5, p6, p7); mosi, miso, sclk DigitalOut cs(p8); Serial pc(USBTX, USBRX); tx, rx int main() { spi.format(8,2); spi.frequency(10000);
cs = 0; spi.write(0x20); spi.write(0x90);
wait_ms(10);
spi.write(0x20); int whoami = spi.write(0xff); pc.printf("WHOAMI register = 0x%X\n", whoami);
cs = 1; }
Thanks for reading the poor English!