看了论坛里的一些资料学着改了下,为什么使用TCP_CONNECT后返回是ERR_OK但是不会调用此函数中的回调函数?在ENET_IO的基础上修改,代码如下:
unsigned long ulUser0, ulUser1;
unsigned char pucMACArray[8]={0x00,0x16,0x4e,0x22,0x13,0x14};
struct tcp_pcb *pstClient_Pcb;
struct ip_addr ullipaddr;
//
// Set the clocking to run directly from the crystal.
//
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_8MHZ);
//
// Enable and Reset the Ethernet Controller.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_ETH);
SysCtlPeripheralReset(SYSCTL_PERIPH_ETH);
//
// Enable Port F for Ethernet LEDs.
// LED0 Bit 3 Output
// LED1 Bit 2 Output
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeEthernetLED(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3);
//
// Configure SysTick for a periodic interrupt.
//
SysTickPeriodSet(SysCtlClockGet() / SYSTICKHZ);
SysTickEnable();
SysTickIntEnable();
//
// Enable processor interrupts.
//
IntMasterEnable();
// Configure the hardware MAC address for Ethernet Controller filtering of
// incoming packets.
//
// For the LM3S6965 Evaluation Kit, the MAC address will be stored in the
// non-volatile USER0 and USER1 registers. These registers can be read
// using the FlashUserGet function, as illustrated below.
//
FlashUserGet(&ulUser0, &ulUser1);
/* if((ulUser0 == 0xffffffff) || (ulUser1 == 0xffffffff))
{
//
// We should never get here. This is an error if the MAC address
// has not been programmed into the device. Exit the program.
//
RIT128x96x4StringDraw("MAC Address", 0, 16, 15);
RIT128x96x4StringDraw("Not Programmed!", 0, 24, 15);
while(1);
} */
//
// Convert the 24/24 split MAC address from NV ram into a 32/16 split
// MAC address needed to program the hardware registers, then program
// the MAC address into the Ethernet Controller registers.
//
pucMACArray[0] = ((ulUser0 >> 0) & 0xff);
pucMACArray[1] = ((ulUser0 >> 8) & 0xff);
pucMACArray[2] = ((ulUser0 >> 16) & 0xff);
pucMACArray[3] = ((ulUser1 >> 0) & 0xff);
pucMACArray[4] = ((ulUser1 >> 8) & 0xff);
pucMACArray[5] = ((ulUser1 >> 16) & 0xff);
//
// Loop forever. All the work is done in interrupt handlers.
//
while(1)
{
}
另外想问下端口口是如何设置?默认是什么样的?我只知道TCP_BIND函数中有端口绑定,是否这个时候就会设置成这个端口?如果是,那做服务器模式时如何获知?我是个新手,求各位高手帮忙了!