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
Ethernet GPIO config #2616
Merged
Merged
Ethernet GPIO config #2616
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
technobly
force-pushed
the
feature/sc-105146-ethernet-gpio-config
branch
from
February 2, 2023 06:19
c18f9d5
to
d7c54bb
Compare
scott-brust
reviewed
Feb 3, 2023
XuGuohui
reviewed
Feb 3, 2023
XuGuohui
reviewed
Feb 3, 2023
XuGuohui
reviewed
Feb 3, 2023
XuGuohui
reviewed
Feb 3, 2023
XuGuohui
reviewed
Feb 3, 2023
XuGuohui
reviewed
Feb 3, 2023
XuGuohui
reviewed
Feb 3, 2023
XuGuohui
reviewed
Feb 3, 2023
XuGuohui
reviewed
Feb 3, 2023
XuGuohui
reviewed
Feb 3, 2023
XuGuohui
reviewed
Feb 3, 2023
avtolstoy
reviewed
Feb 3, 2023
technobly
force-pushed
the
feature/sc-105146-ethernet-gpio-config
branch
from
February 9, 2023 06:27
d7c54bb
to
dbc170c
Compare
avtolstoy
approved these changes
Feb 9, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Devices that support the WizNet Ethernet controller have 3 hard coded GPIO pins in system firmware that collide with SPI1 usage. If a user wants to use Ethernet which requires SPI and D3, D4 and D5 to be reserved on Argon/Boron/P2/Photon2/TrackerM for example. If they also need to use hardware SPI1 for some other peripheral, they cannot.
Solution
System.enableFeature(FEATURE_ETHERNET_DETECTION)
must be used, and if Ethernet is detected,Ethernet.isOn()
will returntrue
. If the system boots with FEATURE_ETHERNET_DETECTION disabled (default), the Ethernet API's will not work andEthernet.isOn()
will returnfalse
, which can be used to set the correct pin configuration, enabled FEATURE_ETHERNET_DETECTION and reset the system. Upon successive boots the Ethernet controller will be found and pin config and reset will not need to be called again. NOTE: ensure the device does not get caught up in a reset loop with aretained
variable, or some other NVM method. Another important note is when following this sequence of DISABLED, pin config change, ENABLE, the Ethernet GPIO pins will not inadvertently be toggled upon first boot. Namely these are the CS and RESET OUTPUT pins, whereas the INT pin is an INPUT with external 10k pull-up.Steps to Test
TEST=app/ethernet
with an Ethernet Wing and Argon/Boron/Photon2.How to change the pins:
Set the pins to whatever available GPIO is required. All can be explicitly set, or if you would like one or more to be in their default location you may use
PIN_INVALID
. Enable the Ethernet detection feature, and reset the system. Avoid calling this again on successive boots by using the Ethernet.isOn() API. (See example snippet and full example below)Example App
References
Completeness