stianeikeland / go-rpio

:electric_plug: Raspberry Pi GPIO library for go-lang
MIT License
2.2k stars 221 forks source link

Feature/SPI #31

Closed drahoslove closed 6 years ago

drahoslove commented 6 years ago

Hi, I implemented basic SPI functionality.

(I originally wanted to first start a discussion about API and implementation details first, but after writing long, long text in new issue form I accidentally hit back button and lost the text :man_facepalming:. So I decided to just implement it. But we can still run discussion here.)

Summary of what I have done:

(i will be referencing BCM2835-ARM-Peripherals.pdf)

API

setup/teardown

issues

I only have resources now to test MOSI transfer, but not MISO - only have a ouptup-only device. So if somebody with some "readable" slave SPI chip could test the recieving functionality, that would be great.

stianeikeland commented 6 years ago

Hey, this looks great! I'll have a look through my parts drawer and see if I can find some device that require MISO.

drahoslove commented 6 years ago

Hi, have you managed to find something in your drawer? It would be great to merge this.

stianeikeland commented 6 years ago

Hey man! Had some time to play with it tonight. Turns out that most of the devices I hoped were SPI was in fact I2C, however I was able to test:

I had a winbond 16M SPI flash laying around that I tried to use for a write/read test, but I was unable to get the chip to work. Hard to figure out why, possible reasons range from broken chip to maybe I didn't have proper contact on one of the pins (SOIC package in a clamp), or maybe I was using it wrong.

While I couldn't make the SPI flash work, maybe the loopback test + matrix is good enough to ship the code for now?

And maybe we can order up some cheap two way SPI devices from ebay, something that doesn't require tons of setup before you can finally start reading and writing some data.

drahoslove commented 6 years ago

Great you managed to test something :+1:. I think you can ship it and let potential users test the rest :wink:.

Can you adress the issue https://github.com/stianeikeland/go-rpio/issues/27 when you'll be creating new release?

Also since I'm the ~contributor~ collaborator now. Should I create future contributions in new branches of this repo rather than in my fork?