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

Makes the Ethernet reset pin optional. #2794

Open
wants to merge 1 commit into
base: feature/auxiliary-power-control
Choose a base branch
from

Conversation

XuGuohui
Copy link
Member

NOTE: this PR is targeting the feature/auxiliary-power-control branch

Problem

The Ethernet reset pin on Muon is controlled by a reset IC, instead of GPIO. The reset IC will delay up to 200ms after the Ethernet interface is powered up to reset the Ethernet, which is too late to add the Ethernet interface.

Solution

  1. Makes the reset pin of Ethernet optional, so that user can set the reset pin to PIN_INVALID
  2. Does retries to detect the Ethernet interface so that we can detect it after the reset IC resets it.

Steps to Test

Build and run the test app on MSoM/B5SoM/BSoM that is installed on the Muon.

Example App

#include "application.h"

SYSTEM_MODE(SEMI_AUTOMATIC);

Serial1LogHandler l(115200, LOG_LEVEL_ALL);

uint8_t auxPwrPin = D7;

STARTUP(System.enableFeature(FEATURE_ETHERNET_DETECTION));

STARTUP({
    System.setPowerConfiguration(SystemPowerConfiguration().auxPowerControlPin(auxPwrPin).feature(SystemPowerFeature::PMIC_DETECTION));

    System.enableFeature(FEATURE_ETHERNET_DETECTION);

    if_wiznet_pin_remap remap = {};
    remap.base.type = IF_WIZNET_DRIVER_SPECIFIC_PIN_REMAP;
    remap.cs_pin = A3;
    remap.reset_pin = PIN_INVALID;
    remap.int_pin = A4;
    if_request(nullptr, IF_REQ_DRIVER_SPECIFIC, &remap, sizeof(remap), nullptr);
});

void setup() {
    Log.info("Application started");
}

void loop() {
    if (Serial.available()) {
        char c = Serial.read();
        switch (c) {
            case 'i': {
                if_list* ifs = nullptr;
                if_get_list(&ifs);
                for (if_list* iface = ifs; iface != nullptr; iface = iface->next) {
                    if (iface->iface) {
                        uint8_t idx;
                        if_get_index(iface->iface, &idx);
                        Log.info("Interface %d: %s", idx, iface->iface->name);
                    }
                }
                if_free_list(ifs);
                break;
            }
            case 'p': {
                Log.info("Connecting to Particle Cloud...");
                Particle.connect();
                break;
            }
            case 'e': {
                Log.info("Connecting to Ethernet...");
                Ethernet.connect();
                break;
            }
            default: break;
        }
    }
}

References

N/A


Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA (Info here)
  • Problem and Solution clearly stated
  • Run unit/integration/application tests on device
  • Added documentation
  • Added to CHANGELOG.md after merging (add links to docs and issues)

@XuGuohui XuGuohui force-pushed the feature/ethernet-reset-optional branch from 161c193 to b3849f0 Compare July 4, 2024 14:48
@@ -157,12 +157,16 @@ int if_init_platform_postpone(void*) {
uint8_t dummy;
if (!if_get_index(en2->interface(), &dummy)) {
auto wizNetif = reinterpret_cast<WizNetif*>(en2);
if (wizNetif->isPresent()) {
return 0;
for (uint8_t retries = 0; retries < 5; retries++) {
Copy link
Member Author

Choose a reason for hiding this comment

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

5 retries does not work reliably, we probably need to increase the retries.

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