?? cs8900.i
字號:
#line 1 "..\cs8900.c" /0 #error *** WARNING C318 IN LINE 4 OF ..\cs8900.c: can't open file 'inet/datatypes.h' #error *** WARNING C318 IN LINE 5 OF ..\cs8900.c: can't open file 'inet/system.h' #error *** WARNING C318 IN LINE 6 OF ..\cs8900.c: can't open file 'inet/ethernet.h' #error *** WARNING C318 IN LINE 7 OF ..\cs8900.c: can't open file 'inet/cs8900.h' #error *** WARNING C318 IN LINE 9 OF ..\cs8900.c: can't open file 'inet/arch/config.h' struct ethernet_frame received_frame; struct ethernet_frame send_frame; UINT8 xdata RxBuf1[ETH_MTU]; UINT8 xdata TxBuf1[ETH_MTU]; UINT8 xdata * RxPtr; UINT8 xdata * TxPtr; UINT16 RxLength; void CSInit (UINT8* mac) { UINT8 chip_id[4]; P1_3 = 1; wait(0xFFFF); P1_3 = 0; wait(0xFFFF); (*((volatile UINT8 xdata *)(PPPtr))) = 0x58; (*((volatile UINT8 xdata *)(PPPtrp1))) = 0x01; (*((volatile UINT8 xdata *)(PPData))) = *(mac+5); (*((volatile UINT8 xdata *)(PPDatap1))) = *(mac+4); (*((volatile UINT8 xdata *)(PPPtr))) = 0x5A; (*((volatile UINT8 xdata *)(PPPtrp1))) = 0x01; (*((volatile UINT8 xdata *)(PPData))) = *(mac+3); (*((volatile UINT8 xdata *)(PPDatap1))) = *(mac+2); (*((volatile UINT8 xdata *)(PPPtr))) = 0x5C; (*((volatile UINT8 xdata *)(PPPtrp1))) = 0x01; (*((volatile UINT8 xdata *)(PPData))) = *(mac+1); (*((volatile UINT8 xdata *)(PPDatap1))) = *(mac); (*((volatile UINT8 xdata *)(PPPtr))) = 0x04; (*((volatile UINT8 xdata *)(PPPtrp1))) = 0x01; (*((volatile UINT8 xdata *)(PPData))) = 0x00; (*((volatile UINT8 xdata *)(PPDatap1))) = 0x0D; (*((volatile UINT8 xdata *)(PPPtr))) = 0x12; (*((volatile UINT8 xdata *)(PPPtrp1))) = 0x01; (*((volatile UINT8 xdata *)(PPData))) = 0xc0; (*((volatile UINT8 xdata *)(PPDatap1))) = 0x00; (*((volatile UINT8 xdata *)(PPPtr)))=0x00; (*((volatile UINT8 xdata *)(PPPtrp1)))=0x00; chip_id[0]=(*((volatile UINT8 xdata *)(PPData))); chip_id[1]=(*((volatile UINT8 xdata *)(PPDatap1))); (*((volatile UINT8 xdata *)(PPPtr)))=0x02; (*((volatile UINT8 xdata *)(PPPtrp1)))=0x00; chip_id[2]=(*((volatile UINT8 xdata *)(PPData))); chip_id[3]=(*((volatile UINT8 xdata *)(PPDatap1))); } UINT8 CSCheckRxFrame (void) { UINT8 highbyte, lowbyte; (*((volatile UINT8 xdata *)(PPPtr))) = 0x24; (*((volatile UINT8 xdata *)(PPPtrp1))) = 0x01; highbyte = (*((volatile UINT8 xdata *)(PPDatap1))); lowbyte = (*((volatile UINT8 xdata *)(PPData))); return highbyte; } UINT8 CSReceiveFrame (void) { UINT8 temp,lenh, lenl; UINT8 i; if (CSCheckRxFrame() == FALSE) return(FALSE); RxPtr = &RxBuf1[0]; temp=(*((volatile UINT8 xdata *)(RxTxDatap1))); temp=(*((volatile UINT8 xdata *)(RxTxData))); lenh=(*((volatile UINT8 xdata *)(RxTxDatap1))); lenl=(*((volatile UINT8 xdata *)(RxTxData))); RxLength=(UINT16)((lenh<<8)+lenl); for (i=0;i<(RxLength>>1);i++) { *RxPtr++=(*((volatile UINT8 xdata *)(RxTxData))); *RxPtr++=(*((volatile UINT8 xdata *)(RxTxDatap1))); } if((RxLength&0x0001)==1) { *RxPtr++=(*((volatile UINT8 xdata *)(RxTxData))); } RxPtr = &RxBuf1[0]; received_frame.frame_size = lenl; received_frame.frame_size |= ((UINT16)lenh) << 8; if(received_frame.frame_size > 4) received_frame.frame_size -= 0; else return(FALSE); received_frame.destination[5] = *RxPtr++; received_frame.destination[4] = *RxPtr++; received_frame.destination[3] = *RxPtr++; received_frame.destination[2] = *RxPtr++; received_frame.destination[1] = *RxPtr++; received_frame.destination[0] = *RxPtr++; received_frame.source[5] = *RxPtr++; received_frame.source[4] = *RxPtr++; received_frame.source[3] = *RxPtr++; received_frame.source[2] = *RxPtr++; received_frame.source[1] = *RxPtr++; received_frame.source[0] = *RxPtr++; received_frame.protocol = *RxPtr++; received_frame.protocol <<= 8; received_frame.protocol |= *RxPtr++; received_frame.buf_index = ETH_HEADER_LEN; return(TRUE); } void CSSendFrame (UINT16 len) { UINT8 BusST; UINT16 i = 0; TxPtr = &TxBuf1[0]; (*((volatile UINT8 xdata *)(TxCmd)))= 0xc0; (*((volatile UINT8 xdata *)(TxCmd + 1))) = 0x00; (*((volatile UINT8 xdata *)(TxLength))) = (UINT8) (len & 0x00FF); (*((volatile UINT8 xdata *)(TxLength + 1))) = (UINT8) (len >> 8); (*((volatile UINT8 xdata *)(PPPtr))) = 0x38; (*((volatile UINT8 xdata *)(PPPtr + 1))) = 0x01; do { BusST = (*((volatile UINT8 xdata *)(PPData))); BusST = (*((volatile UINT8 xdata *)(PPDatap1))); } while(!(BusST==0x01)); while (i<(len>>1)) { (*((volatile UINT8 xdata *)(RxTxData))) = *(TxPtr++); (*((volatile UINT8 xdata *)(RxTxDatap1))) = *(TxPtr++); i++; } if((len&0x0001)==1) { (*((volatile UINT8 xdata *)(RxTxData))) = *(TxPtr); } } void CSInitRx_position (UINT16 pos) { RxPtr = &RxBuf1[0] + pos; } void CSInitTx_position (UINT16 pos) { TxPtr = &TxBuf1[0] + pos; } void CSDumpRxFrame (void) { ; } void outBUF (UINT8 dat) { *TxPtr++ = dat; } UINT8 inBUF (void) { return(*RxPtr++); } void CSWriteEthernetHeader (struct ethernet_frame* frame) { INT8 i; TxPtr = &TxBuf1[0]; for(i=ETH_ADDRESS_LEN-1; i >= 0; i--) { *TxPtr++ = frame->destination[i]; } for(i=ETH_ADDRESS_LEN-1; i >= 0; i--) { *TxPtr++ = frame->source[i]; } *TxPtr++ = (UINT8)(frame->protocol >> 8); *TxPtr++ = (UINT8)frame->protocol; }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -