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.
Dependencies: mbed
Revision 0:ab4af7c70188, committed 2014-11-10
- Comitter:
- pc445
- Date:
- Mon Nov 10 17:20:14 2014 +0000
- Commit message:
- MCP3201_exampleCode
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 Mon Nov 10 17:20:14 2014 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+
+SPI spi(p5, p6, p7); // mosi, miso, sclk
+DigitalOut cs(p8);
+
+int main() {
+ // Chip must be deselected
+
+ cs = 1;
+ spi.format(16,0);
+ spi.frequency(1000000);
+
+ // Setup the spi for 8 bit data, high steady state clock,
+ // second edge capture, with a 1MHz clock rate
+ while(1){
+ // Select the device by seting chip select low
+ cs = 0;
+
+ // Send 0x8f, the command to read the WHOAMI register
+ //spi.write(0x8F);
+
+ // Send a dummy byte to receive the contents of the WHOAMI register
+ unsigned int whoami = spi.write(0x00);
+ whoami = (whoami>>1)&0x0FFF;
+ printf("WHOAMI register = %d\n\r", whoami);
+
+ // Deselect the device
+ cs = 1;
+ //wait(0.001);
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Nov 10 17:20:14 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f \ No newline at end of file