SS pin on Arduino for CC1101


SS pin is controlled by SPI bus for SPI transactions. However CC1101 library uses the SS pin explicitly. How is it that it does not conflict with SPI bus operation?

A code fragment from the CC1101 library

// Select CC1101
#define cc1101_Select()  digitalWrite(SS, LOW)

// Deselect (SPI) CC1101
#define cc1101_Deselect()  digitalWrite(SS, HIGH)

// Wait until SPI MISO line goes low
#define wait_Miso()  while(digitalRead(MISO)>0)

void CC1101::wakeUp(void)
  cc1101_Select();                      // Select CC1101
  wait_Miso();                          // Wait until MISO goes low
  cc1101_Deselect();                    // Deselect CC1101


The Arduino SPI reference page has a good explanation:

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.

So the SS pin on the Arduino board (which is the SPI master in this case) is simply being used as CS (chip select) for the CC1101, which is the SPI slave. You could use any pin on the Arduino board for this. However, since the use of SPI already puts limitations on the Arduino board's SS pin, it's convenient to use it for CS.

SS pin is controlled by SPI bus for SPI transactions.

At least on the AVR platform this is true only for the slave mode. In master mode the programmer is responsible to set the SS/CS pin correctly.