CMSIS: Cortex Microcontroller Software Interface Standard (Ethernet Device)

LPC1700CMSIS

Cortex Microcontroller Software Interface Standard
Ethernet Device

This file describes the Ethernet Device Driver for Cortex Microcontroller Software Interface Standard (CMSIS).

Version: 1.20 - 22. May 2009

Information in this file, the accompany manuals, and software is
Copyright © ARM Ltd.
All rights reserved.


Revision History

  • Revision 0.01 - November 2008: Concept
  • Revision 0.06 - February 2009: Added Multicast
  • Revision 1.00 - February 2009: Added RxFrameReady callback, added SetMCFilter function
  • Revision 1.10 - February 2009: First Release
  • Revision 1.20 - May 2009: Second Release

Contents

  1. About
  2. CMSIS Ethernet Device Files
  3. CMSIS Ethernet Device Definitions
  4. CMSIS Ethernet Device I/O Block
  5. CMSIS Ethernet Device Functions
  6. CMSIS Ethernet Device Callback Functions
  7. CMSIS Ethernet Example Drivers
  8. Flowcharts

 

About

The CMSIS Ethernet Device provides a standard interface to an Ethernet Controller that is part of a Cortex-M3 system. This interface is an hardware abstraction layer between the Ethernet Controller and a communication (TCP/IP) stack. It consists of a general Ethernet Device Driver (files EthDev.h) and a device specific Ethernet Device Driver (files EthDev_LM3C.[h,c]). The device specific Ethernet Device Driver provides an I/O Block which is used to select, configure and access the Device Driver. Each Ethernet Device needs a device specific Ethernet Device Driver which provides it's own I/O block. The I/O blocks differ in their names (eth0, eth1, ...).

 

CMSIS Ethernet Device Files

The driver consists of a generic include file EthDev.h and the device specific driver files EthDev_<device>.c and EthDev_<device>.h. The device specific driver files are provided by the device vendor. The naming conventions are EthDev_<device>.[c,h]. The device vendor specifies <device>.

Name Description
EthDev.h Global defines and structure definitions for general Ethernet Device interface.
EthDev_<device>.h Device dependent definitions of the device specific Ethernet Device Driver.
EthDev_<device>.c Device specific Ethernet Device Driver.

File EthDev.h

Description File EthDev.h contains function prototypes and type definitions for configuration and status values. Also global defines are part of this file. File EthDev.h must be included in the communication (TCP/IP) stack. This file contains the type definition for I/O Block. The I/O block contains configuration values and function pointer to access the device specific Ethernet Device Driver

File EthDev_<device>.h

Description File EthDev_<device>.h contains device specific defines like registers and register values. It is only included from file EthDev_<device>.c.

File EthDev_<device>.c

Description File EthDev_<device>.c contains the device specific Ethernet Device Driver. Provides the Device Driver specific I/O Block. It must be linked to the communication (TCP/IP) stack.

 

CMSIS Ethernet Device Definitions

Ethernet Device Driver uses following definitions for configuartion and function parameter values:

Name Description
Global Defines Global define values.
Link Mode Configuration values for the used link mode.
Link State Link state values.
Link Speed Link speed values.
Link Duplex Link duplex values
Link Status Provides attributes for current link state, link speed and link duplex

Global Defines

Summary
#define EthDev_ADDR_SIZE         6
#define EthDev_MTU_SIZE       1514
Description

This two defines are used from the Ethernet Device Driver.

Define

EthDev_ADDR_SIZE
Ethernet Address size in bytes.

EthDev_MTU_SIZE
Maximum Transmission Unit size.

Link Mode

Summary
typedef enum {
  EthDev_MODE_AUTO              = 0,
  EthDev_MODE_10M_FULL          = 1,
  EthDev_MODE_10M_HALF          = 2,
  EthDev_MODE_100M_FULL         = 3,
  EthDev_MODE_100M_HALF         = 4,
  EthDev_MODE_1000M_FULL        = 5,
  EthDev_MODE_1000M_HALF        = 6,
} EthDev_MODE;
Description

Link Mode values and explanation.

Link Mode

EthDev_MODE_AUTO
Ethernet link speed and link duplex depend on autonegothiation.

EthDev_MODE_10M_FULL
Use 10.0 Mbps link speed with full duplex.

EthDev_MODE_10M_HALF
Use 10.0 Mbps link speed with half duplex.

