device-os
device-os copied to clipboard
Makes the Ethernet interrupt pin optional.
NOTE: this PR is targeting the feature/muon-som-evb 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
- 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.
- Run the following test app.
Example App
#include "application.h"
SYSTEM_MODE(SEMI_AUTOMATIC);
SerialLogHandler l(LOG_LEVEL_ALL);
STARTUP(
System.enableFeature(FEATURE_ETHERNET_DETECTION);
if_wiznet_pin_remap remap = {};
remap.base.type = IF_WIZNET_DRIVER_SPECIFIC_PIN_REMAP;
remap.cs_pin = PIN_INVALID; // default
remap.reset_pin = PIN_INVALID; // default
remap.int_pin = PIN_INVALID;
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
- [x] User is totes amazing for contributing!
- [x] Contributor has signed CLA (Info here)
- [x] Problem and Solution clearly stated
- [ ] Run unit/integration/application tests on device
- [ ] (REQUIRED) Added documentation
- [ ] Added to CHANGELOG.md after merging (add links to docs and issues)
How does this work in safe mode when the app can't reconfigure the ethernet interface?
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.
Does this Ethernet remaping interface already address this PR? https://docs.particle.io/reference/device-os/api/ethernet/ethernet/#pin-configuration-ethernet
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.
How does this work in safe mode when the app can't reconfigure the ethernet interface?
It is important to note that if a custom configuration is required, the correct system parts need to be flashed to the device so that it does not rely on booting into Safe Mode for the first connection to the Cloud.
This NOTE should also be added to the Docs. https://docs.particle.io/reference/device-os/api/ethernet/pin-configuration-ethernet/