Skip to content

Commit 7c33efc

Browse files
committed
fix SPI run on system clock
1 parent 51b1daf commit 7c33efc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

libraries/SPI/SPI.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ void SPIClass::begin() {
4343
pinMode(MISO, SPECIAL); ///< GPIO12
4444
pinMode(MOSI, SPECIAL); ///< GPIO13
4545

46-
GPMUX = 0x105; // note crash if SPI flash Frequency < 40MHz
4746
SPI1C = 0;
4847
setFrequency(1000000); ///< 1MHz
4948
SPI1U = SPIUMOSI | SPIUDUPLEX | SPIUSSE;
@@ -187,6 +186,11 @@ void SPIClass::setFrequency(uint32_t freq) {
187186
}
188187

189188
void SPIClass::setClockDivider(uint32_t clockDiv) {
189+
if(clockDiv == 0x80000000) {
190+
GPMUX |= (1 << 9); // Set bit 9 if sysclock required
191+
} else {
192+
GPMUX &= ~(1 << 9);
193+
}
190194
SPI1CLK = clockDiv;
191195
}
192196

0 commit comments

Comments
 (0)