29 lines
518 B
C++
29 lines
518 B
C++
#include "aSPISlave.h"
|
|
#include "bCommands.h"
|
|
|
|
void setup() {
|
|
Serial.begin(2000000);
|
|
SPI_SlaveInit();
|
|
|
|
Serial.println();
|
|
Serial.println("Initialization ");
|
|
}
|
|
|
|
void processSPI(void (*callback)(char*)) {
|
|
if (PINB & (1 << 2)) {
|
|
if (index > 1) {
|
|
char checkSum = CRC8(data, index - 1);
|
|
char lastElement = data[index - 1];
|
|
if (lastElement == checkSum) {
|
|
callback(data);
|
|
index = 0;
|
|
return;
|
|
}
|
|
index = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
void loop() {
|
|
processSPI(SetCommand);
|
|
} |