move preference converter switch cases to NetworkUtil

This commit is contained in:
technyon
2024-08-18 08:21:28 +02:00
parent 7138802462
commit 0b423ee29d
3 changed files with 78 additions and 51 deletions

View File

@@ -1,5 +1,6 @@
#include "NetworkUtil.h"
#include "../Logger.h"
#include "../networkDevices/LAN8720Definitions.h"
NetworkDeviceType NetworkUtil::GetDeviceTypeFromPreference(int hardwareDetect, int customPhy)
{
@@ -51,3 +52,71 @@ NetworkDeviceType NetworkUtil::GetDeviceTypeFromPreference(int hardwareDetect, i
break;
}
}
std::string NetworkUtil::GetCustomEthernetDeviceName(int custPHY)
{
switch(custPHY)
{
case 4:
return "Custom (LAN8720)";
case 5:
return"Custom (RTL8201)";
case 6:
return "Custom (TLK110)";
case 7:
return "Custom (DP83848)";
case 8:
return "Custom (KSZ8041)";
case 9:
return "Custom (KSZ8081)";
default:
return"Custom (LAN8720)";
}
}
eth_phy_type_t NetworkUtil::GetCustomEthernetType(int custPHY)
{
switch(custPHY)
{
case 4:
return ETH_PHY_TYPE_LAN8720;
break;
case 5:
return ETH_PHY_RTL8201;
break;
case 6:
return ETH_PHY_TLK110;
break;
case 7:
return ETH_PHY_DP83848;
break;
case 8:
return ETH_PHY_KSZ8041;
break;
case 9:
return ETH_PHY_KSZ8081;
break;
default:
return ETH_PHY_TYPE_LAN8720;
break;
}
}
eth_clock_mode_t NetworkUtil::GetCustomClock(int custCLKpref)
{
switch(custCLKpref)
{
case 0:
return ETH_CLOCK_GPIO0_IN;
break;
case 2:
return ETH_CLOCK_GPIO16_OUT;
break;
case 3:
return ETH_CLOCK_GPIO17_OUT;
break;
default:
return ETH_CLOCK_GPIO17_OUT;
break;
}
}