onSPITransaction()

[Serial Peripheral Interface]
void onSPITransaction(void (*function)());

Description

Sets the function that will be called when the follower SPI bus is selected by first time.

Parameters

function: the function that will be called when the follower SPI bus is selected.

Returns

Nothing.

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.

Sets the function transactionEvent as callback when the follower SPI bus is selected.

void transactionEvent() {
    // code to be executed when the follower SPI bus is selected
}

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
    onSPITransaction(transactionEvent);  // sets the function transactionEvent as callback when the follower SPI bus is selected
}

void loop() {
}

Notes and Warnings

The parameter function must be a function that does not receive any parameters.