Sharing SPI (WAV Shield + MEGA +WiFly) - WiFly/WAV cable select pins

Almost there...I have the WAV shield working with the new pin reassignment...But I'm having issues switching between shields.

I edited "ArduinoPins.h" in the WAVHC library to change the SS_PIN from 53 to 33

// SPI port
// **SJ #define SS_PIN 53
#define SS_PIN 33 //<---changing this from 53 to 33 so I can use the WiFly shield
#define MOSI_PIN 51
#define MISO_PIN 50
#define SCK_PIN 52

Snippet from my app to toggle between shields:

#define SSWAV 33 //cable select pin for WAV shield
#define SSWIFLY 53 //cable select pin for WIFLY shield


//this enables the cable selection pin for WiFly shield
void enableWiFlyShield()
{
  digitalWrite(SSWIFLY, LOW);
  digitalWrite(SSWAV, HIGH);
}

//this enables the cable selection pin for WAV shield
void enableWAVShield()
{
  digitalWrite(SSWIFLY, HIGH);
  digitalWrite(SSWAV, LOW);
}

On init of my app I can call either enableWiFlyShield() or enableWAVShield() and run the respective shield fine....

BUT if I run the WiFly shield first, then at run time toggle the WAV shield....I get read errs from the WAV shield's SD card: "Couldn't open file mytestsound.wav" The SD card reader on the WAV shield used the SPI...So I'm thinking it a cable select issue? Either the WiFly css pin isn't being disabled properly and hogging the SPI or the WAV css pin isn't being enable properly?

Here's a picture of my board setup and specs to give you a better idea what I'm working with:

  • Arduino MEGA 2560
  • WiFly Shield
  • SpeakJet Shield
  • Adafruit WAV Shield

Anyone have suggestions on how to debug this? My pins modifications to the WAVHC library seem to be fine, because all the WAV shield examples work and I can run my app with just the WAV shield alone. The problem seems to be initializing the WiFly shield first....