Ponting ioLibrary_v100 to 16bit, bugs


#1

All,

I have come across 3 bug today in code from ioLibrary_v100 that
has issues when ported to 16bit.

Function “wiz_send_data”, in W5500.c:
uint16_t ptr = 0; needs changed to a uint32.
If not the upper 8 bits gets truncated during
addrsel = (ptr << 8) + (WIZCHIP_TXBUF_BLOCK(sn) << 3);
This causes garbage to be sent out during a send data.
Also changed it in wiz_recv_data, although it was working.

Function “inet_ntoa” and “inet_ntoa”_pad, in sockutil.c:
sprintf((char*)addr_str,"%d.%d.%d.%d",(int32_t)(addr>>24 & 0xFF),(int32_t)(addr>>16 & 0xFF),(int32_t)(addr>>8 & 0xFF),(int32_t)(addr & 0xFF))
int32’s needs changed to int16’s.
It may be compiler dependent, but for me I had to change it to int16’s or I was getting
extra characters out of the sprintf function.

Function “loopback_tcps”, in loopback.c:
ret is defined as int32, but in this line:
SendLen = TCPSend(sock, data_buf, ret)
function TCPSend is expecting the length to be uint32.
Had to add a type cast like this:
SendLen = TCPSend(sock, data_buf, (Uint32)ret)
with out the type cast garbage was passed to TCPSend.

Maybe this will help someone, and maybe for future updates.

Thanks,
Jim


#2

Hi,
Thank so much for your advice.
I also think your adivce would be a help to 16bit MCU users who need to port the driver to theirs.

Thanks again.


#3

Come across another one today.

Function “loopback_udp”, in loopback.c:
The destination IP is defined as,
uint32_t destip = 0;

The problem is that the UDPRecv function places the IP
address in 4 consecutive memory locations, in the case of a 16bit processor,
it uses 4 16bit words, this don’t fit into the 32bit address defined.
After the UDPRecv function the memory is Eg. 0x00A800C0 (192.0.168.0).
To resolve this I defined the destination IP like:
Uint8 destip[4] = { 0 };

There are pointer castings on the function, (Uint8*)&destip but this
did not seem to matter to my compiler.

Jim,


#4

Hi,
Thank so much you for contributing other mcu user need to port it.
We will expect you continue contribute to and interest in our chip.
Thank you again.