📄 netinit.c
字号:
/* Copyright 2001-2004 Georges Menie (www.menie.org) This file is part of Tftpnaive. Tftpnaive is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Tftpnaive 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. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Tftpnaive; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/#include "tftpnaive.h"#include "68vz328.h"#include "io.h"#include "net.h"#include "timer.h"#include "proto.h"#include "cs89x.h"int netUp (void){ int error; memcpy (netif.IEEEIA, (void *) 0x400fffa, sizeof netif.IEEEIA); netif.send = cs89xSend; /* disable IRQ */ orl (1 << IRQ_NUM, IMR); /* initialise the CSB0 to be used as FPGA/CS89 Chip Select */ writew (0x08000000 >> 13, CSGBB); writew (0x01A1, CSB); /* read/write, 128k, 4ws, FLASH enable, 16 bits bus */ /* PK3: hardware sleep function pin, active low */ orb (0x08, PKSEL); // select pin as I/O orb (0x08, PKDIR); // select pin as output orb (0x08, PKDATA); // set pin high /* PF5: hardware reset function pin, active high */ orb (0x20, PFSEL); // select pin as I/O orb (0x20, PFDIR); // select pin as output andb (~0x20, PFDATA); // set pin low error = cs89xReset (); if (error) return error; /* set interrupt service routine: INT1 -> level 4 */ writel ((int) cs89xISR, ((readb (IVR) & 0xf8) + 4) << 2); /* INT1 enable (cs8900 IRQ) */ andb (~2, PDPOL); /* active high signal */ andb (~2, PDIRQEG); /* level-triggered */ orb (2, PDIRQEN); /* IRQ enabled */ /* network chip initialization * if there is a error the function returns to the caller. */ error = cs89xSetup (); if (error) return error; /* enable IRQ */ orl (1 << IRQ_NUM, ISR); andl (~(1 << IRQ_NUM), IMR); return 0;}int netDown (void){ /* INT1 disable (cs8900 IRQ) */ andb (~2, PDIRQEN); /* disable IRQ */ orl (1 << IRQ_NUM, IMR); orl (1 << IRQ_NUM, ISR); return cs89xReset ();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -