netinit.c
来自「2410 boot loader,usb ftp」· C语言 代码 · 共 107 行
C
107 行
/* 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 "io.h"#include "net.h"#include "timer.h"#include "cs89x.h"static net_init=0; int netUp (char *mac){ int error; /* Probe cs89xx */ if(!net_init) { error = cs89xProbe(); if(error) return error; else net_init=1; } memset(&netif, 0, sizeof(netif)); //memcpy (netif.IEEEIA, (void *) 0x400fffa, sizeof netif.IEEEIA); netif.IEEEIA[0] = mac[0]; netif.IEEEIA[1] = mac[1]; netif.IEEEIA[2] = mac[2]; netif.IEEEIA[3] = mac[3]; netif.IEEEIA[4] = mac[4]; netif.IEEEIA[5] = mac[5]; netif.send = cs89xSend; error = cs89xReset (); if (error) return error; /* Set interrupt service routine */ pISR_EINT8_23 = (unsigned int)cs89xISR; /* Configure gpio as external interrupt #9 */
rGPGCON &= ~(3 << 2);
rGPGCON |= (2 << 2); /* Interrupt Rising Edge Detect Mode */
rEXTINT1 &= ~(7 << 4);
rEXTINT1 |= (4 << 4); /* Interrupt High Level Detect Mode */
//rEXTINT1 &= ~(7 << 4);
//rEXTINT1 |= (1 << 4); /* Interrupt Both Edge Detect Mode */
//rEXTINT1 &= ~(7 << 4);
//rEXTINT1 |= (6 << 4); /* network chip initialization * if there is a error the function returns to the caller. */ error = cs89xSetup (); if (error) return error; /* Enable Interrupt */ rINTMSK &= ~(1<<5); // EINT8~23 rEINTMASK &= ~(1<<9); // EINT9 return 0;}int netDown (void){ net_init = 0; /* Disable Interrupt */ rINTMSK |= (1<<5); // EINT8~23 rEINTMASK |= (1<<9); // EINT9 return cs89xReset ();}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?