Note about Slave Select (SS) pin on AVR based boards
All AVR based boards have an SS pin that is useful when they act as a slave controlled by an external master. Since this library supports only master mode, this pin should be set always as OUTPUT otherwise the SPI interface could be put automatically into slave mode by hardware, rendering the library inoperative.
It is, however, possible to use any pin as the Slave Select (SS) for the devices. For example, the Arduino Ethernet shield uses pin 4 to control the SPI connection to the on-board SD card, and pin 10 to control the connection to the Ethernet controller.
My questions are:
Since "All AVR based boards have an SS pin" and " the SPI interface could be put automatically into slave mode by hardware", as I understand, the hardware said here means to former "SS pin", how could it "possible to use any pin as the Slave Select (SS) for the devices"?
How did "the SPI interface be put automatically into slave mode by hardware"? - what is the "hardware" mentioned here?
Is the same " // turn on SPI in slave mode SPCR |= _BV(SPE);
with "SS pin be set as OUTPUT"?
The pin known as the SS pin on the Arduino is the hard wired pin that would make that Arduino an SPI slave to some other device acting as SPI master, (edit) if set low as an input. That's pin 10 on an Uno for example. If you make that pin an output, it will never be inadvertently be set low by some other device as could happen if it was an input. (And you don't want that, since the Arduino SPI library doesn't support being a slave.)
So with the Arduino as SPI master, think of the other end of the system, where some other device is your Arduino's slave. That other device also has a pin that it reads as input to see if it's selected or not. You can control that device's SS input by using any pin you like on the Arduino as an output, and its high-ness or low-ness is what the other, slave, device would read as an input to be selected currently or not. And since you have already decided that Uno pin 10 is an output for safety's sake at your end, you might as well use that as the control for one of your slaves. Then do the same for some other slave device with some other Uno pin, maybe pin 4, but in theory any pin. The shield mentioned has pins 4 and 10 wired up to be used by the SD card and the E'net controller, but if you used any other "loose" SPI device as a slave, you could use any pin you like as its SS. It's common to use pin 4 as SS for an SD card though, even if it's a "loose" one; iirc the SD library has that coded as a default.
That just means the SPI master device, whatever that may be, in system where the Arduino's not the SPI master.
Each SPI device can have one or more master SS (output) pins and one dedicated hard wired slave SS (input) pin.
The slave SS pin has to be configured for input if the controller shall act as a SPI slave. Then an external master can start a transmission to the selected slave. In slave mode both MISO and MOSI are configured for input. Only if the dedicated SS pin is activated the MISO pin can be switched into output mode.
With that SS pin configured for output the SPI hardware can not detect a transfer request from another master and is passive until configured for master mode.
Any pin can be configured as a master SS (output) pin and can be wired to a dedicated slave's SS pin. The logic state of such pins only affects the connected slaves, not the controller's own SPI interface.