This file implements Ethernet network interface drivers for lwIP. More...
#include "stm32_def.h"#include "lwip/timeouts.h"#include "netif/etharp.h"#include "ethernetif.h"#include <string.h>#include "PeripheralPins.h"#include "lwip/igmp.h"#include "stm32_eth.h"#include "variant.h"
Macros | |
| #define | IFNAME0 's' |
| #define | IFNAME1 't' |
| #define | PHY_SR_AUTODONE ((uint16_t)0x1000) |
| #define | MAC_ADDR0 0x00 |
| #define | MAC_ADDR1 0x80 |
| #define | MAC_ADDR2 0xE1 |
| #define | MAC_ADDR3 ((uint8_t)(((*(uint32_t *)UID_BASE) & 0x00FF0000) >> 16)) |
| #define | MAC_ADDR4 ((uint8_t)(((*(uint32_t *)UID_BASE) & 0x0000FF00) >> 8)) |
| #define | MAC_ADDR5 ((uint8_t)((*(uint32_t *)UID_BASE) & 0x000000FF)) |
Functions | |
| void | HAL_ETH_MspInit (ETH_HandleTypeDef *heth) |
| Initialize the ETH MSP. | |
| void | ethernetif_input (struct netif *netif) |
| Read one received frame from the MAC and pass it to LwIP. | |
| uint8_t | ethernetif_is_init (void) |
| Check whether the Ethernet hardware has been initialized. | |
| err_t | ethernetif_init (struct netif *netif) |
| LwIP network interface initialization callback. | |
| u32_t | sys_now (void) |
| Return the current time in milliseconds. | |
| void | ethernetif_set_link (struct netif *netif) |
| Poll the PHY and update the LwIP link state of the interface. | |
| void | ethernetif_update_config (struct netif *netif) |
| Apply the PHY auto-negotiation result to the MAC. | |
| __weak void | ethernetif_notify_conn_changed (struct netif *netif) |
| Notify the user that the link status has changed. | |
| void | ethernetif_set_mac_addr (const uint8_t *mac) |
| Set the MAC address used by the driver. | |
| void | ethernetif_get_mac_addr (uint8_t *mac) |
| Copy the MAC address used by the driver. | |
Variables | |
| ETH_DMADescTypeDef | DMARxDscrTab [ETH_RXBUFNB] |
| ETH_DMADescTypeDef | DMATxDscrTab [ETH_TXBUFNB] |
| uint8_t | Rx_Buff [ETH_RXBUFNB][ETH_RX_BUF_SIZE] |
| uint8_t | Tx_Buff [ETH_TXBUFNB][ETH_TX_BUF_SIZE] |
This file implements Ethernet network interface drivers for lwIP.
Redistribution and use in source and binary forms, with or without modification, are permitted, provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
| #define IFNAME0 's' |
| #define IFNAME1 't' |
| #define MAC_ADDR0 0x00 |
| #define MAC_ADDR1 0x80 |
| #define MAC_ADDR2 0xE1 |
| #define MAC_ADDR3 ((uint8_t)(((*(uint32_t *)UID_BASE) & 0x00FF0000) >> 16)) |
| #define MAC_ADDR4 ((uint8_t)(((*(uint32_t *)UID_BASE) & 0x0000FF00) >> 8)) |
| #define MAC_ADDR5 ((uint8_t)((*(uint32_t *)UID_BASE) & 0x000000FF)) |
| #define PHY_SR_AUTODONE ((uint16_t)0x1000) |
| void ethernetif_get_mac_addr | ( | uint8_t * | mac | ) |
Copy the MAC address used by the driver.
| mac | Buffer of at least 6 bytes that receives the address. Nothing is copied if NULL. |
| err_t ethernetif_init | ( | struct netif * | netif | ) |
LwIP network interface initialization callback.
Sets the interface name, the output functions and initializes the Ethernet hardware. Pass it to netif_add().
| netif | The LwIP network interface to initialize. |
| void ethernetif_input | ( | struct netif * | netif | ) |
Read one received frame from the MAC and pass it to LwIP.
Does nothing when no frame is available. If netif->input() fails, the frame is dropped.
| netif | The LwIP network interface. |
| uint8_t ethernetif_is_init | ( | void | ) |
Check whether the Ethernet hardware has been initialized.
| __weak void ethernetif_notify_conn_changed | ( | struct netif * | netif | ) |
Notify the user that the link status has changed.
Weak function. The default implementation does nothing, and user code can override it.
| netif | The LwIP network interface. Not used by the default implementation. |
| void ethernetif_set_link | ( | struct netif * | netif | ) |
Poll the PHY and update the LwIP link state of the interface.
The link is set down when the PHY reports a link-change interrupt, and up when the PHY reports a linked state. With LWIP_IGMP, IGMP is started on the first link-up.
| netif | The LwIP network interface. |
| void ethernetif_set_mac_addr | ( | const uint8_t * | mac | ) |
Set the MAC address used by the driver.
Call it before ethernetif_init(). The address is copied only while the driver is not initialized.
| mac | 6-byte MAC address. Ignored if NULL. |
| void ethernetif_update_config | ( | struct netif * | netif | ) |
Apply the PHY auto-negotiation result to the MAC.
Restarts the MAC with the negotiated duplex and speed, or stops the MAC when the link is down. If auto-negotiation is disabled or has not completed, the configured duplex and speed are used. Calls ethernetif_notify_conn_changed() at the end. Call it when the link status changes.
| netif | The LwIP network interface. |
| void HAL_ETH_MspInit | ( | ETH_HandleTypeDef * | heth | ) |
Initialize the ETH MSP.
Configures the GPIO pins listed in PinMap_Ethernet as alternate functions, enables the ETH interrupt when ETH_INPUT_USE_IT is defined, and enables the ETH peripheral clock.
| heth | ETH handle. Not used. |
| u32_t sys_now | ( | void | ) |
Return the current time in milliseconds.
Used by LwIP when LWIP_TIMERS is 1 and NO_SYS is 1.
| ETH_DMADescTypeDef DMARxDscrTab[ETH_RXBUFNB] |
< IAR Compiler
| ETH_DMADescTypeDef DMATxDscrTab[ETH_TXBUFNB] |
< IAR Compiler
| uint8_t Rx_Buff[ETH_RXBUFNB][ETH_RX_BUF_SIZE] |
< IAR Compiler
| uint8_t Tx_Buff[ETH_TXBUFNB][ETH_TX_BUF_SIZE] |
< IAR Compiler