Device: Implement Ethernet PHY MDIO Communication

The following fixups were added during the squash/merge:

Fix formatting in EthPhyMessage and EthPhyRegPacket
Device: Use std::make_shared when creating the EthPHYControl filter
Network: Create NetID String for EthPHYControl
EthPhyRegPacket: Constants in PascalCase
This commit is contained in:
Kyle Johannes
2021-12-08 19:07:07 -05:00
committed by Paul Hollinsky
parent 890eb1e1bc
commit 2d1bb381f6
21 changed files with 421 additions and 1 deletions
@@ -0,0 +1,60 @@
#ifndef __ETHPHYMESSAGE_H__
#define __ETHPHYMESSAGE_H__
#ifdef __cplusplus
#include "icsneo/communication/packet/ethphyregpacket.h"
#include "icsneo/communication/message/message.h"
#include "icsneo/communication/packet.h"
#include "icsneo/api/eventmanager.h"
#include <vector>
#include <memory>
namespace icsneo {
struct Clause22Message
{
uint8_t phyAddr;
uint8_t page;
uint16_t regAddr;
uint16_t regVal;
};
struct Clause45Message
{
uint8_t port;
uint8_t device;
uint16_t regAddr;
uint16_t regVal;
};
struct PhyMessage
{
bool Enabled;
bool WriteEnable;
bool Clause45Enable;
uint8_t version;
union
{
Clause22Message clause22;
Clause45Message clause45;
};
};
//Internal message which provides an interface with device ethernet PHY registers,
//with Clause22 and Clause45 message support
class EthPhyMessage : public Message {
public:
EthPhyMessage() : Message(Message::Type::EthernetPhyRegister) {}
bool appendPhyMessage(bool writeEnable, bool clause45, uint8_t phyAddrOrPort, uint8_t pageOrDevice, uint16_t regAddr, uint16_t regVal = 0x0000u, bool enabled = true);
bool appendPhyMessage(std::shared_ptr<PhyMessage> message);
size_t getMessageCount() const;
std::vector<std::shared_ptr<PhyMessage>> messages;
};
}
#endif // __cplusplus
#endif
@@ -26,6 +26,7 @@ public:
DeviceVersion = 0x8004,
Main51 = 0x8005,
FlexRayControl = 0x8006,
EthernetPhyRegister = 0x8007,
};
Message(Type t) : type(t) {}