EthDev_MODE_100M_FULL
Use 100.0 Mbps link speed with full duplex.

EthDev_MODE_100M_HALF
Use 100.0 Mbps link speed with half duplex.

EthDev_MODE_1000M_FULL
Use 1000.0 Mbps link speed with full duplex.

EthDev_MODE_1000M_HALF
Use 1000.0 Mbps link speed with half duplex.

Link State

Summary
typedef enum {
  EthDev_LINK_DOWN              = 0,
  EthDev_LINK_UP                = 1,
} EthDev_LINK;
Description

Link State values and explanation.

Link State

EthDev_LINK_DOWN
Ethernet link is not established.

EthDev_LINK_UP
Ethernet link is established.

Link Speed

Summary
typedef enum {
  EthDev_SPEED_10M              = 0,
  EthDev_SPEED_100M             = 1,
  EthDev_SPEED_1000M            = 2,
} EthDev_SPEED;
Description

Link Speed values and explanation.

Link Speed

EthDev_SPEED_10M
10.0 Mbps link speed.

EthDev_SPEED_100M
100.0 Mbps link speed.

EthDev_SPEED_1000M
1000.0 Mbps link speed.

Link Duplex

Summary
typedef enum {
  EthDev_DUPLEX_HALF            = 0,
  EthDev_DUPLEX_FULL            = 1,
} EthDev_DUPLEX;
Description

Link Duplex values and explanation.

Link Duplex

EthDev_DUPLEX_HALF
Link half duplex.

EthDev_DUPLEX_FULL
Link full duplex.

Link Status

Summary
typedef struct {
  EthDev_LINK   Link   : 1;
  EthDev_DUPLEX Duplex : 1;
  EthDev_SPEED  Speed  : 2;
} EthDev_STATUS;
Description

Link Status attributes and explanation.

Attributes

Link
Valid values are:

  • EthDev_LINK_DOWN
  • EthDev_LINK_Up

Duplex
Valid values are:

  • EthDev_DUPLEX_HALF
  • EthDev_DUPLEX_Full

Speed
Valid values are:

  • EthDev_SPEED_10M
  • EthDev_SPEED_100M
  • EthDev_SPEED_1000M

 

CMSIS Ethernet Device I/O Block

Ethernet Device Driver defines the following structure to pass initialization data and to access device specific functions:

Name Description
EthDev_IOB Structure to pass configuration values and callback functions to the Ethernet Device Driver.

Structure EthDev_IOB

Summary
typedef struct {
   EthDev_MODE   Mode;
   unsigned char HwAddr[EthDev_ADDR_SIZE];
   void         *(*RxFrame)      (int size);
   void          (*RxFrameReady) (int size);

   int           (*Init)       (void);
   int           (*UnInit)     (void);
   int           (*SetMCFilter)(int NumHwAddr, unsigned char *pHwAddr);
   int           (*TxFrame)    (void *pData, int size);
   void          (*Lock)       (void);
   void          (*UnLock)     (void);
   EthDev_STATUS (*LinkChk)    (void);
} EthDev_IOB;
Description

This structure is used to hold configuration values and function pointer to access the device specific Ethernet Device Driver. The configuration values are preset with default values.

Attributes

Mode
Selects the mode in which the Ethernet link is established.
Valid values are:

  • EthDev_MODE_AUTO (default)
  • EthDev_MODE_10M_FULL
  • EthDev_MODE_10M_HALF
  • EthDev_MODE_100M_FULL
  • EthDev_MODE_100M_HALF
  • EthDev_MODE_1000M_FULL
  • EthDev_MODE_1000M_HALF

EthHwAddr
Contains the 6 byte MAC address. Default value is "0,0,0,0,0,0". If EthHwAddr address is 00:00:00:00:00:00, then the driver shall use it's own MAC which is stored in HW (e.g. EEPROM). After this MAC is used, the Init function shall copy the used MAC to this entry to provide the application the MAC address for the Ethernet Device. If EthHwAddr is not 0, then this MAC shall be used.

void *(*RxFrame) (int size)
Callback function. Called when a frame is received. This function pointer must be set before the Init function is called.

void (*RxFrame) (int size)
Callback function. Called after the frame is copied to the application buffer. This function pointer is optional. In case of NULL the function is omitted.

int (*Init) (void)
Function pointer to Init function.

int (*UnInit) (void)
Function pointer to UnInit function.

