Support ESP8266 core 2.5.1

pull/83/head
Hieromon Ikasamo 6 years ago
parent 2143b0f2f8
commit 45107226bf
  1. 7
      src/AutoConnectDefs.h
  2. 11
      src/AutoConnectUploadImpl.h

@ -135,6 +135,9 @@
// SD pin assignment for AutoConnectFile
#ifndef AUTOCONNECT_SD_CS
#if defined(ARDUINO_ARCH_ESP8266)
#ifndef SD_CHIP_SELECT_PIN
#define SD_CHIP_SELECT_PIN SS
#endif
#define AUTOCONNECT_SD_CS SD_CHIP_SELECT_PIN
#elif defined(ARDUINO_ARCH_ESP32)
#define AUTOCONNECT_SD_CS SS
@ -143,11 +146,7 @@
// SPI transfer speed for SD
#ifndef AUTOCONNECT_SD_SPEED
#if defined(ARDUINO_ARCH_ESP8266)
#define AUTOCONNECT_SD_SPEED SPI_HALF_SPEED
#elif defined(ARDUINO_ARCH_ESP32)
#define AUTOCONNECT_SD_SPEED 4000000
#endif
#endif // !AUTOCONNECT_SD_SPEED
// ArduinoJson buffer size

@ -102,6 +102,15 @@ class AutoConnectUploadFS : public AutoConnectUploadHandler {
SPIFileT _file;
};
// Fix to be compatibility with backward for ESP8266 core 2.5.1 or later
#ifdef ARDUINO_ARCH_ESP8266
#if defined(SD_SCK_HZ)
#define AC_SD_SPEED(s) SD_SCK_HZ(s)
#else
#define AC_SD_SPPED(s) s
#endif
#endif
// Default handler for uploading to the standard SD class embedded in the core.
class AutoConnectUploadSD : public AutoConnectUploadHandler {
public:
@ -111,7 +120,7 @@ class AutoConnectUploadSD : public AutoConnectUploadHandler {
protected:
bool _open(const char* filename, const char* mode) override {
#if defined(ARDUINO_ARCH_ESP8266)
if (_media->begin(_cs, _speed)) {
if (_media->begin(_cs, AC_SD_SPEED(_speed))) {
uint8_t oflag = *mode == 'w' ? FILE_WRITE : FILE_READ;
#elif defined(ARDUINO_ARCH_ESP32)
if (_media->begin(_cs, SPI, _speed)) {

Loading…
Cancel
Save