availableSPI()

[Serial Peripheral Interface]
bool availableSPI();

Description

Checks if the SPI bus buffer contains any data.

Parameters

None.

Returns

A boolean value that indicates if the SPI bus buffer contains any data.

Example Code

The code initializes the SPI communication with the clock pin connected to pin 13, the data in pin connected to pin 12, the data out pin connected to pin 11, the chip select pin connected to pin 10, and the polarity of the chip select line set to LOW.

Continuously checks if the chip is selected, and if it is, checks if the SPI bus buffer contains any data, and if it does, reads the data from the SPI bus buffer and save it into the EEPROM.

void setup() {
    beginEEPROM(32);                // initializes the EEPROM
    beginSPI(13, 12, 11, 10, LOW);  // initializes the SPI communication with the clock pin connected to pin 13, the data in pin connected to pin 12, the data out pin connected to pin 11, the chip select pin connected to pin 10, and the polarity of the chip select line set to LOW
}

void loop() {
    if (selectedSPI()) {            // checks if the chip is selected
        if (availableSPI()) {       // checks if the SPI bus buffer contains any data
            writeEEPROM(1, readSPI()); // reads the data from the SPI bus buffer and save it into the EEPROM
        }
    }
}