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 interrupt pin optional. #2775

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

Currently W5500 interrupt pin is essential for Ethernet to be functional. However, for the Ethernet feather wing from Adafruit doesn't expose the interrupt pin to side headers, indicating that the interrupt pin is optional to the Ethernet interface.

Solution

Allow the int_pin in WizNetifConfigData to be PIN_INVALID and use query scheme in WizNetif when the interrupt pin is not present.

Steps to Test

  1. Use the M.2 SoM breakout board and install the Ethernet feather wing from Adafruit. Do not fly wire the IRQ pin on the wing to any of the Particle SoM's IOs.
  2. Run the following test app.

Example App

#include "application.h"

SYSTEM_MODE(SEMI_AUTOMATIC);

SerialLogHandler l(LOG_LEVEL_ALL);

uint8_t auxPwrPin = D23;

STARTUP(System.enableFeature(FEATURE_ETHERNET_DETECTION));

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

    if_wiznet_pin_remap remap = {};
    remap.base.type = IF_WIZNET_DRIVER_SPECIFIC_PIN_REMAP;
    remap.cs_pin = HAL_PLATFORM_ETHERNET_WIZNETIF_CS_PIN_DEFAULT;
    remap.reset_pin = HAL_PLATFORM_ETHERNET_WIZNETIF_RESET_PIN_DEFAULT;
    remap.int_pin = PIN_INVALID; // D22 for MSoM
    if_request(nullptr, IF_REQ_DRIVER_SPECIFIC, &remap, sizeof(remap), nullptr);
});

void setup() {
    while (!Serial.isConnected()) {
        delay(100);
    }
    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;
            }
            case 'd': {
                Log.info("Connecting to Particle Cloud...");
                Particle.disconnect();
                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 marked this pull request as ready for review May 24, 2024 19:08
@XuGuohui XuGuohui added the 6.x label May 24, 2024
@mrlambchop
Copy link
Contributor

How does this work in safe mode when the app can't reconfigure the ethernet interface?

@XuGuohui
Copy link
Member Author

How does this work in safe mode when the app can't reconfigure the ethernet interface?

The Ethernet config data is stored in system cache, which is a file in littlefs.

@eberseth
Copy link
Contributor

Does this Ethernet remaping interface already address this PR? https://docs.particle.io/reference/device-os/api/ethernet/ethernet/#pin-configuration-ethernet

@XuGuohui
Copy link
Member Author

Does this Ethernet remaping interface already address this PR? https://docs.particle.io/reference/device-os/api/ethernet/ethernet/#pin-configuration-ethernet

No, that feature requires the INT pin to be a valid pin. This PR removes the constraint based on that feature and also makes minor changes to the WizNetif to make sure Ethernet can receive packets without relying on interrupt.

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