int (*SetMCFilter) (int NumHwAddr, unsigned char *pHwAddr)
Function pointer to set Multicast filter function.

int (*EthDev_FrameTx) (void *pData, int size)
Function pointer to frame transmit function.

void (*Lock) (void)
Function pointer to device lock function.

void (*UnLock) (void)
Function pointer to device unlock function.

 

CMSIS Ethernet Device Functions

Ethernet Device Driver contains the following public functions:

Name Description
EthDev_Init Initialize and start the Ethernet Device Driver.
EthDev_UnInit Uninitialize and stop the Ethernet Device Driver.
EthDev_SetMCFilter Set Multicast filters addresses.
EthDev_TxFrame Pass a frame to the EThernet Device Driver to transmit.
EthDev_Lock Lock the Ethernet Device Driver (mask interrupt).
EthDev_Unlock Unlock the Ethernet Device Driver (unmask interrupt).
EthDev_LinkChk Retrieve the current link status.

Function EthDev_Init

Summary
static int EthDev_Init (void);
Description This function initializes the Ethernet Device Driver according the EthDev_IOB structure and starts it.
Parameter none
Return Code
  • Success (0)
  • Failed (-1)

Function EthDev_UnInit

Summary
static int EthDev_UnInit (void);
Description This function uninitializes the Ethernet Device Driver and stops it.
Parameter none
Return Code
  • Success (0)
  • Failed (-1)

Function EthDev_SetMCFilter

Summary
static int EthDev_SetMCFilter (int NumHwAddr, unsigned char *pHwAddr);
Description This function sets the Multicast filter addresses within the specific Ethernet Device Driver. The passed Multicast addresses can be used to set up a hash address filter table. It depends on the device capabilities how the device is configured with the Multicast addresses.
Parameter

NumHwAddr
Number of passed Multicast addresses.

pHwAddr
Pointer to the Multicast addresses.

Return Code
  • Success (0)
  • Failed (-1)

Function EthDev_TxFrame

Summary
static int EthDev_TxFrame (void *pData, int size);
Description This function passes a frame to the specific Ethernet Device Driver to transmit.
Parameter

pData
Pointer to the data to send.

size
Number of bytes to send.

Return Code
  • Success (0)
  • Failed (-1)

Function EthDev_Lock

Summary
static void EthDev_Lock (void);
Description This function locks the specific Ethernet Device Driver. The corresponding interrupt is disabled.
Parameter none
Return Code none

Function EthDev_Unlock

Summary
static void EthDev_UnLock (void);
Description This function unlocks the specific Ethernet Device Driver. The corresponding interrupt is enabled.
Parameter none
Return Code none

Function EthDev_LinkChk

Summary
static EthDev_STATUS EthDev_LinkChk (void);
Description This function returns the current link status. It performs also a post configuration for the selected link speed and link duplex. It must be called in a timely manner to detect changes in the link state.
Parameter none
Return Code Link status containing link speed, link duplex and link state.

 

CMSIS Ethernet Device Callback Functions

The application must provide following callback functions which are called from the specific Ethernet Device Driver upon recieve frame event:

Name Description
RxFrame Called after a frame is received.
RxFrameReady Called after a frame is copied to the application buffer.

Callback Function RxFrame

Summary
void *RxFrame (int size);
Description This function is called after Ethernet Device driver received a frame. It returns the start address of an application buffer to which the received frame is copied.
This function runs in the Ethernet Device driver interrupt context.
Parameter

size
Size of the received frame.

Return Code Pointer to memory block

Callback Function RxFrameReady

Summary
void RxFrameReady (int size);
Description This function is called after Ethernet Device driver has copied a frame to the application buffer. This function is optional. If a NULL pointer is passed via the IO block than the function call is omitted.
This function runs in the Ethernet Device driver interrupt context.
Parameter

size
Size of the copied frame.

Return Code None

 

CMSIS Ethernet Example Drivers

CMSIS Ethernet example drivers are provided for:

  • Luminary Micro LM3S6965
    Files EthDev_LM3S.h, EthDev_LM3S.c
  • NXP LPC1768
    Files EthDev_LPC17xx.h, EthDev_LPC17xx.c

 

Flowcharts

The following Flowchart shows a typical Ethernet Device flow.

CMSIS_EthDev_Interrupt

The following Flowchart shows how multicast support can be changed.

CMSIS_EthDev_Multicast