-
Notifications
You must be signed in to change notification settings - Fork 35
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
bcm283x (or new pkg): support alternate functions of the bcm2711 #24
Comments
The mapping is intentionally a private variable. Duplicate it, and chose the right table based on the CPU. Better than trying to make one table address both configurations. Something like:
It's just simpler for everyone IMO. |
The BCM2711 provides more alternate pin functions than the BCM283x. An extra mapping table mapping2711 is added by this change, which gets assigned to the `mapping` variable conditionally during driverGPIO.Init(). The existing mapping is renamed to mapping283x, and used as default to keep tests working. This change enables selecting alternate functions at runtime on a BCM2711 that were not supported by the existing BCM283x specific mapping, like GPIO4's UART3_TX; toggling between UART_TX and IN at runtime can be useful e.g. when sharing a single CAN transceiver between a CAN controller and a UART peripheral. Resolves periph#24
Thanks for suggesting to create a second table. I have tried to implement that approach in the commit linked above. |
Please send as a PR, it's hard for me to visualize the end result. Thanks. |
The BCM2711 provides more alternate pin functions than the BCM283x. An extra mapping table mapping2711 is added by this change, which gets assigned to the `mapping` variable conditionally during driverGPIO.Init(). The existing mapping is renamed to mapping283x, and used as default to keep tests working. This change enables selecting alternate functions at runtime on a BCM2711 that were not supported by the existing BCM283x specific mapping, like GPIO4's UART3_TX; toggling between UART_TX and IN at runtime can be useful e.g. when sharing a single CAN transceiver between a CAN controller and a UART peripheral. Resolves #24
In an RPi 4 project I needed to switch pin functions of GPIO4/5 at runtime between the Input function and the ALT4 alternate function TXD3/RXD3.
While
rpi
andbcm283x
packages mostly appear to work fine on an RPi 4 regarding GPIO functionality, the RPi 4, which is based on the bcm2711, provides quite some more alternate functions that are not covered by the mapping table in bcm283x/gpio.c.As a workaround, I simply added entries for UART3_TX and UART3_RX to that table:
What would be an appropriate way to add the more extensive settings for the bcm2711?
Alternate function tables of bcm2835 and bcm2711 suggest that the bcm2711 is mostly compatible, an extension, to the bcm2835 in this regard. So the
mapping
table could just be extended to contain the additional functions of the bcm2711. The problem with this approach is that the table then would be misleading for users of RPis smaller than 4, as it would contain alternate functions that are not available on the bcm2835. Code callingrpi.P1_7.(pin.PinFunc).SetFunc("UART_TX")
would not work as expected when running it on an RPi 3.Perhaps an approach could be to extend mapping table entries by a prefix, like in the following example:
... with prefixes
bcm2711:
or+
meaning available only on the bcm2711 resp. extended MCUs.Depending on a package
bcm283x
global variable, configured duringhost.Init()
, the additional alt functions then would be available, or not.(Additional code would be needed to strip the prefix within
bcm283x/gpio.go
where needed)Do you see another approach that you would prefer?
The text was updated successfully, but these errors were encountered: