Are these hardwired in some way?
Can I assign any digital pins for these uses?
How do I declare these assignments in my Arduino code?
What about the six pins at the right of the PCB (in the illustration)? Can I use those (although I notice there is no SS pin there)?
In short, can I, and how do I, assign other pins for SPI?
vagulus:
In short, can I, and how do I, assign other pins for SPI?
I think not, and much more to the point would be your explanation as to why you would want to do that.
The ICSP cluster is simply an alternative set of the same pins. It is common to both Uno and Mega, while pins 11,13 are not SPI on Mega. SS is not part of the ISP bus. Pin 10 is just a common and obvious choice.
Some devices have software SPI , but that doesn't mean you get to change Arduino's hardware SPI.
vagulus:
What is SS then? The graphic in the initial post labels it something to do with SPI.
The SPI Bus proper consists of SPCLK, MOSI, and MISO. They operate at the SPI bit rate (multiple Mbits / sec) and typically require specialized hardware within the processor -- or, performance-sucking bit bang software SPI. That's why you can't reassign their pins willy-nilly. SS (aka CS) is only required to select the intended slave on the bus -- if there is more than one. It can be a relatively low speed GPIO because it just needs to be asserted before the SPI transaction and de-asserted after. With the Arduino SPI library, SS is handled by the user's code or by a library that uses the SPI library.
In response to 'I can do the something else on other pins' Nick wrote,
Nick_Pyner:
That sounds like a really good idea.
Well, it gets curiouser! :o
The something else is code to drive a 128x64 OLED display with is a PCB (breakout) set up for SPI communication using u8g2lib.h. This is the declaration which instantiates the OLED communication
/* Create instance of library used to communicate with the OLED. */
/* This configuration for remoteWeatherStation-PRX */
U8G2_SSD1325_NHD_128X64_1_4W_SW_SPI u8g2(
/* rotation zero */ U8G2_R0,
/* clock=*/ 7,
/* data=*/ 6,
/* cs=*/ 5,
/* dc=*/ 4,
/* reset=*/ 3);
You can see that I have assigned pins (other that 9-13) to those nice SPI tasks. This works! Clock, data, cs and dc are working from pins other that the Arduino standard pins!
vagulus:
You can see that I have assigned pins (other that 9-13) to those nice SPI tasks. This works! Clock, data, cs and dc are working from pins other that the Arduino standard pins!
How does that happen?
As has been mentioned more than once in this thread, you can run a software version of SPI (slower) on just about any of the pins.