Skip to content

Ethernet ​

Ethernet Interface API.

The API is a simplified API that does not offer all Ethernet MAC related configuration options, because the operating system has mainly been designed for battery-operated devices with RF interfaces. Nevertheless, the API allows for full-fledged TCP/IP communication over Ethernet.

Sysprops ​

The Ethernet driver does not have any sysprops defined.

Types ​

Name
structethif_config
Configuration settings for the Ethernet interface.
structeth_hw_address_t
Structure representing an Ethernet hardware address.

Functions Overview ​

Name
CW_DRIVER_FUNCethif_config(int hDev, int flags)
Configures the Ethernet interface with the specified flags.
CW_DRIVER_FUNCethif_set_hwaddr(int hDev, eth_hw_address_t * hwaddr)
Sets the hardware address of a specified device in the Ethernet interface.
CW_DRIVER_FUNCethif_hwaddr(int hDev, eth_hw_address_t * hwaddr)
Get the hardware address of a network device.
CW_DRIVER_FUNCethif_up(int hDev, struct ethif_config * config)
Bring up an Ethernet interface.
CW_DRIVER_FUNCethif_down(int hDev)
Takes a device handle and brings down the Ethernet interface associated with it.

Defines ​

Name
ETH_MAC_SPEED_10M
ETH_MAC_SPEED
ETH_MAC_SPEED_1G
ETH_MAC_DUPLEX_HALF
ETH_MAC_DUPLEX_FULL
ETH_MAC_LOOPBACK
ETH_MAC_CS_OFFLOAD_RX
ETH_MAC_CS_OFFLOAD_TX
ETH_MAC_ADDR_BROADCAST
ETH_MAC_ADDR_MULTICAST
ARM_ETH_MAC_ADDRESS_ALL

Function Details ​

function ethif_config ​

cpp
CW_DRIVER_FUNC ethif_config(
    int hDev,
    int flags
)

Configures the Ethernet interface with the specified flags.

Parameters:

  • hDev The handle of the device representing the Ethernet interface
  • flags The configuration flags to be set

Returns:

  • 0 Operation completed successfully
  • <0 An error occured during the configuration

Return: The result of the configuration operation

This function is used to configure the Ethernet interface with the specified flags.

function ethif_set_hwaddr ​

cpp
CW_DRIVER_FUNC ethif_set_hwaddr(
    int hDev,
    eth_hw_address_t * hwaddr
)

Sets the hardware address of a specified device in the Ethernet interface.

Parameters:

  • hDev The handle of the device.
  • hwaddr Pointer to the eth_hw_address_t structure representing the hardware address.

Return: Returns CW_DRIVER_OK if the hardware address is set successfully, otherwise returns an error code.

This function sets the hardware address (MAC address) of the specified device in the Ethernet interface.

function ethif_hwaddr ​

cpp
CW_DRIVER_FUNC ethif_hwaddr(
    int hDev,
    eth_hw_address_t * hwaddr
)

Get the hardware address of a network device.

Parameters:

  • hDev The handle of the network device
  • hwaddr Pointer to an eth_hw_address_t structure where the hardware address will be stored

Return: The result of the function execution. Returns a negative value if an error occurred, and 0 otherwise.

This function retrieves the hardware address of a network device.

function ethif_up ​

cpp
CW_DRIVER_FUNC ethif_up(
    int hDev,
    struct ethif_config * config
)

Bring up an Ethernet interface.

Parameters:

  • hDev The handle to the device.
  • config The configuration for the Ethernet interface.

Return: CW_DRIVER_OK if successful, otherwise an error code.

This function brings up the specified Ethernet interface.

function ethif_down ​

cpp
CW_DRIVER_FUNC ethif_down(
    int hDev
)

Takes a device handle and brings down the Ethernet interface associated with it.

Parameters:

  • hDev The device handle for the Ethernet interface.

Return: None.

This function brings down the specified Ethernet interface.

Macros Documentation ​

define ETH_MAC_SPEED_10M ​

cpp
#define ETH_MAC_SPEED_10M (0)

define ETH_MAC_SPEED ​

cpp
#define ETH_MAC_SPEED 100M       (1)

define ETH_MAC_SPEED_1G ​

cpp
#define ETH_MAC_SPEED_1G (2)

define ETH_MAC_DUPLEX_HALF ​

cpp
#define ETH_MAC_DUPLEX_HALF (0)

define ETH_MAC_DUPLEX_FULL ​

cpp
#define ETH_MAC_DUPLEX_FULL (4)

define ETH_MAC_LOOPBACK ​

cpp
#define ETH_MAC_LOOPBACK (8)

define ETH_MAC_CS_OFFLOAD_RX ​

cpp
#define ETH_MAC_CS_OFFLOAD_RX (16)

define ETH_MAC_CS_OFFLOAD_TX ​

cpp
#define ETH_MAC_CS_OFFLOAD_TX (32)

define ETH_MAC_ADDR_BROADCAST ​

cpp
#define ETH_MAC_ADDR_BROADCAST (64)

define ETH_MAC_ADDR_MULTICAST ​

cpp
#define ETH_MAC_ADDR_MULTICAST (128)

define ARM_ETH_MAC_ADDRESS_ALL ​

cpp
#define ARM_ETH_MAC_ADDRESS_ALL (ETH_MAC_ADDR_BROADCAST | ETH_MAC_ADDR_MULTICAST)