MPL3115A2
Fork of SPI_HelloWorld_Mbed by
Mit dem XTRINSIC-SENSE Board von element14 wird der Sensor MPL3115 ausgelesen.
mbed | XTRINSIC-SENSE Board |
---|---|
VOUT 3.3v | CN2->3.3v (1) |
GND | CN2->SCL (3) |
pin9 sda | CN3->SDA (3) |
pin10 scl | CN3->SCL (5) |
Datenblatt Board: /media/uploads/ODEM/xtrinsic-sense_user_manual_v0_5.pdf
Datenblatt Sensor: /media/uploads/ODEM/mpl3115a2.pdf
Diff: main.cpp
- Revision:
- 1:a5921d978d61
- Parent:
- 0:466ad3f38b6b
- Child:
- 2:29e536aabd5b
diff -r 466ad3f38b6b -r a5921d978d61 main.cpp --- a/main.cpp Tue Feb 12 17:25:49 2013 +0000 +++ b/main.cpp Fri Jun 09 12:37:41 2017 +0000 @@ -3,24 +3,28 @@ SPI spi(p5, p6, p7); // mosi, miso, sclk DigitalOut cs(p8); +int temp=0; + + int main() { // Chip must be deselected cs = 1; // Setup the spi for 8 bit data, high steady state clock, // second edge capture, with a 1MHz clock rate - spi.format(8,3); + spi.format(8,0); spi.frequency(1000000); // Select the device by seting chip select low cs = 0; // Send 0x8f, the command to read the WHOAMI register - spi.write(0x8F); + spi.write(0x800); // Send a dummy byte to receive the contents of the WHOAMI register int whoami = spi.write(0x00); - printf("WHOAMI register = 0x%X\n", whoami); + + printf("WHOAMI register = %d\n", whoami); // Deselect the device cs = 1;