SPI Master/Slave communication between two NUCLEO module. You can send objects ( float, text, ..etc) between them. These projects should be used together: SPI_NUCLEO_MASTER SPI_NUCLEO_SLAVE

Files at this revision

API Documentation at this revision

Comitter:
mjm2016
Date:
Wed Dec 06 08:46:12 2017 +0000
Parent:
0:52f83e5addd7
Commit message:
bug fixed

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Dec 05 10:33:22 2017 +0000
+++ b/main.cpp	Wed Dec 06 08:46:12 2017 +0000
@@ -29,9 +29,9 @@
 
 
 
-#define SPI_DUMMY     0X00
+#define SPI_DUMMY     0X0000
 #define SPI_CMD       0XADAD     //Anything as a CMD code.
-#define SPI_FAULT     0xDD       //Anything as a part of 16 bit as control byte
+#define SPI_FAULT     0xDD00       //Anything as a part of 16 bit as control byte
 
 #ifdef _DEBUG
 extern Serial pc;
@@ -49,10 +49,10 @@
 /*This will be the float number we wish to transfer. 
 You can make a struct of multiple variable and send it in the same way*/
 
-typedef union SPI_Packet_t{
+typedef union {
 float sensor;
 byte SPI_Packet[sizeof(float)];
-};
+}SPI_Packet_t;
 
 SPI_Packet_t packet;
 int main()
@@ -93,7 +93,7 @@
                             }
                             else {
                                 slave.reply(SPI_FAULT); //ERROR CODE
-                                slave.reply(SPI_DUMMY);     //dummy ..skiped value
+                                break;
                             }
                         }
                     }