Skip to content
This repository has been archived by the owner on Sep 30, 2019. It is now read-only.

High level API for SPI? #1

Closed
riklaunim opened this issue Jun 11, 2014 · 1 comment
Closed

High level API for SPI? #1

riklaunim opened this issue Jun 11, 2014 · 1 comment

Comments

@riklaunim
Copy link

Are you planning wrapping the SPI interfaces into some high level one so that it would be easier to switch between backends?

Like when I swapped Raspberry SPI to pyMCU SPI in max7219 library: riklaunim/max7219@0aa4c47#diff-0ba4e19a70b47820e42736807850fdf9 there weren't any bigger changes so it ought to be doable in some cases.

@tdicola
Copy link
Contributor

tdicola commented Jun 12, 2014

Good question--I made the bit bang SPI and spidev SPI implementation have the same functions like set_clock_hz, set_mode, read, write, transfer, etc. so it should be possible to swap code that uses one interface to use the other. There are a few small differences in functionality, like the bitbang interface ignoring clock speed and also being a little more flexible (i.e. can choose to assert or deassert CS on SPI read/write/transfer) but my goal was to not make any major differences that would preclude changing out one implementation for the other (other than the fact that software SPI is really slow).

I didn't make them inherit from a common base class just because it seemed like a little overkill and I didn't think there would be a ton of other implementations. I'm not against having them inherit from a common base though.

Does that help answer your question? Thanks for checking out the library BTW. I'm open for feedback on extending it for more folks to use. I'm hoping to add more functionality like I2C, support for other boards GPIO, etc. over time.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants