SPI Library (0019) SPI.setClockDivider()

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);
}

Otherwise, works great. :slight_smile:

This is a little broken

Is that like being a little bit pregnant? Either it's broken or it isn't. There are not degrees of brokenness.

I do like the phrase " a little bit broken" :slight_smile: It would mean: It's easy to fix ;D

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.

But, broken is broken.

There are situations where I am tempted to say:

  • It's a little bit weird.
  • It's a little funny.
  • It's a little dangerious.
    _ It's a kind of green.
  • It's a sort of English.
  • I feel a little bit lonely.

Of course you could can argue that broken, pregnant, dead belong to another category (the "digital" one)