/* * Copyright (c) 2001-2003 Leon Woestenberg
* Copyright (c) 2001-2003 Axon Digital Design B.V., The Netherlands. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Leon Woestenberg * * This is a device driver for the Crystal Semiconductor CS8900 * chip in combination with the lwIP stack. * * This is work under development. Please coordinate changes * and requests with Leon Woestenberg * * The Swedish Institute of Computer Science and Adam Dunkels * are specifically granted permission to redistribute this * source code under any conditions they seem fit. * */ #ifndef __NETIF_CS8900IF_H__ #define __NETIF_CS8900IF_H__ #include "lwip/netif.h" extern struct netif netif; //#error TODO: Check if ETH_MIN_FRAME_LEN is defined correctly. (RFC1042 or CS8900) //changed commented out #define ETH_MIN_FRAME_LEN 64 //changed was 76 #include "lwip/snmp.h" // Define those to better describe your network interface #define IFNAME0 'e' #define IFNAME1 'n' static const struct eth_addr ethbroadcast = {{0xffU,0xffU,0xffU,0xffU,0xffU,0xffU}}; // function prototypes err_t cs8900if_init (struct netif *netif); static err_t cs8900_init (void); static INT16U cs8900_reset (void); void CS8900_Interrupt (void); void ServiceCS8900 (void); err_t cs8900if_output (struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr); static err_t cs8900_output (struct netif *netif, struct pbuf *p); void cs8900if_input (struct netif *netif); static struct pbuf* cs8900_input (struct netif *netif); static INT16U ppRead (INT16U); static void ppWrite (INT16U, INT16U); static INT16U IORead (INT8U); static void IOWrite (INT8U, INT16U); //cs8900 related signals from the 9s12->cs8900 #define CS8900_RESET 0x01 //if Port M pin 0 is pulled high, then the cs8900's reset pin is active #define CS8900_READ 0x02 //if Port M pin 1 is pulled low, then cs8900's IOR pin is active #define CS8900_WRITE 0x04 //if Port M pin 2 is pulled low, then cs8900's IOW pin is active #define CS8900_SBHE 0x08 //if Port M pin 2 is pulled low, then cs8900's SBHE pin is active /* packet page addresses of common registers */ #define CS8900_RxTxDataPort 0x00 #define CS_IO_TXCMDW 0x04 //IO txcmdwrite register #define CS_IO_TXLEN 0x06 //IO txlength register #define CS8900_ISQ 0x08 //ISQ #define CS8900_PP_PTR_PORT 0x0A #define CS8900_PP_DATA_PORT 0x0C // CS8900 PacketPage register offsets byte swapped since we have a big endian machine #define CS_PP_EISA 0x0000 // EISA Registration number of CS8900 #define CS_PP_PRODID 0x0200 // Product ID Number #define CS_PP_IOBASE 0x2000 // I/O Base Address #define CS_PP_INTNUM 0x2200 // Interrupt number (0,1,2, or 3) #define CS_PP_RXCFG 0x0201 // Receiver Configuration #define CS_PP_RXCTL 0x0401 // Receiver Control #define CS_PP_TXCFG 0x0601 // Transmit Configuration #define CS_PP_BUFCFG 0x0a01 // Buffer Configuration #define CS_PP_LINECTL 0x1201 // Line Control Register offset #define CS_PP_SELFCTL 0x1401 // Self Control #define CS_PP_BUSCTL 0x1601 // Bus Control #define CS_PP_TESTCTL 0x1801 // Test Control #define CS_PP_ISQ 0x2001 // Interrupt status queue #define CS_PP_RXEVENT 0x2401 // Receiver Event #define CS_PP_TX_EVENT 0x2801 // Transmitter Event #define CS_PP_BUF_EVENT 0x2c01 // Buffer Event #define CS_PP_RXMISS 0x3001 // Receiver Miss Counter #define CS_PP_TXCOL 0x3201 // Transmit Collision Counter #define CS_PP_LINESTATUS 0x3401 // Line Status #define CS_PP_SELFTEST 0x3601 // Self Status #define CS_PP_BUSSTATUS 0x3801 // Bus Status #define CS_PP_TXCMD 0x4401 // Transmit Command Request #define CS_PP_TXLEN 0x4601 // Transmit Length #define CS_PP_IA1 0x5801 // Individual Address (IA) #define CS_PP_IA2 0x5a01 // Individual Address (IA) #define CS_PP_IA3 0x5c01 // Individual Address (IA) #define CS_PP_RXSTATUS 0x0400 // Receive Status #define CS_PP_RXLEN 0x0402 // Receive Length #define CS_PP_RXFRAME 0x0404 // Receive Frame Location #define CS_PP_TXFRAME 0x0A00 // Transmit Frame Location /* interface statistics gathering * such as collisions, dropped packets, missed packets * 0 = no statistics, minimal memory requirements, no overhead * 1 = statistics on, but some have large granularity (0x200), very low overhead * 2 = statistics on, updated on every call to cs8900_service(), low overhead */ #define CS8900_STATS 0 struct cs8900if { //struct eth_addr *ethaddr; volatile u8_t needs_service; u8_t use_polling; #if (CS8900_STATS > 0) u32_t interrupts; // #interrupt requests of cs8900 u32_t missed; // #packets on medium that could not enter cs8900a chip due to buffer shortage u32_t dropped; // #packets dropped after they have been received in chip buffer u32_t collisions; // #collisions on medium when transmitting packets u32_t sentpackets; // #number of sent packets u32_t sentbytes; // #number of sent bytes #endif /* Add whatever per-interface state that is needed here. */ }; #endif /* __NETIF_CS8900IF_H__ */