CaptainJack:
Rob,it's a lovely rewrite. It does seem I get into an endless loop. After entering the ISR for the first time it doesn't get out, tested with div64. However, I can't see the error. It's hanging on the lines while ( (PIND & B00100000) == 0) ;, if I comment them the ISR runs. I just don't see why the ISR would stay in that while loop.
Jack
the blocking endless loop can be fixed by extending the inner conditions. Please try
void _isrd2()
{
flag = 0;
byte bn = 1;
while (~PIND & B00000100) // while SS is LOW (PD2)
{
while ((PIND & B00100000) == 0 && ~PIND & B00000100) ; // wait for CLOCK HIGH
if (PIND & B01000000) // if Data HIGH (PD6)
{
rec += bn; // add 1 bit
}
bn = bn << 1; // shift to the next bit to receive
while ((PIND & B00100000) == B00100000 && ~PIND & B00000100 ); // wait for CLOCK LOW
}
flag = rec;
}