#include <SPI.h>
const uint32_t CS_PIN = D10; // à adapter à votre cablage
const uint16_t DIG0 = 0x01; // ligne 0

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 static data = 0x0055;
  SPI.beginTransaction(cfgSPI);
  for (uint8_t n_ligne = DIG0; n_ligne < DIG0+8; n_ligne++) {
    trame = n_ligne << 8;
    data = data^0x00FF;
    trame |= data;
    digitalWrite(CS_PIN, LOW);
    for (uint8_t i = 0; i < 4; i++) {
      SPI.transfer16(trame);
    }
    digitalWrite(CS_PIN, HIGH); // le front montant provoque le verrouillage des données dans le(s) MAX7219
  }
  SPI.endTransaction();
}

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