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.
Fork of spi_comm by
Revision 1:5a737795f89c, committed 2017-12-25
- Comitter:
- Ishwar_Anjana
- Date:
- Mon Dec 25 17:47:44 2017 +0000
- Parent:
- 0:ff086cd5333c
- Commit message:
- hi
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Jan 11 22:55:47 2017 +0000
+++ b/main.cpp Mon Dec 25 17:47:44 2017 +0000
@@ -1,27 +1,33 @@
#include "mbed.h"
-
-SPI spi(p5, p6, p7); // mosi, miso, sclk
-DigitalOut cs(p8);
-
+#include "SPI.h"
+SPI spi(D11, D12, D13); // mosi, miso, sclk
+DigitalOut cs(D9);
+
+char hello[14] = "Hello World \n";
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,3);
+ 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(0x8F);
+ //spi.write(0x8F);
// Send a dummy byte to receive the contents of the WHOAMI register
- int whoami = spi.write(0x00);
- printf("WHOAMI register = 0x%X\n", whoami);
+ while(1){
+ cs = 0;
+ for(int i=0; i<14; i++){
+ spi.write(hello[i]);
+ }
+ wait(2);
+ cs = 1;
+ wait(1);
+ }
// Deselect the device
- cs = 1;
}
\ No newline at end of file
