forked from mohr/ArduinoIO
SPI Settings adjusted and debugg info activated
This commit is contained in:
parent
b4314f72cb
commit
2c1925d18f
8
main.cpp
8
main.cpp
@ -46,7 +46,7 @@ void sendData(uint8_t *data, size_t len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void transferSPI(uint8_t address, uint8_t *data, size_t datalen) {
|
void transferSPI(uint8_t address, uint8_t *data, size_t datalen) {
|
||||||
SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE0));
|
SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE3));
|
||||||
CS_PORT = ~address;
|
CS_PORT = ~address;
|
||||||
SPI.transfer(data, datalen);
|
SPI.transfer(data, datalen);
|
||||||
delay(100);
|
delay(100);
|
||||||
@ -63,14 +63,14 @@ void handlePacket(uint8_t *packet, size_t packetLen) {
|
|||||||
uint16_t crc = Calculate_CRC(packet, packetLen);
|
uint16_t crc = Calculate_CRC(packet, packetLen);
|
||||||
|
|
||||||
if (crc != 0) {
|
if (crc != 0) {
|
||||||
//Serial.println("invalid Checksum");
|
Serial.println("invalid Checksum");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t payloadLen = (packet[2] << 8) | packet[3];
|
uint16_t payloadLen = (packet[2] << 8) | packet[3];
|
||||||
|
|
||||||
if (payloadLen != packetLen - 6) {
|
if (payloadLen != packetLen - 6) {
|
||||||
//Serial.println("invalid len");
|
Serial.println("invalid len");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ void handlePacket(uint8_t *packet, size_t packetLen) {
|
|||||||
sendData(packet, packetLen);
|
sendData(packet, packetLen);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//Serial.println("invalid command");
|
Serial.println("invalid command");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user