1
0
Fork 0

Adafruit BLE: Set SPI2X bit only when F_CPU is 8MHz (#6671)

This commit is contained in:
fauxpark 2019-09-08 01:18:05 +10:00 committed by Drashna Jaelre
parent 91bd2117df
commit 0d94730da0

View file

@ -151,9 +151,10 @@ static struct SPI_Settings spi;
// Initialize 4Mhz MSBFIRST MODE0 // Initialize 4Mhz MSBFIRST MODE0
void SPI_init(struct SPI_Settings *spi) { void SPI_init(struct SPI_Settings *spi) {
spi->spcr = _BV(SPE) | _BV(MSTR); spi->spcr = _BV(SPE) | _BV(MSTR);
#if F_CPU == 8000000
// For MCUs running at 8MHz (such as Feather 32U4, or 3.3V Pro Micros) we set the SPI doublespeed bit
spi->spsr = _BV(SPI2X); spi->spsr = _BV(SPI2X);
#endif
static_assert(SpiBusSpeed == F_CPU / 2, "hard coded at 4Mhz");
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
// Ensure that SS is OUTPUT High // Ensure that SS is OUTPUT High