demo demo
/
LIS302HelloWorld
WHOAMI Example for the LIS302
Revision 0:51161d5d0bb2, committed 2010-02-23
- 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 |
diff -r 000000000000 -r 51161d5d0bb2 main.cpp --- /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); +}
diff -r 000000000000 -r 51161d5d0bb2 mbed.bld --- /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