#include <stdint.h>
#define SPI_ENABLE A6
SYSTEM_MODE(MANUAL)
void setup() {
Serial.begin(115200);
Serial.printf("*** BEGIN ***\r\n");
Serial.printf(" [%d]\r\n",millis());
SPI.begin();
SPI.setClockSpeed(1, MHZ);
SPI.setDataMode(SPI_MODE0);
SPI.setBitOrder(LSBFIRST);
pinMode(SPI_ENABLE, OUTPUT);
digitalWrite(SPI_ENABLE, HIGH); //deselected
}
void loop() {
uint8_t rx_buffer[255];
uint8_t tx_buffer[255];
uint8_t count = 0x57;
for(int i = 0; i < 255; i++) {
tx_buffer[i] = count;
rx_buffer[i] = 0;
count--;
}
digitalWrite(SPI_ENABLE, LOW);
delayMicroseconds(50); //wait for second electron to get ready
SPI.transfer(tx_buffer, rx_buffer, 8, NULL);
digitalWrite(SPI_ENABLE, HIGH);
uint64_t b15 = rx_buffer[15];
uint64_t b14 = rx_buffer[14];
uint64_t b13 = rx_buffer[13];
uint64_t b12 = rx_buffer[12];
uint64_t b11 = rx_buffer[11];
uint64_t b10 = rx_buffer[10];
uint64_t b9 = rx_buffer[9];
uint64_t b8 = rx_buffer[8];
uint64_t b7 = rx_buffer[7];
uint64_t b6 = rx_buffer[6];
uint64_t b5 = rx_buffer[5];
uint64_t b4 = rx_buffer[4];
uint64_t b3 = rx_buffer[3];
uint64_t b2 = rx_buffer[2];
uint64_t b1 = rx_buffer[1];
uint64_t b0 = rx_buffer[0];
Serial.printf("received over SPI: (hex) %x,%x,%x,%x,%x,%x,%x,%x and %x,%x,%x,%x,%x,%x,%x,%x\r\n",b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15);
delay(5000);
}
I could post the sending code too, but it looks fine on the bus to me:
edit: Am I missing something by not expecting to see the zeroes in the printf here?