industrialNETworXnetx

| 11.10.2007 | 16:17 | 4 replies

Ethernet: Dependencies on other drivers

To implement raw Ethernet functionality (w/o TCP/IP) are there more or less dependencies than to PHY, Xc and Fif drivers?
Or is this question to general?

Martin

M T

M T

Hilscher Gesellschaft für Systemautomation mbH

| 12.10.2007 | 13:51

I am currently not sure, what you are trying to do. (porting the Ethernet HAL Example to the netX, or use rcX) I will try to explain in detail what hardware units are used, and what drivers are available for this.

To get the Ethernet Standard MAC Software running on the netX you need access to the following elements (in brackts is the rcX driver equivalent):
- Interrupt (Drv_Int in rcX)
- Phy (Drv_Phy) to initialize the internal PHYs
- Hardware-Fifo Units (Drv_Fif)
- XC Units (Drv_Xc), for loading the microcode

On Top of these Drivers rcX provides the Drv_Edd to access the raw ethernet functionality. The Edd uses all of these Drivers to access the ethernet MAC.

PS: If you use the Ethernet HAL example you will only need the Interrupt Driver and the FIFO driver to pre-initalize the Pointer Fifo. All other components are directly accessed by the sample code.

Regards

MT

| 12.10.2007 | 14:18

Thanks. This is on rcX using Drv_Edd. I figured out that Phy, Fif and Xc is necessary. But I was not sure if this is really true. Is the order of these drivers in some way important?

Is there an example or code snippets on this raw level available? Just to verify the basics we did? The driver manual does not tell much more than the header file.

Martin

M T

M T

Hilscher Gesellschaft für Systemautomation mbH

| 15.10.2007 | 07:14

The startup order does only matter on one thing. the EDD Driver needs to be initialized after the others, to make sure it can access the proper hardware correctly.

Here is a short example of an EDD Application (with warranty on completeness):

/**************************************************************************************

Copyright (c) Hilscher GmbH. All Rights Reserved.

**************************************************************************************

Filename:
$Workfile: Edd_Example_App.c $
Last Modification:
$Author: Eddie $
$Modtime: 23.08.05 7:11 $
$Revision: 13 $

Targets:
Win32/ANSI : no
Win32/Unicode: no (define _UNICODE)
WinCE : yes
rcX : yes

Description:

Edd Test
Task Process - Simple Edd Example

Changes:

Version Date Author
Description
----------------------------------------------------------------------------------

**************************************************************************************/
#define __EDD_TEST_PROCESS_C

/****************************************************************************************
* includes */
#include "EddTest_Includes.h" /* Edd Test includes */

TLR_HANDLE hEdd;
TLR_HANDLE hEddEth=0;
TLR_HANDLE hEddApp=0;

VOID EddTest_FrameSent(RX_EDD_FRAME_BUF_T FAR* ptBuf, UINT32 ulPortNo)
{
RX_EDD_COMMBLK_T* ptCommBlk = &(ptBuf->atEth[ulPortNo & DRV_EDD_PORT_MASK]);

/* let's see if we got our frame */
Drv_EddFreeBuffer(hEdd, hEddApp, ptBuf);
}

RX_EDD_FRAME_BUF_T* EddTest_FrameRecv_Cbk(
RX_EDD_FRAME_BUF_T* ptBuf,
VOID FAR* pvUserData)
{
RX_EDD_COMMBLK_T* ptCommBlk = &(ptBuf->atEth[0]);
VOID FAR* pvProtocol = ((UINT8*) ptCommBlk->ptFrame) + ptCommBlk->ulOffset;
UINT32 ulFrameLength = ptCommBlk->ulLength;
UINT32 ulDataSize = ulFrameLength - ptCommBlk->ulOffset;

/* we should do something with the frame here
* pvProtocol points to the actual data in the frame
* ulFrameLength determines the size of the entire frame
* ulDataSize determines the size of the data in the frame
*/

return ptBuf;
}

/***************************************************************************************/
/* Edd_Test Task, Process */

/****************************************************************************************
function: TaskProcess_EddTest
description: handles the task process
- wait for requests
- wait for confirmations
- wait for indications
- check task state

global: none
input: EDD_TEST_RSC_T FAR* ptRsc - task resources
output: none
return: TLR_RESULT (TLR_S_OK == succeeded)
****************************************************************************************/
void
EddDemo(void* pvParam)
{
TLR_RESULT eRslt; /* result */
RX_EDD_MAC_ADDR_T abMacAddr;

/*
* initialize
* startup process of task -> running
*/
eRslt = TLR_S_OK;

/* we have to find our ethernet device first */
eRslt = TLR_EDD_IDENTIFY("ETHERNET", 0, &hEdd);
if(TLR_S_OK != eRslt)
{
for(;;);
}

/* now, we register our app */
eRslt = Drv_EddRegisterApp(hEdd, &hEddApp);
if(TLR_S_OK != eRslt)
{
for(;;);
}

/* fetch the mac address from the ethernet device */
eRslt = Drv_EddIoctl(hEdd, DRV_EDD_GET_MAC_ADDRESS_REQ, abMacAddr);
if(TLR_S_OK != eRslt)
{
for(;;);
}

/* register a frame callback, we specify the ether type in host byte order here */
eRslt = Drv_EddRegisterEthCb(hEdd, hEddApp, 0x0800, EddTest_FrameRecv_Cbk, 0, &hEddEth);
if(TLR_S_OK != eRslt)
{
for(;;);
}

{
UINT8 mac1[6]={0x00,0x00,0x00,0x00,0x00,0x01};
RX_EDD_ETHERNET_FRAME_T* ptFrame;
RX_EDD_FRAME_BUF_T* ptBuf;

/* we send a frame and await the returning of it */
while(RX_OK != Drv_EddGetBuffer(hEdd, hEddApp, &ptBuf));
ptFrame = ptBuf->atEth[0].ptFrame;

/* Initialize the frame */
MEMCPY(ptFrame->tEth.tDstAddr, mac1, RX_EDD_LEN_MAC);
MEMCPY(ptFrame->tEth.tSrcAddr, abMacAddr, RX_EDD_LEN_MAC);
ptFrame->tEth.usType = 0xffff;

ptBuf->atEth[0].fnSendCbk = EddTest_FrameSent;
ptBuf->atEth[0].ulLength = 60;

if(RX_OK != Drv_EddSendBuffer(hEdd, hEddApp, ptBuf))
Drv_EddFreeBuffer(hEdd, hEddApp, ptBuf);

/* we send a frame in a fire-and-forget fashion */
while(RX_OK != Drv_EddGetFrame(hEdd, hEddApp, &ptFrame));
MEMCPY(ptFrame->tEth.tDstAddr, mac1, RX_EDD_LEN_MAC);
MEMCPY(ptFrame->tEth.tSrcAddr, abMacAddr, RX_EDD_LEN_MAC);

ptFrame->tEth.usType = 0xffff;
ptBuf->atEth[0].ulLength = 60;

if(RX_OK != Drv_EddSendBuffer(hEdd, hEddApp, ptBuf))
Drv_EddFreeBuffer(hEdd, hEddApp, ptBuf);
}
}

Regards

MT

Alex

Alex

| 15.10.2007 | 10:06

hi,

talking about the internal PHY initialization the rcX Configuration manual say:

"A description of the registers (of the PHY) can be found in the PHYs user manual"

where can i find this manual?

Login