//********************************************************************* //-------------------- Mac Configuration -------------------- //********************************************************************* //When STACK_USE_FAST_NIC is defined, a bit longer, but faster code is used. #define STACK_USE_FAST_NIC //When defined, the code will be compiled for optimal speed. If not defined, code is defined for smallest size. #define MAC_SPEED_OPTIMIZE //STACK_DISABLES_INTS can be defined if interrupts are to be disabled during the MAC access routines //#define STACK_DISABLES_INTS //NIC_DISABLE_INT0 can be defined if the MAC should NOT use INT0 (connected to PIC port RB0) for it's //interrupt request status line. When defined, INT0 is tri-stated, and the PIC port pin connected to //it can be used as a general purpose user IO pin. The PIC port pin that becomes available is: // - For SBC44EC this has no affect - no PIC pins are connected to the interrupt pins // - For SBC45EC this has no affect - no PIC pins are connected to the interrupt pins // - For SBC65EC and SBC68EC this frees up PIC pin RB0. #define NIC_DISABLE_INT0 //NIC_DISABLE_IOCHRDY can be defined if the MAC should NOT use the IOCHRDY signal on the RTL8019AS chip. This //will mean that an additional PIC pin will be available for general purpose use. To use this port pin, the //connection to the IOCHRDY signal on RTL8019AS must be broken. This can be done via solder jumpers on certian //SBC boards. // - For SBC44EC PIC port pin B5 will be available for user IO. Solder jumper SJ5 must be opened! // - For SBC45EC PIC port pin A4 will be available for user IO. Solder jumper SJ5 must be opened! // - For SBC65EC and SBC68EC this frees up PIC pin RG4. This pin is currently however not routed to an connectors #define NIC_DISABLE_IOCHRDY //Keep a count of CNTR1 - CNTR3 registers. This can be used for debug purposes, and can be disabled for //production code. //#define MAC_CNTR1_3 //Use access RAM variables to optiomize speed and code size. There are only a limited amount of access RAM //registers in the PIC processor. If they are not used by any other code modules, this define should be enabled //seeing that it will speed up the MAC module quite a bit. If they are not available, an error message will be //displayed during compilation. //#define MAC_USE_ACCESSRAM
Data Structures | |
| struct | _MAC_ADDR |
Defines | |
| #define | INVALID_BUFFER (0xff) |
| #define | MAC_ARP (0x6) |
| #define | MAC_IP (0) |
| #define | MAC_UNKNOWN (0x0ff) |
| #define | MACGetRxBuffer() (MACCurrRxbuf) |
| #define | MACGetTxBuffer() (MACCurrTxbuf) |
Typedefs | |
| typedef _MAC_ADDR | MAC_ADDR |
Functions | |
| void | MACDiscardTx (BUFFER buffer) |
| void | MACFlush (void) |
| WORD | MACGetFreeRxSize (void) |
| WORD | MACGetNICAddr (void) |
| void | MACInit (void) |
| BOOL | MACIsLinked (void) |
| BOOL | MACIsTxReady (void) |
| void | MACPut (BYTE val) |
| void | MACPutArray (BYTE *val, WORD len) |
| void | MACPutHeader (MAC_ADDR *remote, BYTE type, WORD dataLen) |
| void | MACReserveTxBuffer (BUFFER buffer) |
| void | MACRxbufDiscard (void) |
| BYTE | MACRxbufGet (void) |
| WORD | MACRxbufGetArray (BYTE *val, WORD len) |
| BOOL | MACRxbufGetHdr (MAC_ADDR *remote, BYTE *type) |
| void | MACSetRxBuffer (WORD offset) |
| void | MACSetTxBuffer (BUFFER buffer, WORD offset) |
| void | MACTask (void) |
| void | NICReset (void) |
Variables | |
| BYTE | MACCurrRxbuf |
| BYTE | MACCurrTxbuf |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Get handle of current receive buffer. Is a number from 0-255.
|
|
|
Get handle of current transmit buffer. Is a number from 0-255. The current transmit buffer will automatically be set to the next available buffer after a MACFlush() function.
|
|
|
Structure for storing Ethernet address |
|
|
Discard the given transmit buffer
|
|
|
Flush the MAC |
|
|
This function returns total receive buffer size available for future data packets. |
|
|
Get the current Remote DMA address. This is the address set by the NICSetAddr register. It will however be incremented after each Remote DMA read. The MACRxbufGet() function for example does a remote DMA read.
|
|
|
|
|
|
Check if the MAC is linked
|
|
|
Check if ready for next transmission.
|
|
|
Write a single byte to the Remote DMA. The byte is written to the current Remote DMA address.
|
|
||||||||||||
|
Write given array of bytes to NIC's RAM
|
|
||||||||||||||||
|
This function writes the MAC header (Ethernet header) part of a packet that has to be transmitted to the current TX buffer (page in NIC RAM). After this function, the data must still be written to the TX buffer. After both header and data has been written, bits are set to instruct NIC to transmit transmit buffer. This function does the following:
|
|
|
This function reserves a given transmit buffer and marks it as unavailable. This function is useful for TCP layer where a message would be queued until it is correctly acknowledged by remote host.
|
|
|
Discard the contents of the current RX buffer. |
|
|
Reads a single byte via Remote DMA from the current MAC Receive buffer. If the last byte of the RX Buffer was read, this function automatically updates the Remote DMA read address to the first page of the RX Buffer. See PreConditions for more info.
|
|
||||||||||||
|
Reads the given amount of bytes via Remote DMA from the current MAC Receive buffer. If the end of the RX Buffer is reached, this function automatically rolls over to the first page of the RX Ring Buffer. See PreConditions above for more info.
|
|
||||||||||||
|
Check if the MAC Receive Buffer has any received packets. Reads the following data from the next available packet in the RX buffer:
|
|
|
This function sets the access location for the active receive buffer, relative to the first byte following the Ethernet header. If the given offset is thus 0, the access location will be set to the first byte of whatever follows the Ethernet header, for example the IP packet or ARP packet. Users must make sure that the supplied offset does not go beyond current receive buffer content. If offset overruns the current receive buffer, all subsequent access to that buffer would yield invalid data.
|
|
||||||||||||
|
This function makes the given transmit buffer active, and sets it's access pointer to be:
|
|
|
Function for performing MAC related tasks
|
|
|
Reset the NIC |
|
|
|
|
|
|
1.4.5