1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-17 22:23:10 +03:00

fix SPI run on system clock

This commit is contained in:
Markus Sattler
2015-05-08 15:27:32 +02:00
parent afdc5f1c84
commit db64fd9f98
2 changed files with 6 additions and 2 deletions

View File

@ -43,7 +43,6 @@ void SPIClass::begin() {
pinMode(MISO, SPECIAL); ///< GPIO12 pinMode(MISO, SPECIAL); ///< GPIO12
pinMode(MOSI, SPECIAL); ///< GPIO13 pinMode(MOSI, SPECIAL); ///< GPIO13
GPMUX = 0x105; // note crash if SPI flash Frequency < 40MHz
SPI1C = 0; SPI1C = 0;
setFrequency(1000000); ///< 1MHz setFrequency(1000000); ///< 1MHz
SPI1U = SPIUMOSI | SPIUDUPLEX | SPIUSSE; SPI1U = SPIUMOSI | SPIUDUPLEX | SPIUSSE;
@ -187,6 +186,11 @@ void SPIClass::setFrequency(uint32_t freq) {
} }
void SPIClass::setClockDivider(uint32_t clockDiv) { void SPIClass::setClockDivider(uint32_t clockDiv) {
if(clockDiv == 0x80000000) {
GPMUX |= (1 << 9); // Set bit 9 if sysclock required
} else {
GPMUX &= ~(1 << 9);
}
SPI1CLK = clockDiv; SPI1CLK = clockDiv;
} }

View File

@ -153,7 +153,7 @@ void Adafruit_ILI9341::writedata(uint8_t c) {
static inline void spi_begin(void) __attribute__((always_inline)); static inline void spi_begin(void) __attribute__((always_inline));
static inline void spi_begin(void) { static inline void spi_begin(void) {
#ifdef ESP8266 #ifdef ESP8266
SPI.beginTransaction(SPISettings(40000000, MSBFIRST, SPI_MODE0)); SPI.beginTransaction(SPISettings(80000000, MSBFIRST, SPI_MODE0));
#else #else
SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0)); SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));
#endif #endif