SPI "transfer" function

I’m reading the particle reference docs of the firmware for SPI. The problem is that I don’t really understand “transfer” function because it says that “SPI.transfer(val)” is both for sending and receiving. If I’m using Photon as master and I don’t care about the slave feedback, I can just write “SPI.transfer(0x01);”. But if I’m using Photon as a slave, how do I use “transfer” to receive data?

If in the slave loop I have “SPI.transfer(val);”, is “val” going to be the receiving data???

The doc says “the parameter val is the byte to send out over the SPI bus”, so where do I get the byte I received???

You can have a look at the sample shown for onSelect()
https://docs.particle.io/reference/firmware/photon/#onselect-

But the example uses “transfer(rx_buffer, tx_buffer, sizeof, function)” and the doc says that is used for transfering a large number of bytes. I just want to send “0” or “1”, that’s why I’m using just “transfer(val)” because it only transfers 1 byte and it’s simplier. Support told me you can use in the slave loop to transfer and receive, but I don’t understand where do you receive.

The return value of transfer(0) will be the byte you want to read.

  uint8_t x;
  x = SPI.transfer(0);

Ok let me try it. Thank you!