#include <SPI.h>
// define Xiao CS
#define CS 7
SPISettings settings(1000000, MSBFIRST, SPI_MODE0);
void setup() {
Serial.begin(9600);
SPI.begin();
pinMode(CS,OUTPUT);
digitalWrite(CS, HIGH);
}
void loop() {
SPI.beginTransaction(settings);
digitalWrite(CS, LOW);
SPI.transfer(0x00); // Address to read from peripheral
SPI.transfer(0x80); // Byte signalling read instruction to peripheral
uint8_t readByte = SPI.transfer(0xFF); // Sent DONT CARE byte and receive peripheral data
digitalWrite(CS, HIGH);
Serial.print(“0x”);
Serial.println(readByte, HEX);
delay(10);
SPI.endTransaction();
delay(1000);
}