|
20 | 20 |
|
21 | 21 |
|
22 | 22 | #if defined(ARDUINO_ARCH_ESP32) |
| 23 | +/** |
| 24 | + * Supported ethernet devices |
| 25 | + */ |
23 | 26 | const ethernet_config ethernetDevices[] = { |
24 | | - // No Ethernet |
25 | | - { |
26 | | - }, |
27 | | - // QuinLed-ESP32-Ethernet |
28 | | - { |
29 | | - 0, |
30 | | - 5, |
31 | | - 23, |
32 | | - 18, |
33 | | - ETH_PHY_LAN8720, |
34 | | - ETH_CLOCK_GPIO17_OUT |
35 | | - }, |
36 | | - // QuinLed-Dig-Octa Brainboard-32-8L and LilyGO-T-ETH-POE |
37 | | - { |
38 | | - 0, |
39 | | - -1, |
40 | | - 23, |
41 | | - 18, |
42 | | - ETH_PHY_LAN8720, |
43 | | - ETH_CLOCK_GPIO17_OUT |
44 | | - }, |
45 | | - // WT32-EHT01 |
46 | | - // These pins works well: IO2, IO4, IO12, IO14, IO15 |
47 | | - // These not: IO35, IO36, IO39 |
48 | | - { |
49 | | - 1, |
50 | | - 16, |
51 | | - 23, |
52 | | - 18, |
53 | | - ETH_PHY_LAN8720, |
54 | | - ETH_CLOCK_GPIO0_IN |
55 | | - }, |
56 | | - // ESP32-ETHERNET-KIT-VE |
57 | | - { |
58 | | - 0, |
59 | | - 5, |
60 | | - 23, |
61 | | - 18, |
62 | | - ETH_PHY_IP101, |
63 | | - ETH_CLOCK_GPIO0_IN |
64 | | - }, |
65 | | - // ESP32-POE |
66 | | - { |
67 | | - 0, |
68 | | - 12, |
69 | | - 23, |
70 | | - 18, |
71 | | - ETH_PHY_LAN8720, |
72 | | - ETH_CLOCK_GPIO17_OUT |
73 | | - }, |
74 | | - // WESP32 |
75 | | - { |
76 | | - 0, |
77 | | - -1, |
78 | | - 16, |
79 | | - 17, |
80 | | - ETH_PHY_LAN8720, |
81 | | - ETH_CLOCK_GPIO0_IN |
82 | | - } |
| 27 | + // No Ethernet |
| 28 | + { |
| 29 | + }, |
| 30 | + // QuinLed-ESP32-Ethernet |
| 31 | + { |
| 32 | + |
| 33 | + 0, |
| 34 | + 5, |
| 35 | + 23, |
| 36 | + 18, |
| 37 | + ETH_PHY_LAN8720, |
| 38 | + ETH_CLOCK_GPIO17_OUT |
| 39 | + }, |
| 40 | + // QuinLed-Dig-Octa Brainboard-32-8L and LilyGO-T-ETH-POE |
| 41 | + { |
| 42 | + 0, |
| 43 | + -1, |
| 44 | + 23, |
| 45 | + 18, |
| 46 | + ETH_PHY_LAN8720, |
| 47 | + ETH_CLOCK_GPIO17_OUT |
| 48 | + }, |
| 49 | + // WT32-EHT01 |
| 50 | + // These pins works well: IO2, IO4, IO12, IO14, IO15 |
| 51 | + // These not: IO35, IO36, IO39 |
| 52 | + { |
| 53 | + 1, |
| 54 | + 16, |
| 55 | + 23, |
| 56 | + 18, |
| 57 | + ETH_PHY_LAN8720, |
| 58 | + ETH_CLOCK_GPIO0_IN |
| 59 | + }, |
| 60 | + // ESP32-ETHERNET-KIT-VE |
| 61 | + { |
| 62 | + 0, |
| 63 | + 5, |
| 64 | + 23, |
| 65 | + 18, |
| 66 | + ETH_PHY_IP101, |
| 67 | + ETH_CLOCK_GPIO0_IN |
| 68 | + }, |
| 69 | + // ESP32-POE |
| 70 | + { |
| 71 | + 0, |
| 72 | + 12, |
| 73 | + 23, |
| 74 | + 18, |
| 75 | + ETH_PHY_LAN8720, |
| 76 | + ETH_CLOCK_GPIO17_OUT |
| 77 | + }, |
| 78 | + // WESP32 |
| 79 | + { |
| 80 | + 0, |
| 81 | + -1, |
| 82 | + 16, |
| 83 | + 17, |
| 84 | + ETH_PHY_LAN8720, |
| 85 | + ETH_CLOCK_GPIO0_IN |
| 86 | + } |
83 | 87 | }; |
84 | 88 |
|
| 89 | +/** |
| 90 | + * Connect to ethernet |
| 91 | + * @param deviceNumber to use |
| 92 | + */ |
85 | 93 | void EthManager::connectToEthernet(int8_t deviceNumber) { |
86 | 94 | ETH.begin( |
87 | | - ethernetDevices[deviceNumber].address, |
88 | | - ethernetDevices[deviceNumber].power, |
89 | | - ethernetDevices[deviceNumber].mdc, |
90 | | - ethernetDevices[deviceNumber].mdio, |
91 | | - ethernetDevices[deviceNumber].type, |
92 | | - ethernetDevices[deviceNumber].clk_mode |
| 95 | + ethernetDevices[deviceNumber].address, |
| 96 | + ethernetDevices[deviceNumber].power, |
| 97 | + ethernetDevices[deviceNumber].mdc, |
| 98 | + ethernetDevices[deviceNumber].mdio, |
| 99 | + ethernetDevices[deviceNumber].type, |
| 100 | + ethernetDevices[deviceNumber].clk_mode |
93 | 101 | ); |
94 | 102 | } |
95 | 103 |
|
| 104 | +/** |
| 105 | + * Deallocate ethernet pins |
| 106 | + * @param deviceNumber to deallocate |
| 107 | + */ |
| 108 | +void EthManager::deallocateEthernetPins(int8_t deviceNumber) { |
| 109 | + const uint32_t MATRIX_DETACH_OUT_SIG = 0x100; |
| 110 | + gpio_matrix_out(ethernetDevices[deviceNumber].address, MATRIX_DETACH_OUT_SIG, false, false); |
| 111 | + gpio_matrix_out(ethernetDevices[deviceNumber].power, MATRIX_DETACH_OUT_SIG, false, false); |
| 112 | + gpio_matrix_out(ethernetDevices[deviceNumber].mdc, MATRIX_DETACH_OUT_SIG, false, false); |
| 113 | + gpio_matrix_out(ethernetDevices[deviceNumber].mdio, MATRIX_DETACH_OUT_SIG, false, false); |
| 114 | + gpio_matrix_out(ethernetDevices[deviceNumber].clk_mode, MATRIX_DETACH_OUT_SIG, false, false); |
| 115 | + pinMode(ethernetDevices[deviceNumber].address, INPUT); |
| 116 | + pinMode(ethernetDevices[deviceNumber].power, INPUT); |
| 117 | + pinMode(ethernetDevices[deviceNumber].mdc, INPUT); |
| 118 | + pinMode(ethernetDevices[deviceNumber].mdio, INPUT); |
| 119 | + pinMode(ethernetDevices[deviceNumber].clk_mode, INPUT); |
| 120 | +} |
| 121 | + |
96 | 122 | #endif |
0 commit comments