⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cs8900.c

📁 含有完整TCP/IP PPP协议的嵌入式操作系统
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (C) 2002-2003 by Call Direct Cellular Solutions Pty. Ltd. 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. All advertising materials mentioning features or use of this *    software must display the following acknowledgement: * *    This product includes software developed by Call Direct Cellular Solutions Pty. Ltd. *    and its contributors. * * THIS SOFTWARE IS PROVIDED BY CALL DIRECT CELLULAR SOLUTIONS AND CONTRIBUTORS * ``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 CALL DIRECT * CELLULAR SOLUTIONS OR CONTRIBUTORS 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. * * For additional information see http://www.calldirect.com.au/ * * - * Copyright (C) 2001-2003 by egnite Software GmbH. 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. All advertising materials mentioning features or use of this *    software must display the following acknowledgement: * *    This product includes software developed by egnite Software GmbH *    and its contributors. * * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS * ``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 EGNITE * SOFTWARE GMBH OR CONTRIBUTORS 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. * * For additional information see http://www.ethernut.de/ * * - * Portions Copyright (C) 2000 David J. Hudson <dave@humbug.demon.co.uk> * * This file is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. * * You can redistribute this file and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software Foundation; * either version 2 of the License, or (at your discretion) any later version. * See the accompanying file "copying-gpl.txt" for more details. * * As a special exception to the GPL, permission is granted for additional * uses of the text contained in this file.  See the accompanying file * "copying-liquorice.txt" for details. * - * Portions Copyright (c) 1983, 1993 by *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed by the University of *	California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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. * - * Portions Copyright (c) 1993 by Digital Equipment Corporation. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies, and that * the name of Digital Equipment Corporation not be used in advertising or * publicity pertaining to distribution of the document or software without * specific, written prior permission. *  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. *//* * $Log: cs8900.c,v $ * Revision 1.1  2005/07/26 18:02:27  haraldkipp * Moved from dev. * * Revision 1.9  2005/04/30 16:42:41  chaac * Fixed bug in handling of NUTDEBUG. Added include for cfg/os.h. If NUTDEBUG * is defined in NutConf, it will make effect where it is used. * * Revision 1.8  2004/05/26 09:40:30  olereinhardt * Changed reading of packet length / receive status to be compatible with * newer AVRGCC versions. (Need to read high byte first!) * * Added software reset / wakeup routine to init code. (only avalilable in new code) * * Revision 1.7  2004/05/25 11:39:47  olereinhardt * Define NUT_CS8900_OLD to get the old functionality back again * * Revision 1.6  2004/05/24 17:09:17  olereinhardt * Changed base address handling in cs8900.c and moved cs8900.h to /include/dev * Base address can now be passed to the nic driver by NutRegisterDevice. * Removed some Assembler code in cs8900.c * * Added some databus waitstate settings for the upper half of the address space in os/arch/avr_nutinit.c. Now three waitstates are default for 0x8000-0xFFFF * * Added terminal device driver for hd44780 compatible LCD displays directly * connected to the memory bus (memory mapped). See hd44780.c for more information. * Therefore some minor changed in include/dev/term.h and dev/term.c are needet to * pass a base address to the lcd driver. * * Revision 1.5  2004/03/18 14:06:52  haraldkipp * Deprecated header file replaced * * Revision 1.4  2003/10/13 10:13:49  haraldkipp * First release * * Revision 1.3  2003/08/05 20:11:30  haraldkipp * Removed from ICCAVR compilation * * Revision 1.2  2003/07/20 20:07:38  haraldkipp * Conflicting Ethernet driver routine names solved. * * Revision 1.1  2003/07/20 16:37:21  haraldkipp * CrystalTek 8900A driver added. * * * Revision 1.0  2002/03/28 MJC CDCS * Created * * Revision 1.1  2003/03/25 MJC CDCS * Modified behaviour when transmit buffer space unavailable * *//* Not ported. */#ifdef __GNUC__#include <cfg/os.h>#include <string.h>#include <avr/interrupt.h>#include <sys/heap.h>#include <sys/thread.h>#include <sys/event.h>#include <sys/timer.h>#include <sys/confnet.h>#include <dev/nicrtl.h>#include <netinet/if_ether.h>#include <net/ether.h>#include <net/if_var.h>#include <netinet/ip.h>#include <dev/irqreg.h>#include "cs8900.h"#ifdef NUTDEBUG#include <sys/osdebug.h>#include <net/netdebug.h>#endif/*! * \addtogroup xgNicCs8900 *//*@{*/// Ethernet flags byte// Bit 0 = transmit byte flagu_char cs_flags;volatile u_short cs_base = 0x0000;void CSWrite16(u_short addr, u_short data){    u_short *p;    p = (u_short *) addr;    cli();    *p = data;    sei();}void CSWritePP16(u_short addr, u_short data){    u_short *p;    cli();    p = (u_short *) CS_PP_PTR;    *p = addr;    CSWrite16(CS_PP_DATA0, data);    return;}u_short CSRead16(u_short addr){    u_short *p;    u_short d;    cli();    p = (u_short *) addr;    d = *p;    sei();    return d;}u_short CSReadPP16(u_short addr){    u_short *p;    cli();    p = (u_short *) CS_PP_PTR;    *p = addr;    return CSRead16(CS_PP_DATA0);}u_long CSReadPP32(u_int addr){    u_long l;    u_long *p;    cli();    p = (u_long *) CS_PP_PTR;    *p = addr;    p = (u_long *) CS_PP_DATA0;    l = *p;    sei();    return l;}void CSBeginFrame(void){    cs_flags &= ~1;}void CSEndFrame(void){    u_char *p;    cli();    p = (u_char *) CS_DATA_P0 + 1;    sei();    // If odd number of bytes in packet pad it out    if (cs_flags & 1)        p = 0;}void CSWriteFrameByte(u_char data){    u_char *p;    if (cs_flags & 1)        p = (u_char *) CS_DATA_P0 + 1;    else        p = (u_char *) CS_DATA_P0;    *p = data;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -