mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 13:52:15 +01:00
For boards such as Waveshare's ESP32-P4-WIFI6-POE-ETH: WiFi through the board's ESP32-C6 on SDIO (esp-hosted), Ethernet on the P4's RMII MAC with an IP101. Not tested on a device: no P4 board was at hand. - platformio.ini: env esp32p4 (esp32-p4_r3, chip v3.01+) and esp32p4es (esp32-p4, the esp32p4_es libraries, chips before v2.0). An image runs on one of the two only, so each has its own release files, chip models "p4" and "p4es". Both keep the OTA slot: at level 2 they leave about 128 KB of it. - Ethernet clock mode: stored as eth_clock_id_t in the ESP32's numbering and translated by name, like the PHY id. The P4's eth_clock_mode_t is the IDF's emac_rmii_clock_mode_t, whose 0 is a deprecated default; only clock in (GPIO 50) translates there. - P4 Ethernet defaults: the Waveshare wiring (IP101 as TLK110, address 1, MDC 31, MDIO 52, reset 51), board type 8. The ESP32's put MDIO on an SDIO pin. - Settings take pins up to GPIO 54, the P4's last, instead of 48. - Radio defaults: SPI 32/33/27, CSN 46 (the framework's Waveshare variant), TX 2, RX 3. - Web UI: a Waveshare ESP32-P4-ETH preset, the P4's clock mode, pin lists up to GPIO 54 without the pins the C6 link, Ethernet, USB and UART0 use. - CI builds and releases both, with their ELFs; bootloader at 0x2000. - ADR 0003: amended. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
100 lines
4.1 KiB
C++
100 lines
4.1 KiB
C++
#include <unity.h>
|
|
// As on the original ESP32, so the translation is built.
|
|
#define CONFIG_ETH_USE_ESP32_EMAC 1
|
|
#include "EthPhy.h"
|
|
|
|
void setUp() {}
|
|
void tearDown() {}
|
|
|
|
static eth_phy_type_t translate(eth_phy_id_t id) {
|
|
eth_phy_type_t type = ETH_PHY_MAX;
|
|
TEST_ASSERT_TRUE(ethPhyType(static_cast<uint8_t>(id), type));
|
|
return type;
|
|
}
|
|
|
|
/*********************************************************************
|
|
* Stored ids
|
|
********************************************************************/
|
|
static void test_ids_match_stored_values() {
|
|
// NVS, backups and the web UI hold these numbers. Changing one moves
|
|
// every existing Ethernet board to another chip.
|
|
TEST_ASSERT_EQUAL_UINT8(0, static_cast<uint8_t>(eth_phy_id_t::LAN8720));
|
|
TEST_ASSERT_EQUAL_UINT8(1, static_cast<uint8_t>(eth_phy_id_t::TLK110));
|
|
TEST_ASSERT_EQUAL_UINT8(2, static_cast<uint8_t>(eth_phy_id_t::RTL8201));
|
|
TEST_ASSERT_EQUAL_UINT8(3, static_cast<uint8_t>(eth_phy_id_t::DP83848));
|
|
TEST_ASSERT_EQUAL_UINT8(4, static_cast<uint8_t>(eth_phy_id_t::DM9051));
|
|
TEST_ASSERT_EQUAL_UINT8(5, static_cast<uint8_t>(eth_phy_id_t::KSZ8041));
|
|
TEST_ASSERT_EQUAL_UINT8(6, static_cast<uint8_t>(eth_phy_id_t::KSZ8081));
|
|
}
|
|
|
|
/*********************************************************************
|
|
* ethPhyType
|
|
********************************************************************/
|
|
static void test_translates_each_rmii_chip_by_name() {
|
|
TEST_ASSERT_EQUAL(ETH_PHY_LAN8720, translate(eth_phy_id_t::LAN8720));
|
|
TEST_ASSERT_EQUAL(ETH_PHY_TLK110, translate(eth_phy_id_t::TLK110));
|
|
TEST_ASSERT_EQUAL(ETH_PHY_RTL8201, translate(eth_phy_id_t::RTL8201));
|
|
TEST_ASSERT_EQUAL(ETH_PHY_DP83848, translate(eth_phy_id_t::DP83848));
|
|
TEST_ASSERT_EQUAL(ETH_PHY_KSZ8041, translate(eth_phy_id_t::KSZ8041));
|
|
TEST_ASSERT_EQUAL(ETH_PHY_KSZ8081, translate(eth_phy_id_t::KSZ8081));
|
|
}
|
|
static void test_lan8720_is_not_the_framework_zero() {
|
|
// The default board stores 0. Arduino 3.x's 0 is ETH_PHY_GENERIC.
|
|
TEST_ASSERT_NOT_EQUAL(0, translate(eth_phy_id_t::LAN8720));
|
|
}
|
|
static void test_rejects_dm9051() {
|
|
eth_phy_type_t type = ETH_PHY_MAX;
|
|
TEST_ASSERT_FALSE(ethPhyType(static_cast<uint8_t>(eth_phy_id_t::DM9051), type));
|
|
}
|
|
static void test_rejects_unknown_ids() {
|
|
eth_phy_type_t type = ETH_PHY_MAX;
|
|
TEST_ASSERT_FALSE(ethPhyType(7, type));
|
|
TEST_ASSERT_FALSE(ethPhyType(255, type));
|
|
}
|
|
|
|
/*********************************************************************
|
|
* Clock modes
|
|
********************************************************************/
|
|
static void test_clock_ids_match_stored_values() {
|
|
TEST_ASSERT_EQUAL_UINT8(0, static_cast<uint8_t>(eth_clock_id_t::GPIO0_IN));
|
|
TEST_ASSERT_EQUAL_UINT8(1, static_cast<uint8_t>(eth_clock_id_t::GPIO0_OUT));
|
|
TEST_ASSERT_EQUAL_UINT8(2, static_cast<uint8_t>(eth_clock_id_t::GPIO16_OUT));
|
|
TEST_ASSERT_EQUAL_UINT8(3, static_cast<uint8_t>(eth_clock_id_t::GPIO17_OUT));
|
|
}
|
|
static void test_translates_each_clock_mode() {
|
|
eth_clock_mode_t mode;
|
|
TEST_ASSERT_TRUE(ethClockMode(0, mode));
|
|
TEST_ASSERT_EQUAL(ETH_CLOCK_GPIO0_IN, mode);
|
|
TEST_ASSERT_TRUE(ethClockMode(1, mode));
|
|
TEST_ASSERT_EQUAL(ETH_CLOCK_GPIO0_OUT, mode);
|
|
TEST_ASSERT_TRUE(ethClockMode(2, mode));
|
|
TEST_ASSERT_EQUAL(ETH_CLOCK_GPIO16_OUT, mode);
|
|
TEST_ASSERT_TRUE(ethClockMode(3, mode));
|
|
TEST_ASSERT_EQUAL(ETH_CLOCK_GPIO17_OUT, mode);
|
|
}
|
|
static void test_rejects_unknown_clock_ids() {
|
|
eth_clock_mode_t mode;
|
|
TEST_ASSERT_FALSE(ethClockMode(4, mode));
|
|
TEST_ASSERT_FALSE(ethClockMode(255, mode));
|
|
}
|
|
static void test_clock_pins() {
|
|
TEST_ASSERT_EQUAL_INT8(0, ethClockPin(0));
|
|
TEST_ASSERT_EQUAL_INT8(0, ethClockPin(1));
|
|
TEST_ASSERT_EQUAL_INT8(16, ethClockPin(2));
|
|
TEST_ASSERT_EQUAL_INT8(17, ethClockPin(3));
|
|
TEST_ASSERT_EQUAL_INT8(-1, ethClockPin(4));
|
|
}
|
|
|
|
int main(int, char **) {
|
|
UNITY_BEGIN();
|
|
RUN_TEST(test_ids_match_stored_values);
|
|
RUN_TEST(test_translates_each_rmii_chip_by_name);
|
|
RUN_TEST(test_lan8720_is_not_the_framework_zero);
|
|
RUN_TEST(test_rejects_dm9051);
|
|
RUN_TEST(test_rejects_unknown_ids);
|
|
RUN_TEST(test_clock_ids_match_stored_values);
|
|
RUN_TEST(test_translates_each_clock_mode);
|
|
RUN_TEST(test_rejects_unknown_clock_ids);
|
|
RUN_TEST(test_clock_pins);
|
|
return UNITY_END();
|
|
}
|