test
Revision 0:48b56cad57ae, committed 2017-06-02
- Comitter:
- kevin1990
- Date:
- Fri Jun 02 09:14:50 2017 +0000
- Child:
- 1:bb09fc532f44
- Commit message:
- test
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 Fri Jun 02 09:14:50 2017 +0000
@@ -0,0 +1,34 @@
+#include "mbed.h"
+
+SPI spi(D11, D12, D13); // mosi, miso, sclk
+DigitalOut chipSelect(D10);
+
+Serial pc(USBTX, USBRX); // tx, rx
+
+int main() {
+
+ int valueToSendToSlave = 20; // Starting value only, this increments
+ spi.format(8,3); // Setup: bit data, high steady state clock, 2nd edge capture
+ spi.frequency(1000000); //1MHz
+
+ pc.printf("======================================================\r\n");
+ pc.printf("Press any key to start...\r\n");
+ pc.getc(); // wait for keyboard
+
+ int counter = 1;
+ while (1) {
+
+ pc.printf("%d Value to send = %d ", counter++, valueToSendToSlave);
+
+ chipSelect = 0; // Select device
+ int dataFromSlave = spi.write(valueToSendToSlave);
+ chipSelect = 1; // Deselect device
+
+ pc.printf(" returns %d\r\n", dataFromSlave);
+
+ valueToSendToSlave++;
+
+ wait(5); // Wait for 5 seconds for readability only
+
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jun 02 09:14:50 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/86740a56073b \ No newline at end of file