Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:51161d5d0bb2
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);
+}