Callback init function, Callback txdone function, Callback receive function – Comtrol eCos User Manual

Page 609: Calling graph for transmission and reception, Callback tx-done function, Transmission

Advertising
background image

Chapter 46. Generic Ethernet Device Driver

These functions require a pointer to a struct eth_drv_sc which describes the interface at a logical level. It is assumed
that the low level hardware driver will keep track of this pointer so it may be passed “up” as appropriate.

Callback Init function

void (sc->funs->eth_drv->init)(

struct eth_drv_sc *sc, unsigned char *enaddr)

This function establishes the device at initialization time. It should be called once per device instance only, from the
initialization function, if all is well (see

the Section called Init function

). The hardware should be totally initialized

(not “started”) when this function is called.

Callback Tx-Done function

void (sc->funs->eth_drv->tx_done)(

struct eth_drv_sc *sc,

unsigned long key, int status)

This function is called when a packet completes transmission on the interface. The

key

value must be one of the

keys provided to

HRDWR_send()

above. The value

status

should be non-zero (details currently undefined) to

indicate that an error occurred during the transmission, and zero if all was well.

It should be called from the deliver function (see

the Section called Deliver function

) or poll function (see

the

Section called Poll function

).

Callback Receive function

void (sc->funs->eth_drv->recv)(struct eth_drv_sc *sc, int len)

This function is called to indicate that a packet of length

len

has arrived at the interface. The callback

HRDWR_recv()

function described above will be used to actually unload the data from the interface into buffers

used by the device independent layers.

It should be called from the deliver function (see

the Section called Deliver function

) or poll function (see

the

Section called Poll function

).

Calling graph for Transmission and Reception

It may be worth clarifying further the flow of control in the transmit and receive cases, where the hardware driver
does use interrupts and so DSRs to tell the “foreground” when something asynchronous has occurred.

505

Advertising