| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
LPC17xx/40xx Ethernet example
Peripheral examples

## Detailed Description

Example description
The ENET example is a simple ethernet application for sending an ethernet packet via the MAC and displaying received broadcast packets. The MAC example will listen for all packets on the ethernet and display some stats via UART when a packet is received. A dummy packet can also be sent out. Wireshark can be used to view the outgoing packet.

To use the example, connect a serial cable to the board's RS232/UART port and start a terminal program to monitor the port. The terminal program on the host PC should be setup for 115K8N1. For each packet received, the LED will toggle and the packets source and destination MAC addresses will be displayed with the packet type. Pressing any key will send a dummy packet.

Special connection requirements

- Embedded Artists' LPC1788 Developer's Kit:
- Embedded Artists' LPC4088 Developer's Kit:
  There are no special connection requirements for this example.
- LPCXpresso LPC1769:
  Need to connect with base board for using RS232/UART port and Ethernet port.

Build procedures:
LPC17xx/40xx example quickstart for Keil uVision4
LPC17xx/40xx example quickstart for IAR EWARM
LPC17xx/40xx example quickstart for Code Red Xpresso

Supported boards and board setup:
Embedded Artists' LPC1788 Developer's Kit
Embedded Artists' LPC4088 Developer's Kit
NXP Xpresso LPC1769 board

Submitting LPCOpen issues:
Community support for LPCOpen

## Macros
#define | ENET_NUM_TX_DESC 4
#define | ENET_NUM_RX_DESC 4
#define | ENET_RX_DESC_BASE (0x20000000UL)
#define | ENET_RX_STAT_BASE (ENET_RX_DESC_BASE + ENET_NUM_RX_DESC * sizeof(ENET_RXDESC_T))
#define | ENET_TX_DESC_BASE (ENET_RX_STAT_BASE + ENET_NUM_RX_DESC * sizeof(ENET_RXSTAT_T))
#define | ENET_TX_STAT_BASE (ENET_TX_DESC_BASE + ENET_NUM_TX_DESC * sizeof(ENET_TXDESC_T))
#define | ENET_RX_BUF_BASE (ENET_TX_STAT_BASE + ENET_NUM_TX_DESC * sizeof(ENET_TXSTAT_T))
#define | ENET_TX_BUF_BASE (ENET_RX_BUF_BASE + ENET_NUM_RX_DESC * ENET_ETH_MAX_FLEN)
#define | ENET_RX_BUF(i) (ENET_RX_BUF_BASE + ENET_ETH_MAX_FLEN * i)
#define | ENET_TX_BUF(i) (ENET_TX_BUF_BASE + ENET_ETH_MAX_FLEN * i)

## Functions
STATIC void | localMsDelay (uint32_t ms)
STATIC void | InitDescriptors (void)
STATIC void * | ENET_RXGet (int32_t *bytes)
STATIC void | ENET_RXBuffClaim (void)
STATIC void * | ENET_TXBuffGet (void)
STATIC void | ENET_TXQueue (int32_t bytes)
STATIC bool | ENET_IsTXFinish (void)
void | ETH_IRQHandler (void)
| Handle interrupt from ethernet.
int | main (void)
| main routine for ENET example

## Variables
STATIC ENET_RXDESC_T * | pRXDescs = (ENET_RXDESC_T *) ENET_RX_DESC_BASE
STATIC ENET_RXSTAT_T * | pRXStats = (ENET_RXSTAT_T *) ENET_RX_STAT_BASE
STATIC ENET_TXDESC_T * | pTXDescs = (ENET_TXDESC_T *) ENET_TX_DESC_BASE
STATIC ENET_TXSTAT_T * | pTXStats = (ENET_TXSTAT_T *) ENET_TX_STAT_BASE
STATIC int32_t | rxConsumeIdx
STATIC int32_t | txProduceIdx

## Macro Definition Documentation

#define ENET_NUM_RX_DESC 4

Definition at line 78 of file enet.c.

#define ENET_NUM_TX_DESC 4

Definition at line 77 of file enet.c.

#define ENET_RX_BUF | ( |  | i | ) | (ENET_RX_BUF_BASE + ENET_ETH_MAX_FLEN * i)

Definition at line 92 of file enet.c.

#define ENET_RX_BUF_BASE (ENET_TX_STAT_BASE + ENET_NUM_TX_DESC * sizeof(ENET_TXSTAT_T))

Definition at line 90 of file enet.c.

#define ENET_RX_DESC_BASE (0x20000000UL)

Definition at line 85 of file enet.c.

#define ENET_RX_STAT_BASE (ENET_RX_DESC_BASE + ENET_NUM_RX_DESC * sizeof(ENET_RXDESC_T))

Definition at line 87 of file enet.c.

#define ENET_TX_BUF | ( |  | i | ) | (ENET_TX_BUF_BASE + ENET_ETH_MAX_FLEN * i)

Definition at line 93 of file enet.c.

#define ENET_TX_BUF_BASE (ENET_RX_BUF_BASE + ENET_NUM_RX_DESC * ENET_ETH_MAX_FLEN)

Definition at line 91 of file enet.c.

#define ENET_TX_DESC_BASE (ENET_RX_STAT_BASE + ENET_NUM_RX_DESC * sizeof(ENET_RXSTAT_T))

Definition at line 88 of file enet.c.

#define ENET_TX_STAT_BASE (ENET_TX_DESC_BASE + ENET_NUM_TX_DESC * sizeof(ENET_TXDESC_T))

Definition at line 89 of file enet.c.

## Function Documentation

STATIC bool ENET_IsTXFinish | ( | void |  | ) |

Definition at line 203 of file enet.c.

STATIC void ENET_RXBuffClaim | ( | void |  | ) |

Definition at line 177 of file enet.c.

STATIC void* ENET_RXGet | ( | int32_t * | bytes | ) |

Definition at line 155 of file enet.c.

STATIC void* ENET_TXBuffGet | ( | void |  | ) |

Definition at line 183 of file enet.c.

STATIC void ENET_TXQueue | ( | int32_t | bytes | ) |

Definition at line 194 of file enet.c.

void ETH_IRQHandler | ( | void |  | ) |

Handle interrupt from ethernet.

Returns
  Nothing

Definition at line 221 of file enet.c.

STATIC void InitDescriptors | ( | void |  | ) |

Definition at line 123 of file enet.c.

STATIC void localMsDelay | ( | uint32_t | ms | ) |

Definition at line 114 of file enet.c.

int main | ( | void |  | ) |

main routine for ENET example

Main program body.

Returns
  Nothing (function should not exit)

Definition at line 230 of file enet.c.

## Variable Documentation

STATIC ENET_RXDESC_T* pRXDescs = (ENET_RXDESC_T *) ENET_RX_DESC_BASE

Definition at line 95 of file enet.c.

STATIC ENET_RXSTAT_T* pRXStats = (ENET_RXSTAT_T *) ENET_RX_STAT_BASE

Definition at line 96 of file enet.c.

STATIC ENET_TXDESC_T* pTXDescs = (ENET_TXDESC_T *) ENET_TX_DESC_BASE

Definition at line 97 of file enet.c.

STATIC ENET_TXSTAT_T* pTXStats = (ENET_TXSTAT_T *) ENET_TX_STAT_BASE

Definition at line 98 of file enet.c.

STATIC int32_t rxConsumeIdx

Definition at line 101 of file enet.c.

STATIC int32_t txProduceIdx

Definition at line 102 of file enet.c.