WHOAMI Example for the LIS302

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
demo
Date:
Tue Feb 23 23:33:36 2010 +0000
Commit message:

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Feb 23 23:33:36 2010 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+
+SPI spi (p11, p12, p13);
+DigitalOut cs (p10);
+
+int main() {
+
+    spi.format(8, 3);         // 8 bit, mode 3 (high clk, 2nd edge capture)
+    spi.frequency(1000000);   // 1MHz clock rate
+
+    // Enable the device, and all three channels
+    cs = 0;
+    spi.write(0x20);
+    spi.write(0x40);
+    cs = 1;
+
+    wait (0.01);
+
+    // Send the command to read the WHOAMI register
+    cs = 0;
+    spi.write(0x8F);
+    char value = spi.write(0x00);
+    cs = 1;
+
+    printf("WHOAMI register contains 0x%X\n", value);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Feb 23 23:33:36 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0