#include <SPI.h>
const uint32_t CS_PIN = D10; // à adapter à votre cablage
const uint16_t DIG0 = 0x01; // ligne 0
void setup()
{
uint16_t trame;
SPISettings cfgSPI(10000000, MSBFIRST, SPI_MODE0);
Serial.begin(115200);
Serial.println("Boot");
pinMode(CS_PIN, OUTPUT);
uint16_t donnees = 0x00AA;
uint16_t adresse;
// SPI Transaction: sends the contents of buffer, and overwrites it with the received data
// POUR CHARGEMENT AUTORISER
digitalWrite(CS_PIN, LOW);
SPI.beginTransaction(cfgSPI);
for ( uint8_t cpt = 0; cpt < 8; cpt++)
{
digitalWrite(CS_PIN, LOW);
trame=0x0000;
adresse = DIG0 + cpt;
adresse = adresse << 8;
trame |= adresse;
trame |= donnees;
SPI.transfer16(trame); //10 0101 0101
SPI.transfer16(trame); //10 0101 0101
SPI.transfer16(trame); //10 0101 0101
SPI.transfer16(trame); //10 0101 0101
digitalWrite(CS_PIN, HIGH);
donnees = donnees ^ 0x00FF;
}
SPI.endTransaction();
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
}