void IntWriteReg( //===================//===================//===========//===========
IN PEPL_PORT_HANDLE portHandle,
IN NS_UINT registerIndex,
IN NS_UINT value)
// Internal procedure that performs the actual write operation. See below for details of parameters
//****************************************************************************
{
PPORT_OBJ portHdl = (PPORT_OBJ)portHandle;
NS_UINT32 tPCF;
// See if we need to do a page select, but not if we are using PCFs
if( ((registerIndex & ~0x8000) > PHY_PAGESEL) && !portHdl->usePhyControlFrames )
{ // Make sure correct register page is selected
IntWriteReg( portHdl, (PHY_PAGESEL | (registerIndex & 0x8000)), (registerIndex & 0xE0) >> 5);
registerIndex &= ~0xE0;
}
switch( portHdl->ifType ) {
case EPL_ENUM_CYUSB_MDIO://--------------------------------------------------------------
// Send data out Cypress USB MDIO interface 如果使用Cypress USB MDIO与PHY通信 请问Cypress USB MDIO是什么呢?MDIO不就是一根线吗?
ifCyUSB_WriteMDIO( portHdl, registerIndex, value);
break;
case EPL_ENUM_DIRECT://------------------------------------------------------------------
// Using direct interface. See if we should use PCFs如果使用direct接口与PHY通信 什么算是direct接口?
//Use OK MAC interface.
if( portHdl->usePhyControlFrames )
{
// Send data out "MAC" interface using PHY Control Frames
// Create PCF packet
tPCF = 0x40000000; // [31:30] 01'b for write command
tPCF |= ((portHdl->portMdioAddress & 0x1F) << 25); // [29:25] PHY Address
tPCF |= ((registerIndex>>5 & 0x0F) << 21); // [24:21] Page
tPCF |= ((registerIndex & 0x1F) << 16); // [20:16] Register
// PCFs are in network order, need to swap the bytes around
tPCF = (((tPCF) >> 24) & 0x000000ff) | (((tPCF) >> 8 ) & 0x0000ff00) |
(((tPCF) << 8 ) & 0x00ff0000) | (((tPCF) << 24) & 0xff000000);
MACMIIWriteReg( portHdl, (NS_UINT8 *)&tPCF, sizeof(tPCF) );
}
else
{ // Send data out direct "MAC" interface
MACWriteReg( portHdl, registerIndex, value);
}
break;
default://--------------------------------------------------------------------------------
// Send data out bit bang interface on LPT 如果使用MDIO与PHY通信
ifLPTWriteReg( portHdl, registerIndex, value);
break;
} // switch( portHdl->ifType )
}