43 lines
587 B
C++
43 lines
587 B
C++
#include "SPISlave.h"
|
|
#include "head_oled_i2c.h"
|
|
|
|
static int index = 0;
|
|
static int arIndex = 0;
|
|
static char data[64];
|
|
|
|
ISR(SPI_STC_vect)
|
|
{
|
|
char received = SPDR;
|
|
data[index] = received;
|
|
index++;
|
|
}
|
|
|
|
void setup()
|
|
{
|
|
SPI_SlaveInit();
|
|
initialization();
|
|
|
|
Fill(0);
|
|
update();
|
|
}
|
|
|
|
void loop() {
|
|
if(PINB & (1 << 2)){
|
|
if(index > 0){
|
|
char sum = 0;
|
|
sum = crc8(data, index-1);
|
|
char last_1 = data[index - 1];
|
|
|
|
if (last_1 == sum){
|
|
SetCommand(data, index);
|
|
|
|
index = 0;
|
|
return;
|
|
}else{
|
|
index = 0;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|