dotnet / iot

This repo includes .NET Core implementations for various IoT boards, chips, displays and PCBs.
MIT License
2.12k stars 574 forks source link

Add support for SPI devices that use separate GPIO outputs for Data/Command and Reset #2317

Closed AdamJSchofield closed 1 month ago

AdamJSchofield commented 1 month ago

I am looking to add support for a new SSD1309 device that shares a lot of functionality with the other SSD13xx devices. However, the existing implementations only use I2C and a "control byte" for Data/Command switching.

I would like to extend the SSD13xx implementation to support SPI with additional GPIO pins for controlling DC and RST. Ideally these pins would be specified via Board.CreateSpiDevice or SpiConnectionSettings.

The device I am using: https://www.waveshare.com/1.51inch-transparent-oled.htm SSD1309 Datasheet: https://www.crystalfontz.com/controllers/datasheet-viewer.php?id=342 WIP PR: https://github.com/dotnet/iot/pull/2316

Even with hacky work-arounds I have been unable to get this device working. I have validated my device and pin configuration with examples from the Luma.OLED and have some other work in progress to port over as much as I can from there to have a working baseline.

I'm looking to start some conversation about what an implementation like this may entail. Is it too specific to be supported by the lower-level SpiDevice? Is bit-banging support a possibility? I'm also interested in opinions on temporary work arounds involving interop with working python code (unrelated to this project I suppose).

AdamJSchofield commented 1 month ago

And I'll add a full disclosure that I am fairly inexperienced with IoT things in general but I have spent several days in the weeds on this so I'm fairly comfortable with the basics of SPI. But for example, I just learned the difference between hardware/software SPI. I suspect that my device doesn't use hardware SPI and using software SPI may resolve some of the issues with my demo project.

joperezr commented 1 month ago

Hey @AdamJSchofield, thank you so much for your contribution 😃. I noticed you already sent out a PR, we'll take a look soon to be able to get it in.

AdamJSchofield commented 1 month ago

@joperezr Thanks for taking a look! As I mentioned on the draft PR, I've worked out some issues and am just polishing up my branch for review. I will probably close this issue now that I've got things figured out and keep discussion on the PR. Unless you prefer an issue for every PR.

AdamJSchofield commented 1 month ago

Closing because I've worked through most of the issues I was having. Will mark the PR as ready for review in the next few days.