Wiznet W6100 Spin2 driver usage
Started using the @ke4pjw Spin2 driver for W6100, hoping to use it to implement Modbus TCP for the P2PLC project...
Have it working, sort of...
Using a version where the top file is "SpinnerEdge_Top.spin2".
Thing Terry might have added a regular SPI interface after asking for it. He uses the 8-bit parallel interface.
Have to select which one here:
' Init Ethernet ' elock := W6100.initparallel() elock := W6100.initSPI()
Thought the SPI pins in the main file were for the W6100, but these are for uSD. Added a comment there:
CON 'uSD card pin settings DOPin = 58 CLKPin = 61 DIPin = 59 CSPin = 60
The actual ethernet SPI pins are in W6100drv.spin2. A bit confusing there because A0 and A1 are actually MOSI and MISO in SPI mode. Added a comment there. So, the pins here changed by comments are the ones you need:
CLK = 39'16 MOD = 16 ADDR = 18 ADDPINS 1 RSET = 23 CSn = 40'17 RDn = 21 WRn = 22 ' INTn = 20 'Not used DATA = 24 ADDPINS 7 DPINS = 24 / 8 A0 = 38'18 'mosi in spi A1 = 41'19 'miso in spi
There are also some hopefully unused pins defined here and also some LED pins defined below this. Have to make sure these aren't actually being used or disable that...
Using this with the DMB-4775 enclosure board with a special PCB for the SWaP module and a daughter PCB interface for the wiznet module.
I'm directly connecting with ethernet cable to a spare ethernet port on a PC. This doesn't seem to be a DHCP server, so need to specify IP address for the wiznet here:
' Set IP Address. Set to 0.0.0.0 for DHCP IPADDRESS[0] := 192'0 IPADDRESS[1] := 168 IPADDRESS[2] := 1'0'137 IPADDRESS[3] := 2'150 ' Set Subnet Mask. Set to 0.0.0.0 for DHCP SUBNETMASK[0] := 255 SUBNETMASK[1] := 255 SUBNETMASK[2] := 255 SUBNETMASK[3] := 0 ' Set Gateway Address. Set to 0.0.0.0 for DHCP GATEWAY[0] := 192 GATEWAY[1] := 168 GATEWAY[2] := 1'0'137 GATEWAY[3] := 1'10'1 ' Set DNS Server Address. Set to 0.0.0.0 for DHCP DNS[0] := 192'8 DNS[1] := 168'8 DNS[2] := 1'8 DNS[3] := 1'8
Anyway, so after all that (and copying the files in the "SDCARD" to the uSD card, it seems to work, sort of.
It serves up index.html from uSD to browser, but the page appears either blank or with just the text, "Spinnernet Edge". It doesn't seem to serve up the .png background file. Working now to figure this out.
Will probably eventually switch this over to C, where there is another solution, but want to get this working first.
Should also update the uSD driver with the new one from @evanh ...
Comments
@Rayman What browser are you using? I may be too aggressively closing the connection on the webserver. I have wanted to change how those timeouts are performed in the driver, now that I know more about how they can be handled. The browsers want to keep a persistent connection open to the webserver, but that prevents anyone else from connecting.
I am happy to help out with anything I can.
Ok, this was a terrible way to add a wait. For the moment, change 10000 to something larger like 25000. I am going to rework this to be a number of ms to wait before closing the connection.

There are several improvements I have not folded into this terrible code of mine that I have made in other projects.
@Rayman Be sure to copy the favicon.ico file too. Otherwise the browser will try and pull it on every request instead of caching it. That may make for unexpected results.