commit c915956121ccc602a2735c7caa2ea3315eb3931d Author: Adema Date: Fri May 16 10:21:50 2025 +0200 Upload files to "spi_receive" diff --git a/spi_receive/spi_receive.ino b/spi_receive/spi_receive.ino new file mode 100644 index 0000000..ec31e2a --- /dev/null +++ b/spi_receive/spi_receive.ino @@ -0,0 +1,46 @@ +#include + +uint8_t spiRx[256]; // Array to store received data +volatile int spiRxIdx = 0; // Index to track how many items are in spiRx +volatile int spiRxComplete = 0; // Flag to indicate when data is ready for printing + +char buffer[2048]; // Character buffer to store formatted data +int indexbuf = 0; // Track current position in buffer + + +#include "SPI2Slave_T4.h" + + +SPI2Slave_T4<&SPI2, SPI_8_BITS> mySPI; + +//IntervalTimer SPI_transfer; + +void setup() { + Serial.begin(921600); + SPI.end(); + SPI1.end(); + + SPI2.begin(); + mySPI.begin(); + //SPI_transfer.begin(ReceiveData, 10); // run every 10 microseconds + +} + +void loop() { + if (spiRxComplete) { + indexbuf = 0; + for (int i = 0; i < spiRxIdx; i++) { + indexbuf += snprintf(buffer + indexbuf, sizeof(buffer) - indexbuf, "%02X ", (unsigned int)spiRx[i]); + } + // Print the formatted buffer at once + Serial.println(buffer); + + // Reset for the next round of data + spiRxComplete = 0; + spiRxIdx = 0; + } + delayMicroseconds(1); +} + +void ReceiveData() { +}