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
main.cpp
- Committer:
- ODEM
- Date:
- 2017-06-09
- Revision:
- 1:a5921d978d61
- Parent:
- 0:466ad3f38b6b
- Child:
- 2:29e536aabd5b
File content as of revision 1:a5921d978d61:
#include "mbed.h" 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,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(0x800); // Send a dummy byte to receive the contents of the WHOAMI register int whoami = spi.write(0x00); printf("WHOAMI register = %d\n", whoami); // Deselect the device cs = 1; }