Skip to content

Adding SPI specific documentation for Raspberry Pi#1197

Merged
Ellerbach merged 4 commits intodotnet:masterfrom
Ellerbach:addspirpidoc
Oct 9, 2020
Merged

Adding SPI specific documentation for Raspberry Pi#1197
Ellerbach merged 4 commits intodotnet:masterfrom
Ellerbach:addspirpidoc

Conversation

@Ellerbach
Copy link
Member

Adding SPI specific documentation for Raspberry Pi

sudo reboot
```

This will enable SP0 where those are the pins which will be seleted, only Software Chip Select is activated with the default pins:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this. Cost me a few hours to find out why hardware CS wasn't working...

Maybe add a sentence about the difference between hw and software cs? This isn't clear from this text.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that now there is no difference, once set it is by default activated. The hardware dtoverlay is depreciated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean "software" as in "do it yourself". I've seen quite a few examples (don't remember where, though), where the CS pin is manually controlled directly in the application.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, just using dtparam=spi=on will not activate any CS pin, you need to do it yourself (by manyually controlling the pin that is connected to the CS input line of the attached chip). My finding with adding dtoverlay=spi0-hw-cs will change the ALT setting to the one described in the manual and use that pin.
So with your suggestion, we have actually three different possibilities for the CS pin: None, hardware and "driver controlled gpio".
Can you check what "gpio readall" reports for i.e. pin 27 when your line dtoverlay=spi0-2cs,cs0_pin=27,cs1_pin=22 is used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that now you choose the pins you want, reason why the dtoverlay)spi0-hw-cs is deprecated. Also gpio is not available anymore. See the note from the WiringPi author: http://wiringpi.com/wiringpi-deprecated/
It seems, reading the doc, that dtparam=spio=onwill activate both default pins as Chip Select. Reason why I linked to the latest doc. Now, for previous versions, it seems it was not the case.
If you have any working alternative for gpio readall, happy to try!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, at least the spi0-hw-cs works... I'll need to redo my SPL tests when I find time - last time I tried (when I wrote that issue) dtparam=spi=on would definitelly not activate any CS pins.

The latest version of WiringPi, 2.52, does work on the Pi4 (and is very helpful in analyzing pin multiplexing behavior). However you need to download it from the website, it's not available via apt.

With #1128 in place, we would be able to extend the DeviceApiTester tool to completelly replace gpio.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fully support a board abstract. We discussed it with @krwq. With all the request to support various baords, we need anyway a HAL/PAL approach.
I can try to clone the #1128 and see what I get!

| SPI0 | CE1 | 26 | GPIO07 | SPI0_CE1_N |


If you want to change the default pins for Chip Select 0 to the GPIO pin 27 (hardware 13), and let's say GPIO pin 22 (hardware 15) for Chip Select 1, just add this line:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you can use any pin for hardware CS? The "alternate pin mode" table suggests that these are fixed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table is the default configuration. Advance configuration is what I describe. So seems it is not super clear. How would you rephrase then?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above - I think we're talking about three different ways here. I'll have to think about how to describe this in an understandable and clear way.

sudo reboot
```

This will enable SP0 where those are the pins which will be seleted, only Software Chip Select is activated with the default pins:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This will enable SP0 where those are the pins which will be seleted, only Software Chip Select is activated with the default pins:
This will enable SPI0 where those are the pins which will be selevted, only Software Chip Select is activated with the default pins:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"selected" is still spelled incorrectly ;-)

Copy link
Member

@krwq krwq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple of typos but otherwise looks good to me, thank you!

Ellerbach and others added 2 commits October 8, 2020 12:36
Co-authored-by: Krzysztof Wicher <mordotymoja@gmail.com>
Co-authored-by: Krzysztof Wicher <mordotymoja@gmail.com>
@Ellerbach Ellerbach merged commit 3e1c532 into dotnet:master Oct 9, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants