Upload files to "spi_send"
This commit is contained in:
parent
c915956121
commit
6a2e8436be
32
spi_send/spi_send.ino
Normal file
32
spi_send/spi_send.ino
Normal file
@ -0,0 +1,32 @@
|
||||
#include <SPI.h>
|
||||
|
||||
#define cs_pin 44 // Chip Select pin (must match the slave setup)
|
||||
|
||||
uint8_t dataToSend[256];
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.println("SPI Master Starting...");
|
||||
|
||||
pinMode(cs_pin, OUTPUT);
|
||||
digitalWrite(cs_pin, HIGH);
|
||||
|
||||
SPI2.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
dataToSend[i] = i;
|
||||
}
|
||||
|
||||
SPI2.beginTransaction(SPISettings(22000000, MSBFIRST, SPI_MODE0));
|
||||
Serial.println("Sending data...");
|
||||
digitalWrite(cs_pin, LOW);
|
||||
SPI2.transfer(dataToSend, 256); // Send the whole array at once
|
||||
digitalWrite(cs_pin, HIGH);
|
||||
Serial.println("Data sent.");
|
||||
SPI2.endTransaction();
|
||||
|
||||
delayMicroseconds(1000); // Wait before sending again
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user