Skip to content
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

Broadcom Pin 21/27 : Wrong number on Raspberry Pi B+ #1

Open
Aichan opened this issue Apr 22, 2015 · 4 comments
Open

Broadcom Pin 21/27 : Wrong number on Raspberry Pi B+ #1

Aichan opened this issue Apr 22, 2015 · 4 comments
Labels

Comments

@Aichan
Copy link

Aichan commented Apr 22, 2015

When using PiSharp, "Physical pin 13" is refered to "Broadcom Pin 21" which doesn't work on my Raspberry Pi B+

I don't know why but it seems that this Pin has two broadcom number, and in my case it was the number "27" so I had to edit your code and change line 45 of Entities/BroadcomPinNumbers.cs

I don't know much about it but maybe it's related to the model

@andycb andycb added the bug label Apr 23, 2015
@andycb
Copy link
Owner

andycb commented Apr 23, 2015

Hi,

Thanks for reporting this.

You're right, Physical 13 was Broadcom 21 on the Revision 1 Pi B boards, but on A, B+, Pi 2 B and Revision 2 B boards it became 27.

There's a handy diagram here: http://1.bp.blogspot.com/-SRF0TOvP2xo/VIKNV_Yk1hI/AAAAAAAAVMk/EJW1gPAZrc4/s1600/Raspberry-Pi-AllModelGPIO-pinouts.png

I'll need to figure out a way of handling this in the library, but in the meantime you're best either editing the code as you have done (Note that this way, your code will not have portability onto rev1 boards), or adding support for BroadcomPinNumbers.TwentySeven and using that

Ideally, this could be picke up as part of supporting the expanded GPIO header of the newer boards (The rev1 boards didn't have a Broad 27 output)

I'm more than happy to merge pull requests if you wish to fix this in your fork :)

Sorry I've never noticed this before,
Andy

@Aichan
Copy link
Author

Aichan commented Apr 23, 2015

I don't know much about the old B Rev 1.0 so I'll need more info about it, like can you use GPIO 14 and 15 for general purpose like I can do in the B+ or is it only uart specific?

@andycb
Copy link
Owner

andycb commented Apr 23, 2015

I believe that on all models. GPIO 14 and 15 are usable as GPIO, but do not default as inputs unless they are explicitly exported. As Pi# requires all pins to be explicitly exported before use, they should be usable.

@paulgittings
Copy link

Here's a link to some code which works out some of the details of what version of Pi the code is running on, including revision. http://sourceforge.net/p/raspberry-gpio-python/code/ci/default/tree/source/cpuinfo.c

It's in C but should be easy to port to C#.

As well as exposing this info in the PiSharp library you could include checks in PiSharp so that an exception is thrown when an attempt is made to access a GPIO pin that is not supported by the current revsion (eg, gpio27 on revision 1, gpio21 on revision 2)

Cheers,
Paul

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

No branches or pull requests

3 participants