SHIELD-Malb41k1/SPI/slave/SPI-Slave/SPI-Slave.ino
Soundflog 6b39c55d91 Переход на C
Пока не работает
2023-04-27 15:33:58 +03:00

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);
}