What i'm after:
Arduino Mega as: SPI - MASTER
Arduino Yun as: SPI - SLAVE
Why I'm having a problem with this:
The Arduino Leonardo and Yun boards share the same ATmega32u4 mc. So I figured if I could find a solution for the Leonardo, then I may have found a solution for the Yun.
As you can see here:
For the Leonardo (and also the Yun), the pins on the ICSP header are not connected to any of the digital I/O pins. They are only available on the ICSP connector. They seem to lack any hardware SS pin.
The big question: Given there is no SS pin listed for the Leonardo (or Yun), how would one go about making it an SPI slave-device?
"The (Yun's mc) SPI pins are also connected to the AR9331 gpio pins, where it has been implemented in software the SPI interface. This means that the ATMega32u4 and the AR9331 can also communicate using the SPI protocol."
Does this mean the Yun is destined to be an SPI MASTER, and that casting it as a SLAVE would mean losing control of AR9331 ?
I'm thinking (If it's not possible to have the Arduino Yun acting as an SPI SLAVE) that I would have to perform a role-reversal:
Arduino Yun : SPI MASTER
Arduino Mega: SPI SLAVE
I could then have the slave send data whenever the master pings-it (just sends a "0").
So: the Yun would ping the Mega, and the Mega would be sending back data during each ping.
The only 2 things that are not-so ideal about this role-reversal setup is:
that the Mega is performing most of my calculations and communications w/ wireless modules... I'd hate to have an SPI interrupt throw off anything.
the Mega is now losing the ability for future SPI control (no longer the Master), which may not be a problem after all.
So even though I would prefer the Mega be the MASTER and the YUN be the slave, it seems that's not possible (?).
"The (Yun's mc) SPI pins are also connected to the AR9331 gpio pins, where it has been implemented in software the SPI interface. This means that the ATMega32u4 and the AR9331 can also communicate using the SPI protocol."
An important detail is missing in this sentence: The SPI pins are not directly connected but by a logic level converter chip.
Does this mean the Yun is destined to be an SPI MASTER, and that casting it as a SLAVE would mean losing control of AR9331 ?
As far as I know that SPI connection between the two processors is not used currently. The Bridge library uses only the UART connection between the two. And even if it would be used this doesn't imply that the ATmega32U4 must be the master and the AR9331 the slave. Usually the more powerful chip controls the bus and in this constellation the ATmega is the more flexible of the two. Implementing a slave interface in software is much more difficult than to do the same as a master.
So even though I would prefer the Mega be the MASTER and the YUN be the slave, it seems that's not possible (?).
At the moment the only problem I see is that the SS pin is not easily available on the Yun. You may be able to get it at the level converter but in any case it a quite difficult soldering work.