-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[Enhancement] Make Wire and SPI lib compatible between ESP32 and ESP8266 #3691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I agree :) We could also add Wire::pins(sda, scl) to ESP32 ;) |
Since we're discussing compatibility and api, do we want to consider #2677 here? |
As a library author I fully agree that the API fuctions for SPI and Wire should be the same to avoid ifdefs. |
Same for the file system api's for SD, FS, SDFAT libraries... |
FS compatibility is not that simple to do ;) ESP32 follows Arduino's SD API and SPIFFS on ESP8266 uses a different API from the rest. Changing either will bring more issues than anything. |
I personally would be happy if at least ESP32 and ESP8266 extensions for SPI and Wire libs are compatible. |
Uh oh!
There was an error while loading. Please reload this page.
Basic Infos
This is a feature extension request to make the ESP32 and ESP8266 library compatible with each other.
From my analysis i would suggest to modify ESP8266 library and align with ESP32 library. However other modifications are also thinkable. For more specific suggestions, see below.
Discussion reference:
olikraus/u8g2#377
olikraus/u8g2#378
Hardware
Hardware: n.a.
Core Version: head
Description
Problem description
Assigning movable pins for ESP32 and ESP8266 differs between the projects.
Settings in IDE
n.a.
Sketch
n.a.
Debug Messages
n.a.
Analysis of the Problem
SPI Lib ESP8266:
Link: https://github.com/esp8266/Arduino/blob/master/libraries/SPI/SPI.h#L56
Uses "pins" member function to assign movable pins:
pins(int8_t sck, int8_t miso, int8_t mosi, int8_t ss);
Note, that ss and mosi are required areguments
SPI Lib ESP32:
Link: https://github.com/espressif/arduino-esp32/blob/master/libraries/SPI/src/SPI.h#L55
The begin() member function accepts several (optional) arguments for
the assignment of the pin numbers:
"void begin(int8_t sck=SCK, int8_t miso=MISO, int8_t mosi=MOSI, int8_t ss=-1);"
Wire Lib ESP8266
Link: https://github.com/esp8266/Arduino/blob/master/libraries/Wire/Wire.h#L53
Has a "pins" member function which is declared as deprecated.
"pins(int sda, int scl)"
Instead use "begin(int sda, int scl);"
Wire Lib ESP32
Link: https://github.com/espressif/arduino-esp32/blob/master/libraries/Wire/src/Wire.h#L55
The ESP32 Wire lib extends the begin() member function with optional pin
arguments and also a frequency paramenter:
"void begin(int sda=-1, int scl=-1, uint32_t frequency=100000);"
Conclusion
sure whether they are documented)
an extra frequency parameter and scl line is optional, this means you can specify "begin(X)"
to move the sd line to pin X, which is not possible on ESP8266.
approach in SPI lib of ESP8266 does not seem to fit.
Suggestions for modification
ESP8266 and ESP32 should agree on common code regarding the extension
for movable pins for SPI and Wire functionality.
From seeing the above differences my suggestion is to modify the ESP8266 project
to make it compatible to the ESP32 project:
The text was updated successfully, but these errors were encountered: