Adapted to Lora Semtech + Nucleo

Dependencies:   DebugLib

Dependents:   LoRaWAN-lmic-app LoRaWAN-lmic-app LoRaWAN-test-10secs LoRaPersonalizedDeviceForEverynet ... more

Fork of lwip_ppp_ethernet by Donatien Garnier

Embed: (wiki syntax)

« Back to documentation index

lpc17 EMAC driver for LWIP

lpc17 EMAC driver for LWIP

Functions

 ALIGNED (8)
 LPC EMAC driver work data.
err_t lpc_mii_write (u32_t PhyReg, u32_t Value)
 Write a value via the MII link (blocking)
u32_t lpc_mii_is_busy (void)
 Reads current MII link busy status.
u32_t lpc_mii_read_data (void)
 Starts a read operation via the MII link (non-blocking)
void lpc_mii_read_noblock (u32_t PhyReg)
 Read a value via the MII link (blocking)
err_t lpc_mii_read (u32_t PhyReg, u32_t *data)
 Starts a read operation via the MII link (non-blocking)
static void lpc_rxqueue_pbuf (struct lpc_enetdata *lpc_enetif, struct pbuf *p)
 Queues a pbuf into the RX descriptor list.
s32_t lpc_rx_queue (struct netif *netif)
 Attempt to allocate and requeue a new pbuf for RX.
static err_t lpc_rx_setup (struct lpc_enetdata *lpc_enetif)
 Sets up the RX descriptor ring buffers.
static struct pbuf * lpc_low_level_input (struct netif *netif)
 Allocates a pbuf and returns the data from the incoming packet.
void lpc_enetif_input (struct netif *netif)
 Attempt to read a packet from the EMAC interface.
static s32_t lpc_packet_addr_notsafe (void *addr)
 Determine if the passed address is usable for the ethernet DMA controller.
static err_t lpc_tx_setup (struct lpc_enetdata *lpc_enetif)
 Sets up the TX descriptor ring buffers.
static void lpc_tx_reclaim_st (struct lpc_enetdata *lpc_enetif, u32_t cidx)
 Free TX buffers that are complete.
void lpc_tx_reclaim (struct netif *netif)
 User call for freeingTX buffers that are complete.
s32_t lpc_tx_ready (struct netif *netif)
 Polls if an available TX descriptor is ready.
static err_t lpc_low_level_output (struct netif *netif, struct pbuf *p)
 Low level output of a packet.
void ENET_IRQHandler (void)
 LPC EMAC interrupt handler.
static void packet_receive (void const *pvParameters)
 Packet reception task.
static void transmit_cleanup (void const *pvParameters)
 Transmit cleanup task.
static err_t low_level_init (struct netif *netif)
 Low level init of the MAC and PHY.
void lpc_emac_set_duplex (int full_duplex)
 This function provides a method for the PHY to setup the EMAC for the PHY negotiated duplex mode.
void lpc_emac_set_speed (int mbs_100)
 This function provides a method for the PHY to setup the EMAC for the PHY negotiated bit rate.
err_t lpc_etharp_output (struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr)
 This function is the ethernet packet send function.
err_t lpc_enetif_init (struct netif *netif)
 Should be called at the beginning of the program to set up the network interface.

Function Documentation

ALIGNED (  )

LPC EMAC driver work data.

Definition at line 140 of file lpc17_emac.c.

void ENET_IRQHandler ( void   )

LPC EMAC interrupt handler.

This function handles the transmit, receive, and error interrupt of the LPC177x_8x. This is meant to be used when NO_SYS=0.

Definition at line 742 of file lpc17_emac.c.

static err_t low_level_init ( struct netif netif ) [static]

Low level init of the MAC and PHY.

Parameters:
[in]netifPointer to LWIP netif structure

Definition at line 861 of file lpc17_emac.c.

void lpc_emac_set_duplex ( int  full_duplex )

This function provides a method for the PHY to setup the EMAC for the PHY negotiated duplex mode.

Parameters:
[in]full_duplex0 = half duplex, 1 = full duplex

Definition at line 941 of file lpc17_emac.c.

void lpc_emac_set_speed ( int  mbs_100 )

This function provides a method for the PHY to setup the EMAC for the PHY negotiated bit rate.

Parameters:
[in]mbs_1000 = 10mbs mode, 1 = 100mbs mode

Definition at line 956 of file lpc17_emac.c.

err_t lpc_enetif_init ( struct netif netif )

Should be called at the beginning of the program to set up the network interface.

This function should be passed as a parameter to netif_add().

Parameters:
[in]netifthe lwip network interface structure for this lpc_enetif
Returns:
ERR_OK if the loopif is initialized ERR_MEM if private data couldn't be allocated any other err_t on error

Definition at line 994 of file lpc17_emac.c.

void lpc_enetif_input ( struct netif netif )

Attempt to read a packet from the EMAC interface.

Parameters:
[in]netifthe lwip network interface structure for this lpc_enetif

Definition at line 458 of file lpc17_emac.c.

err_t lpc_etharp_output ( struct netif netif,
struct pbuf *  q,
ip_addr_t *  ipaddr 
)

This function is the ethernet packet send function.

It calls etharp_output after checking link status.

Parameters:
[in]netifthe lwip network interface structure for this lpc_enetif
[in]qPointer to pbug to send
[in]ipaddrIP address
Returns:
ERR_OK or error code

Definition at line 973 of file lpc17_emac.c.

static struct pbuf* lpc_low_level_input ( struct netif netif ) [static, read]

Allocates a pbuf and returns the data from the incoming packet.

