/*
Wokwi Custom SPI Chip example
The chip implements a simple ROT13 letter substitution cipher:
https://en.wikipedia.org/wiki/ROT13
See https://docs.wokwi.com/chips-api/getting-started for more info about custom chips
*/
#include <SPI.h>
#define CS 10
#define LATCH 9
void setup() {
char buffer[] = "Uryyb, FCV! ";
Serial.begin(115200);
pinMode(CS, OUTPUT);
pinMode(LATCH, OUTPUT);
// SPI Transaction: sends the contents of buffer, and overwrites it with the received data.
SPI.begin();
int16_t speed = 1000;
byte lowByteA = speed & 0xff;
byte highByteA = ((speed >> 8) & 0xff) | 0 << 7 | 1 << 4;
SPI.beginTransaction(SPISettings(20000000, MSBFIRST, SPI_MODE0));
digitalWrite(LATCH, 1); digitalWrite(CS, 0);
SPI.transfer(highByteA); SPI.transfer(lowByteA);
digitalWrite(CS, 1); digitalWrite(LATCH, 0);
SPI.endTransaction();
lowByteA = speed & 0xff;
highByteA = ((speed >> 8) & 0xff) | 1 << 7 | 1 << 4;
SPI.beginTransaction(SPISettings(20000000, MSBFIRST, SPI_MODE0));
digitalWrite(LATCH, 1); digitalWrite(CS, 0);
SPI.transfer(highByteA); SPI.transfer(lowByteA);
digitalWrite(CS, 1); digitalWrite(LATCH, 0);
SPI.endTransaction();
SPI.end();
}
void loop() {
}