-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
Revisions to SPI classes #2130
Revisions to SPI classes #2130
Conversation
39d1aa3
to
7f0f182
Compare
7f0f182
to
3921dcd
Compare
Just bought one of these LILYGO ESP32 watches. Hope to be able to run Sming on it soon :-) |
Re. #2171 (comment) I'll get this PR tested so we can merge it, then start on updating the As for the Esp32 Arduino SPI interface I'm not sure what to do about that. Looking at the Esp32 arduino code it does the same thing as the Esp8266 stuff and just mucks about with hardware registers directly. It's generally a poor model (I don't use it). |
@mikee47 Do you think you can add also I2C support for ESP32? |
@slaff I'll certainly take a look at I2C at some point. Hardware support for I2C on ESP32 warrants a separate HardwareI2C library, even more important to make that asynchronous given the slow bus speeds. |
3921dcd
to
b89768a
Compare
@mikee47 what is the status of this PR? Did you have a chance to test it on Esp32 device? |
@slaff Works fine on ESP8266, ESP32 is WIP |
b89768a
to
c233449
Compare
a092adb
to
00eaef3
Compare
@slaff OK ready for review/testing. |
@kmihaylov can you try using this PR and one or two of your devices that use SPI? |
1bab882
to
2216941
Compare
Wow too much activity on the SPI class. Should I wait a bit or give it a go? |
@kmihaylov Go for it. Please test both ESP8266 and ESP32. |
Also remove extraneous debug statement in setClock() Change 'lenght' -> 'length'
SPISettings passed by reference. SPIClass no longer keeps a copy of these, no point. Clock register value is pre-calculated and stored in settings. Code simplified for readability. bugfix: exception (division by zero) raised in some cases, e.g. freq = 27M. BeginTransaction() and prepare() just set up registers anyway as there is now minimal overhead in doing this. Duplicate method comment blocks removed, should only be in header.
Get rid of redundant/duplicate comments Don't repeat method name in brief Use cstdint types
…code Clock has to be recalculated on every call. With non-const version, it is cached.
2216941
to
ad28f70
Compare
Refactor, tidy and implement SPIClass for ESP32.
External interfaces haven't changed but internal ones have.
Tested with
ScreenTFT_ILI9340-ILI9341
,SDCard
andRadio_nRF24L01
samples.bugfix: correct CPU multipler, should be 1M (was 10M)
Naming / comments / style
SPI code revisions to simplify and improve performance
Implement SPIClass for Esp32
Has three available SPI modules:
SPIClass(SpiBus::HSPI, SpiPins{18, 19, 23})
). Suspect involvement with RTC/IO but as yet unable to pin this down.