-
Notifications
You must be signed in to change notification settings - Fork 0
/
nic.h
71 lines (62 loc) · 3.1 KB
/
nic.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*! \file nic.h \brief Network Interface Card (NIC) software definition. */
//*****************************************************************************
//
// File Name : 'nic.h'
// Title : Network Interface Card (NIC) software definition
// Author : Pascal Stang
// Created : 8/22/2004
// Revised : 7/3/2005
// Version : 0.1
// Target MCU : Atmel AVR series
// Editor Tabs : 4
//
/// \ingroup network
/// \defgroup nic Network Interface Card (NIC) software definition (nic.h)
/// \code #include "net/nic.h" \endcode
/// \par Description
/// This is the software interface standard for network interface hardware
/// as used by AVRlib. Drivers for network hardware must implement these
/// functions to allow upper network layers to initialize the interface,
/// and send and receive net traffic.
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
//*****************************************************************************
//@{
#ifndef NIC_H
#define NIC_H
#include "avrlibtypes.h"
//! Initialize network interface hardware.
/// Reset and bring up network interface hardware. This function should leave
/// the network interface ready to handle \c nicSend() and \c nicPoll() requests.
/// \note For some hardware, this command will take a non-negligible amount of
/// time (1-2 seconds).
void nicInit(char Eth);
//! Send packet on network interface.
/// Function accepts the length (in bytes) of the data to be sent, and a pointer
/// to the data. This send command may assume an ethernet-like 802.3 header is at the
/// beginning of the packet, and contains the packet addressing information.
/// See net.h documentation for ethernet header format.
void nicSend(unsigned int len, unsigned char* packet);
//! Check network interface; return next received packet if avaialable.
/// Function accepts the maximum allowable packet length (in bytes), and a
/// pointer to the received packet buffer. Return value is the length
/// (in bytes) of the packet recevied, or zero if no packet is available.
/// Upper network layers may assume that an ethernet-like 802.3 header is at
/// the beginning of the packet, and contains the packet addressing information.
/// See net.h documentation for ethernet header format.
unsigned int nicPoll(unsigned int maxlen, unsigned char* packet);
//! Return the 48-bit hardware node (MAC) address of this network interface.
/// This function can return a MAC address read from the NIC hardware, if available.
/// If the hardware does not provide a MAC address, a software-defined address may be
/// returned. It may be acceptable to return an address that is less than 48-bits.
void nicGetMacAddress(uint8_t* macaddr);
//! Set the 48-bit hardware node (MAC) address of this network interface.
/// This function may not be supported on all hardware.
void nicSetMacAddress(uint8_t* macaddr);
//! Print network interface hardware registers.
/// Prints a formatted list of names and values of NIC registers for debugging
/// purposes.
inline void nicRegDump(void);
#endif
//@}