Go to the documentation of this file.
32 #define TRACE_LEVEL NIC_TRACE_LEVEL
44 #if defined(__ICCARM__)
47 #pragma data_alignment = 4
50 #pragma data_alignment = 4
53 #pragma data_alignment = 4
56 #pragma data_alignment = 4
59 #pragma data_alignment = 4
62 #pragma data_alignment = 8
126 TRACE_INFO(
"Initializing LPC23xx Ethernet MAC...\r\n");
129 nicDriverInterface = interface;
132 PCONP |= PCONP_PCENET;
160 if(interface->phyDriver != NULL)
163 error = interface->phyDriver->init(interface);
165 else if(interface->switchDriver != NULL)
168 error = interface->switchDriver->init(interface);
186 MAC_SA0 = interface->macAddr.w[2];
187 MAC_SA1 = interface->macAddr.w[1];
188 MAC_SA2 = interface->macAddr.w[0];
202 MAC_INTCLEAR = 0xFFFF;
207 VICIntSelect &= ~VIC_INT_ETHERNET;
234 #if defined(USE_LPC2378_STK)
237 PINSEL2 &= ~(PINSEL2_P1_0_MASK | PINSEL2_P1_1_MASK |
238 PINSEL2_P1_4_MASK | PINSEL2_P1_8_MASK | PINSEL2_P1_9_MASK |
239 PINSEL2_P1_10_MASK | PINSEL2_P1_14_MASK | PINSEL2_P1_15_MASK);
241 PINSEL2 |= PINSEL2_P1_0_ENET_TXD0 | PINSEL2_P1_1_ENET_TXD1 |
242 PINSEL2_P1_4_ENET_TX_EN | PINSEL2_P1_8_ENET_CRS | PINSEL2_P1_9_ENET_RXD0 |
243 PINSEL2_P1_10_ENET_RXD1 | PINSEL2_P1_14_ENET_RX_ER | PINSEL2_P1_15_ENET_REF_CLK;
246 PINSEL3 &= ~(PINSEL3_P1_16_MASK | PINSEL3_P1_17_MASK);
247 PINSEL3 |= PINSEL3_P1_16_ENET_MDC | PINSEL3_P1_17_ENET_MDIO;
269 txStatus[i].
info = 0;
280 rxStatus[i].
info = 0;
286 MAC_TXDESCRIPTOR = (uint32_t) txDesc;
287 MAC_TXSTATUS = (uint32_t) txStatus;
289 MAC_TXPRODUCEINDEX = 0;
292 MAC_RXDESCRIPTOR = (uint32_t) rxDesc;
293 MAC_RXSTATUS = (uint32_t) rxStatus;
295 MAC_RXCONSUMEINDEX = 0;
311 if(interface->phyDriver != NULL)
314 interface->phyDriver->tick(interface);
316 else if(interface->switchDriver != NULL)
319 interface->switchDriver->tick(interface);
336 VICIntEnable = VIC_INT_ETHERNET;
339 if(interface->phyDriver != NULL)
342 interface->phyDriver->enableIrq(interface);
344 else if(interface->switchDriver != NULL)
347 interface->switchDriver->enableIrq(interface);
364 VICIntEnClr = VIC_INT_ETHERNET;
367 if(interface->phyDriver != NULL)
370 interface->phyDriver->disableIrq(interface);
372 else if(interface->switchDriver != NULL)
375 interface->switchDriver->disableIrq(interface);
401 status = MAC_INTSTATUS;
410 i = MAC_TXPRODUCEINDEX + 1;
419 if(i != MAC_TXCONSUMEINDEX)
433 nicDriverInterface->nicEvent =
TRUE;
510 i = MAC_TXPRODUCEINDEX;
521 if(j == MAC_TXCONSUMEINDEX)
540 MAC_TXPRODUCEINDEX = i;
552 if(j != MAC_TXCONSUMEINDEX)
577 i = MAC_RXCONSUMEINDEX;
580 if(i != MAC_RXPRODUCEINDEX)
600 MAC_RXCONSUMEINDEX = i;
627 uint32_t hashTable[2];
634 MAC_SA0 = interface->macAddr.w[2];
635 MAC_SA1 = interface->macAddr.w[1];
636 MAC_SA2 = interface->macAddr.w[0];
647 entry = &interface->macAddrFilter[i];
655 k = (crc >> 23) & 0x3F;
657 hashTable[k / 32] |= (1 << (k % 32));
662 MAC_HASHFILTERL = hashTable[0];
663 MAC_HASHFILTERH = hashTable[1];
666 TRACE_DEBUG(
" HashFilterL = %08" PRIX32
"\r\n", MAC_HASHFILTERL);
667 TRACE_DEBUG(
" HashFilterH = %08" PRIX32
"\r\n", MAC_HASHFILTERH);
811 p = (uint8_t *)
data;
816 for(i = 0; i <
length; i++)
819 for(j = 0; j < 8; j++)
822 if((((crc >> 31) ^ (
p[i] >> j)) & 0x01) != 0)
824 crc = (crc << 1) ^ 0x04C11DB7;
bool_t osSetEventFromIsr(OsEvent *event)
Set an event object to the signaled state from an interrupt service routine.
void lpc23xxEthTick(NetInterface *interface)
LPC23xx Ethernet MAC timer handler.
void lpc23xxEthDisableIrq(NetInterface *interface)
Disable interrupts.
const NicDriver lpc23xxEthDriver
LPC23xx Ethernet MAC driver.
size_t netBufferRead(void *dest, const NetBuffer *src, size_t srcOffset, size_t length)
Read data from a multi-part buffer.
#define LPC23XX_ETH_IRQ_PRIORITY
Structure describing a buffer that spans multiple chunks.
#define IPGR_DEFAULT_VALUE
#define MAC_ADDR_FILTER_SIZE
error_t lpc23xxEthReceivePacket(NetInterface *interface)
Receive a packet.
#define COMMAND_TX_ENABLE
void lpc23xxEthEnableIrq(NetInterface *interface)
Enable interrupts.
uint_t refCount
Reference count for the current entry.
void nicProcessPacket(NetInterface *interface, uint8_t *packet, size_t length, NetRxAncillary *ancillary)
Handle a packet received by the network controller.
#define LPC23XX_ETH_TX_BUFFER_COUNT
#define TX_CTRL_INTERRUPT
__weak_func void lpc23xxEthInitGpio(NetInterface *interface)
GPIO configuration.
#define RX_CTRL_INTERRUPT
#define MAC1_RECEIVE_ENABLE
#define CLRT_DEFAULT_VALUE
#define MAC1_SIMULATION_RESET
#define COMMAND_RX_ENABLE
const NetRxAncillary NET_DEFAULT_RX_ANCILLARY
@ ERROR_FAILURE
Generic error code.
#define RFC_ACCEPT_BROADCAST_EN
LPC2300 Ethernet MAC driver.
#define LPC23XX_ETH_RX_BUFFER_SIZE
uint16_t lpc23xxEthReadPhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr)
Read PHY register.
#define MAC1_RESET_MCS_TX
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
#define MAC2_PAD_CRC_ENABLE
#define COMMAND_FULL_DUPLEX
#define MAC1_RESET_MCS_RX
error_t lpc23xxEthInit(NetInterface *interface)
LPC23xx Ethernet MAC initialization.
error_t lpc23xxEthSendPacket(NetInterface *interface, const NetBuffer *buffer, size_t offset, NetTxAncillary *ancillary)
Send a packet.
error_t lpc23xxEthUpdateMacConfig(NetInterface *interface)
Adjust MAC configuration parameters for proper operation.
#define LPC23XX_ETH_RX_BUFFER_COUNT
void lpc23xxEthInitDesc(NetInterface *interface)
Initialize TX and RX descriptors.
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
void lpc23xxEthEventHandler(NetInterface *interface)
LPC23xx Ethernet MAC event handler.
#define MCFG_RESET_MII_MGMT
__irq void lpc23xxEthIrqHandler(void)
LPC23xx Ethernet MAC interrupt service routine.
#define RFC_ACCEPT_MULTICAST_HASH_EN
#define LPC23XX_ETH_TX_BUFFER_SIZE
uint32_t lpc23xxEthCalcCrc(const void *data, size_t length)
CRC calculation.
#define COMMAND_REG_RESET
#define MCFG_CLOCK_SELECT_DIV28
#define MADR_REGISTER_ADDRESS
#define RFC_ACCEPT_PERFECT_EN
error_t lpc23xxEthUpdateMacAddrFilter(NetInterface *interface)
Configure MAC address filtering.
__attribute__((naked))
AVR32 Ethernet MAC interrupt wrapper.
@ NIC_TYPE_ETHERNET
Ethernet interface.
void lpc23xxEthWritePhyReg(uint8_t opcode, uint8_t phyAddr, uint8_t regAddr, uint16_t data)
Write PHY register.