|
我用了SPI0与W5500连接,但是配置总出问题。1是W5500的数据都是uint8但是6748发送接收函数是uint32类型不知道有没有影响,还有时钟频率设置的50000000感觉不太对,再就是sento中不加printf程序就会卡住
uint16_t sendto(SOCKET s, const uint8_t * buf, uint16_t len, uint8_t * addr, uint16_t port)
{
uint16_t ret=0;
static uint8_t flag=0;
if (len > getIINCHIP_TxMAX(s))
ret = getIINCHIP_TxMAX(s); // check size not to exceed MAX size.
else ret = len;
if( ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && (addr[3] == 0x00)) || ((port == 0x00)) )//||(ret == 0) )
{
/* added return value */
ret = 0;
}
else
{
//if(flag==0)
//{
IINCHIP_WRITE( Sn_DIPR0(s), addr[0]);
IINCHIP_WRITE( Sn_DIPR1(s), addr[1]);
IINCHIP_WRITE( Sn_DIPR2(s), addr[2]);
IINCHIP_WRITE( Sn_DIPR3(s), addr[3]);
IINCHIP_WRITE( Sn_DPORT0(s),(uint8_t)((port & 0xff00) >> 8));
IINCHIP_WRITE( Sn_DPORT1(s),(uint8_t)(port & 0x00ff));
//flag=1;
//}
// copy data
send_data_processing(s, (uint8_t *)buf, ret);
IINCHIP_WRITE( Sn_CR(s) ,Sn_CR_SEND);
/* wait to process the command... */
while( IINCHIP_READ( Sn_CR(s) ) )
;
printf("ooo\r\n");
/* ------- */
while( (IINCHIP_READ( Sn_IR(s) ) & Sn_IR_SEND_OK) != Sn_IR_SEND_OK )
{
if (IINCHIP_READ( Sn_IR(s) ) & Sn_IR_TIMEOUT)
{
/* clear interrupt */
IINCHIP_WRITE( Sn_IR(s) , (Sn_IR_SEND_OK | Sn_IR_TIMEOUT)); /* clear SEND_OK & TIMEOUT */
return 0;
}
}
// printf("ooo\r\n");
IINCHIP_WRITE( Sn_IR(s) , Sn_IR_SEND_OK);
}
// printf("ooo\r\n");
return ret;
}
加了一个printf程序正常,求大佬帮忙
|
|