Hot!Proper PLIB Ethernet MIIM driver example in hamony

Author
Bruce Lavoie
Super Member
  • Total Posts : 189
  • Reward points : 0
  • Joined: 2014/06/30 11:23:22
  • Location: Rhode Island
  • Status: offline
2018/08/13 11:22:22 (permalink)
0

Proper PLIB Ethernet MIIM driver example in hamony

I'm using Harmony 2.06 and I've created MIIM read/write functions using PLIB library.  Just to get started I've been using blocking functionality just to prove the concept and test out the library.  It's seems to be working but I'd like to refactor the code to something usable and I'm limited on time, I'm wondering if there is a Harmony example I can possible lift and use?
 
Any help is greatly appreciated and the two test functions I have are below.
 
uint16_t mdio_read(uint8_t port_offset, uint8_t PhyReg)
{
    ETH_MODULE_ID ethphyId = DRV_MIIM_ETH_MODULE_ID;
 
    while ( PLIB_ETH_MIIMIsBusy(ethphyId));
    PLIB_ETH_PHYAddressSet(ethphyId, port_offset);
    PLIB_ETH_RegisterAddressSet(ethphyId,PhyReg);
    PLIB_ETH_MIIMReadStart(ethphyId);
    while ( PLIB_ETH_MIIMIsBusy(ethphyId));
    PLIB_ETH_MIIMWriteStart(ethphyId);         // Stop read cycle.    
    return PLIB_ETH_MIIMReadDataGet(ethphyId); // get the read register
}
void mdio_write(uint8_t port_offset, uint8_t PhyReg, uint16_t Value)
{
    ETH_MODULE_ID ethphyId = DRV_MIIM_ETH_MODULE_ID;
 
    while ( PLIB_ETH_MIIMIsBusy(ethphyId));
    PLIB_ETH_PHYAddressSet(ethphyId, port_offset);
    PLIB_ETH_RegisterAddressSet(ethphyId,PhyReg);    
    PLIB_ETH_MIIMWriteDataSet(ethphyId,Value);
    while ( PLIB_ETH_MIIMIsBusy(ethphyId));
  
}
#1

1 Reply Related Threads

    rainad
    Super Member
    • Total Posts : 1118
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    Re: Proper PLIB Ethernet MIIM driver example in hamony 2018/08/13 16:13:43 (permalink)
    0
    The MIIM driver does exactly what you need, allowing multiple clients to perform transactions over the MIIM bus.
    It also comes with a minimal command set that you can use from the console(> miim read/write, dump, etc.).
    You could use the driver as it is - much easier - or you can extract (look at) just the part that uses PLIBs to talk over the MIIM bus.
    Of course you'l have to remove all the OS synchronization and all other client management stuff that's in there.
     
    #2
    Jump to:
    © 2019 APG vNext Commercial Version 4.5