32 #include "IfxPort_reg.h"
33 #include "IfxEth_bf.h"
35 #include "IfxPort_reg.h"
49 static void IfxEth_setTransmitDescriptorAddress(Ifx_ETH *eth,
void *address);
56 static void IfxEth_setReceiveDescriptorAddress(Ifx_ETH *eth,
void *address);
71 static void IfxEth_initTransmitDescriptors(
IfxEth *eth);
77 static void IfxEth_initReceiveDescriptors(
IfxEth *eth);
99 eth->
status.U = ETH_STATUS.U;
102 if (eth->
status.U & 0x00600000)
107 ETH_STATUS.U = (IFX_ETH_STATUS_TU_MSK << IFX_ETH_STATUS_TU_OFF) |
108 (IFX_ETH_STATUS_UNF_MSK << IFX_ETH_STATUS_UNF_OFF);
118 eth->
status.U = ETH_STATUS.U;
121 if (eth->
status.U & (4U << IFX_ETH_STATUS_RS_OFF))
125 ETH_STATUS.U = (IFX_ETH_STATUS_RU_MSK << IFX_ETH_STATUS_RU_OFF);
137 ETH_TRANSMIT_POLL_DEMAND.U = 0;
138 ETH_OPERATION_MODE.B.ST = 0;
139 ETH_MAC_CONFIGURATION.B.TE = 0;
147 ETH_MAC_CONFIGURATION.B.TE = 1;
148 ETH_OPERATION_MODE.B.ST = 1;
149 ETH_TRANSMIT_POLL_DEMAND.U = 1;
158 ETH_OPERATION_MODE.B.SR = 1;
159 ETH_MAC_CONFIGURATION.B.RE = 1;
160 ETH_RECEIVE_POLL_DEMAND.U = 1;
236 ETH_OPERATION_MODE.B.TSF = 1U;
237 ETH_OPERATION_MODE.B.DT = 0U;
238 ETH_MAC_CONFIGURATION.B.IPC = 1U;
251 static void IfxEth_setTransmitDescriptorAddress(Ifx_ETH *eth,
void *address)
253 eth->TRANSMIT_DESCRIPTOR_LIST_ADDRESS.U = (
uint32)address;
257 static void IfxEth_setReceiveDescriptorAddress(Ifx_ETH *eth,
void *address)
259 eth->RECEIVE_DESCRIPTOR_LIST_ADDRESS.U = (
uint32)address;
266 ETH_MAC_ADDRESS_G00_HIGH.U = 0
267 | ((
uint32)macAddress[4] << 0U)
268 | ((
uint32)macAddress[5] << 8U)
271 ETH_MAC_ADDRESS_G00_LOW.U = 0
272 | ((
uint32)macAddress[0] << 0U)
273 | ((
uint32)macAddress[1] << 8U)
274 | ((
uint32)macAddress[2] << 16U)
275 | ((
uint32)macAddress[3] << 24U)
304 *((
uint32 *)macAddress) = ETH_MAC_ADDRESS_G00_LOW.U;
305 *((
uint16 *)(&macAddress[4])) = (
uint16)(ETH_MAC_ADDRESS_G00_HIGH.U & 0xFFFFU);
309 static void IfxEth_initTransmitDescriptors(
IfxEth *eth)
326 #if !IFXETH_TX_BUFFER_BY_USER
354 static void IfxEth_initReceiveDescriptors(
IfxEth *eth)
373 #if !IFXETH_RX_BUFFER_BY_USER
410 ETH_BUS_MODE.B.SWR = 1;
416 while ((ETH_BUS_MODE.B.SWR == 1) && (timeout < 1000))
425 Ifx_ETH_BUS_MODE busMode;
426 busMode.U = ETH_BUS_MODE.U;
431 ETH_BUS_MODE.U = busMode.U;
436 Ifx_ETH_MAC_CONFIGURATION ethMacCfg;
437 ethMacCfg.U = ETH_MAC_CONFIGURATION.U;
439 ethMacCfg.B.PRELEN = 0;
457 ethMacCfg.B.TWOKPE = 0;
459 ETH_MAC_CONFIGURATION.U = ethMacCfg.U;
465 ETH_MMC_CONTROL.B.CNTFREEZ = 1;
468 ETH_STATUS.U = 0x0001e7ff;
469 ETH_MAC_FRAME_FILTER.U = 0x00000010;
471 ETH_INTERRUPT_ENABLE.U = 0x00010041;
500 IfxEth_initReceiveDescriptors(eth);
501 IfxEth_initTransmitDescriptors(eth);
515 buffer = ((
void *)descr->
TDES2.
U);
531 result = (
void *)(descr->
RDES2.
U);