#include <SPI.h>

const uint32_t CS_PIN = D0; // à adapter à votre cablage


void setup() 
{
SPISettings cfgSPI(10000000, MSBFIRST, SPI_MODE0);
uint16_t trame;
Serial.begin(115200);
Serial.println("Boot");
pinMode(CS_PIN, OUTPUT);
// SPI Transaction: sends the contents of buffer, and overwrites it with the received data
uint16_t data = 0x0055;
for(uint16_t dig=1; dig<=8; dig++)
{
  
  data=data^0x00FF;
  digitalWrite(CS_PIN, LOW);
  
  trame = dig << 8;
  trame |= data;
  SPI.beginTransaction(cfgSPI);
  SPI.transfer16(trame);
  SPI.transfer16(trame);
  SPI.transfer16(trame);
  SPI.transfer16(trame);
  SPI.endTransaction();
  

   





  // for(int j=0; j<4; j++)
  // {
  //   if(i%2 == 0)
  //     SPI.transfer16(trame ^ 0xFF);
  //   else SPI.transfer16(trame);
  // }
  
  digitalWrite(CS_PIN, HIGH); // le front montant provoque le verrouillage des données dans le(s) MAX7219
}

}

void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}