-
Notifications
You must be signed in to change notification settings - Fork 518
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
[network] postpone ethernet interface initialization to allow STARTUP() call to override pin configuration without a reset #2847
Conversation
…() call to override pin configuration without a reset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, please also see comments 👍🏼
bool postpone_; | ||
hal_pin_t cs_ = PIN_INVALID; | ||
hal_pin_t reset_ = PIN_INVALID; | ||
hal_pin_t interrupt_ = PIN_INVALID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use defaults?
HAL_PLATFORM_ETHERNET_WIZNETIF_CS_PIN_DEFAULT
HAL_PLATFORM_ETHERNET_WIZNETIF_RESET_PIN_DEFAULT
HAL_PLATFORM_ETHERNET_WIZNETIF_INT_PIN_DEFAULT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The defaults are in the WizNetConfig. I've left things as much as possible to how it was before: settings coming from network.cpp
. Could set to defaults here too.
if (wizNetif->init(wizNetifConfigData) == 0) { | ||
return 0; | ||
} | ||
LOG(INFO, "Remove Ethernet interface"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be more like LOG(ERROR, "Error Initializing Ethernet");
I won't duplicate my comment for all of the rest of them ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, might be better to make it something like not detected
@@ -173,6 +169,28 @@ int if_init_platform(void*) { | |||
return 0; | |||
} | |||
|
|||
#if HAL_PLATFORM_IF_INIT_POSTPONE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the call to if_init_platform_postpone(nullptr);
in main.cpp
be wrapped in #if HAL_PLATFORM_IF_INIT_POSTPONE ... #endif
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, but there is always a default weak empty function anyway and it was like that before.
I think this may also require a |
@@ -318,7 +328,7 @@ bool WizNetif::isPresent(bool retry) { | |||
cv = getVERSIONR(); | |||
/* VERSIONR always indicates the W5500 version as 0x04 */ | |||
if (cv != 0x04 && retry) { | |||
HAL_Delay_Milliseconds(50); | |||
HAL_Delay_Milliseconds(10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@avtolstoy The delay is not enough to detect the W5500 on Muon. Cc. @artyLee
PR is based on #2846
Description
As title says. Postpones Ethernet interface initialization until after power management is initialized for all the platforms (even without aux power support). This happens after global app constructors are called, so should allow
STARTUP()
to override pin configuration for W5500.Steps to Test
N/A
Example App
N/A
References
Links to the Community, Docs, Other Issues, etc..
Completeness