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
- About
- CMSIS Ethernet Device Files
- CMSIS Ethernet Device Definitions
- CMSIS Ethernet Device I/O Block
- CMSIS Ethernet Device Functions
- CMSIS Ethernet Device Callback Functions
- CMSIS Ethernet Example Drivers
- 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 EthDev_MTU_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 EthDev_MODE_10M_FULL EthDev_MODE_10M_HALF EthDev_MODE_100M_FULL EthDev_MODE_100M_HALF EthDev_MODE_1000M_FULL EthDev_MODE_1000M_HALF |
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 EthDev_LINK_UP |
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 EthDev_SPEED_100M EthDev_SPEED_1000M |
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 EthDev_DUPLEX_FULL |
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
Duplex
Speed
|
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
EthHwAddr void *(*RxFrame) (int size) void (*RxFrame) (int size) int (*Init) (void) int (*UnInit) (void) int (*SetMCFilter) (int NumHwAddr, unsigned char *pHwAddr) int (*EthDev_FrameTx) (void *pData, int size) void (*Lock) (void) void (*UnLock) (void) |
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 |
|
Function EthDev_UnInit
| Summary |
static int EthDev_UnInit (void); |
| Description | This function uninitializes the Ethernet Device Driver and stops it. |
| Parameter | none |
| Return Code |
|
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 pHwAddr |
| Return Code |
|
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 size |
| Return Code |
|
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 |
| 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 |
| 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.
The following Flowchart shows how multicast support can be changed.