This is a little broken - the passed in needs shifting before setting to SPSR
Add this definition: #define SPI_2XCLOCK_SHIFT 2 // amount to shift for SPSR
and change this to:
void SPIClass::setClockDivider(uint8_t rate)
{
SPCR = (SPCR & ~SPI_CLOCK_MASK) | (rate & SPI_CLOCK_MASK);
SPSR = (SPSR & ~SPI_2XCLOCK_MASK) | ((rate >> SPI_2XCLOCK_SHIFT) & SPI_2XCLOCK_MASK);
}
Broken code is like a broken car. All it takes is experience to be able to repair it. Some repairs are easier than others. Some are cheaper than others.