selectedSPI()
[Serial Peripheral Interface]
bool selectedSPI();Description
Checks if the chip is selected.
Parameters
None.
Returns
A boolean value that indicates if the chip is selected.
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, it sends data to the leader chip.
void setup() {
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
writeSPI(0x01); // sends data to the leader chip
}
}Notes and Warnings
This function is only useful if the chip is acting as a follower, and it is needed to continue with the communication.