Parameters:
[in]netifthe lwip network interface structure for this lpc_enetif
Returns:
a pbuf filled with the received packet (including MAC header) NULL on memory error

Definition at line 337 of file lpc17_emac.c.

static err_t lpc_low_level_output ( struct netif netif,
struct pbuf *  p 
) [static]

Low level output of a packet.

Never call this from an interrupt context, as it may block until TX descriptors become available.

Parameters:
[in]netifthe lwip network interface structure for this lpc_enetif
[in]pthe MAC packet to send (e.g. IP packet including MAC addresses and type)
Returns:
ERR_OK if the packet could be sent or an err_t value if the packet couldn't be sent

Definition at line 613 of file lpc17_emac.c.

u32_t lpc_mii_is_busy ( void   )

Reads current MII link busy status.

This function will return the current MII link busy status and is meant to be used with non-blocking functions for monitor PHY status such as connection state.

Returns:
!0 if the MII link is busy, otherwise 0

Definition at line 177 of file lpc17_emac.c.

err_t lpc_mii_read ( u32_t  PhyReg,
u32_t *  data 
)

Starts a read operation via the MII link (non-blocking)

This function will start a read operation on the MII link interface from a PHY or a connected device. The function will not block and the status mist be polled until complete. Once complete, the data can be read.

Parameters:
[in]PhyRegPHY register to read from

Definition at line 200 of file lpc17_emac.c.

u32_t lpc_mii_read_data ( void   )

Starts a read operation via the MII link (non-blocking)

This function returns the current value in the MII data register. It is meant to be used with the non-blocking oeprations. This value should only be read after a non-block read command has been issued and the MII status has been determined to be good.

Returns:
The current value in the MII value register

Definition at line 183 of file lpc17_emac.c.

void lpc_mii_read_noblock ( u32_t  PhyReg )

Read a value via the MII link (blocking)

This function will read a value on the MII link interface from a PHY or a connected device. The function will block until complete.

Parameters:
[in]PhyRegPHY register to read from
[in]dataPointer to where to save data read via MII
Returns:
0 if the read was successful, otherwise !0

Definition at line 192 of file lpc17_emac.c.

err_t lpc_mii_write ( u32_t  PhyReg,
u32_t  Value 
)

Write a value via the MII link (blocking)

This function will write a value on the MII link interface to a PHY or a connected device. The function will block until complete.

Parameters:
[in]PhyRegPHY register to write to
[in]ValueValue to write
Returns:
0 if the write was successful, otherwise !0

Definition at line 151 of file lpc17_emac.c.

static s32_t lpc_packet_addr_notsafe ( void *  addr ) [static]

Determine if the passed address is usable for the ethernet DMA controller.

Parameters:
[in]addrAddress of packet to check for DMA safe operation
Returns:
1 if the packet address is not safe, otherwise 0

Definition at line 499 of file lpc17_emac.c.

s32_t lpc_rx_queue ( struct netif netif )

Attempt to allocate and requeue a new pbuf for RX.

Parameters:
[in]netifPointer to the netif structure
Returns:
1 if a packet was allocated and requeued, otherwise 0

Definition at line 269 of file lpc17_emac.c.

static err_t lpc_rx_setup ( struct lpc_enetdata *  lpc_enetif ) [static]

Sets up the RX descriptor ring buffers.

This function sets up the descriptor list used for receive packets.

Parameters:
[in]lpc_enetifPointer to driver data structure
Returns:
Always returns ERR_OK

Definition at line 313 of file lpc17_emac.c.

static void lpc_rxqueue_pbuf ( struct lpc_enetdata *  lpc_enetif,
struct pbuf *  p 
) [static]

Queues a pbuf into the RX descriptor list.

Parameters:
[in]lpc_enetifPointer to the drvier data structure
[in]pPointer to pbuf to queue

Definition at line 233 of file lpc17_emac.c.

s32_t lpc_tx_ready ( struct netif netif )

Polls if an available TX descriptor is ready.

Can be used to determine if the low level transmit function will block.

Parameters:
[in]netifthe lwip network interface structure for this lpc_enetif
Returns:
0 if no descriptors are read, or >0

Definition at line 585 of file lpc17_emac.c.

void lpc_tx_reclaim ( struct netif netif )

User call for freeingTX buffers that are complete.

Parameters:
[in]netifthe lwip network interface structure for this lpc_enetif

Definition at line 573 of file lpc17_emac.c.

static void lpc_tx_reclaim_st ( struct lpc_enetdata *  lpc_enetif,
u32_t  cidx 
) [static]

Free TX buffers that are complete.

Parameters:
[in]lpc_enetifPointer to driver data structure
[in]cidxEMAC current descriptor comsumer index

Definition at line 538 of file lpc17_emac.c.

static err_t lpc_tx_setup ( struct lpc_enetdata *  lpc_enetif ) [static]

Sets up the TX descriptor ring buffers.

This function sets up the descriptor list used for transmit packets.

Parameters:
[in]lpc_enetifPointer to driver data structure

Definition at line 513 of file lpc17_emac.c.

static void packet_receive ( void const *  pvParameters ) [static]

Packet reception task.

This task is called when a packet is received. It will pass the packet to the LWIP core.

Parameters:
[in]pvParametersNot used yet

Definition at line 789 of file lpc17_emac.c.

static void transmit_cleanup ( void const *  pvParameters ) [static]

Transmit cleanup task.

This task is called when a transmit interrupt occurs and reclaims the pbuf and descriptor used for the packet once the packet has been transferred.

Parameters:
[in]pvParametersNot used yet

Definition at line 811 of file lpc17_emac.c.