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 Nucleo_rtos_SPISlave_Test by
Diff: main.cpp
- Revision:
- 4:3617af415d4c
- Parent:
- 3:e35c6a9ad906
diff -r e35c6a9ad906 -r 3617af415d4c main.cpp
--- a/main.cpp Tue Oct 04 04:58:34 2016 +0000
+++ b/main.cpp Tue Oct 04 06:43:09 2016 +0000
@@ -3,6 +3,7 @@
#include "SPISlave.h"
#define SPI_SPEED (4000000)
+#define SPI_HEADER (0x55)
BusOut Leds(PA_10, PB_3, PB_5, PB_4, PB_10, PA_8);
//DigitalOut StepChangePin(PC_7);
@@ -36,7 +37,7 @@
}
// Setup SPISlave
- SpiS.format(8, 0);
+ SpiS.format(16, 0);
SpiS.frequency(SPI_SPEED);
// RtosTimer
@@ -48,13 +49,13 @@
uint8_t errCount = 0;
while(1) {
if(SpiS.receive()) {
- uint8_t val = SpiS.read(); // Read byte from master
+ uint16_t val = SpiS.read();
prevVal++;
- if (val != prevVal) {
+ if ((val & 0xff00) != (SPI_HEADER << 8) || (val & 0xff) != prevVal) {
errCount++;
Leds.write(errCount);
}
- prevVal = val;
+ prevVal = val & 0xff;
SpiS.reply(step % 16);
}
}
