I finished today 21.06.2007, BETA version of Eth_V2 library with WEB SERVER example for PIC18F97J60 family MCU for MikroBasic language.
Author of this project : Medrea Florin Andrei - YO2LIO -
Thanks to Mikroelektronika team and all forum users.
Web Server example : (No TCP STACK, No fragmentation available at this moment).
Initial IP Address : 192.168.1.253.
HTTP port respond : 80.
//192.168.1.253/ (web page1)
//192.168.1.253/p (web page2)
User Functions and Procedures:
Code: Select all
' Sub Procedure Eth_SetParameters
' Set your IP, Mac, Mask ... etc... here.
' Sub Procedure Eth_Init
' Init MCU Ethernet.
' Sub Procedure Eth_Reset
' Reset MCU Ethernet.
' Sub Procedure Eth_DoPacket
' Process incoming packets.
' Sub Function Eth_UserTCP(dim byref dest_ip_addr_T as byte[4], dim byref source_port_T, dest_port_T, len_T as word) as word
' This Sub Function is called by library. Put your TCP response for WEB server parameters here. See example.
' Sub Function Eth_UserUDP(dim byref dest_ip_addr_U as byte[4], dim byref dest_port_U, source_port_U, len_U as word) as word
' This Sub Function is called by library. Put your UDP response here. See example. ( ECHO example )
' Sub Procedure Eth_PutByte(dim value as byte)
' Put one byte in ETH memory.
' Sub Function Eth_GetByte as byte
' Get one byte from ETH memory.
' Sub Function CopyFlashToEthMem_CP(dim start_Flash_address as longint) as word
' Copy Const from flash to Eth Memory and return length of Const data.
' Const data must be defined as STRING. (and must be zero terminated)
' Ex. len = CopyFlashToEthMem_CP(@httpHeader)
' Sub Function CopyRamToEthMem_CP(dim s as byte[255]) as word
' Copy dim data to Eth Memory and return length of dim data.
' dim data must be defined as ARRAY. (and must be zero terminated)
' Ex. len = CopyRamToEthMem_CP("data data data")
' Sub Function Eth_SendARP(dim ip_dest as Byte[4]) as Boolean
' Get ARP request. Return True if Mac exist.
' Return dest. mac address in dim dest_mac as bytes[6] .
' Return dest. ip address in dim dest_ip_addr as byte[4] .
' Ex. bol = Eth_SendARP(user_ip_addr)
' First Sub Function search in ArpCache (size of 9) ...
' Sub Procedure SendUDP(dim dest_port_S, source_port_S, len_data as word, dim data_udp as byte[1472])
' Send UDP mesage. Max 1472 bytes.
' Ex. If Eth_SendARP(user_ip_addr) then SendUDP(dest_port, eth_port, 10, "Test Test ")
' Sub Procedure Eth_SendPing(dim SlotState as boolean, dim PingSlot as Byte)
' Have 8 Slots available 0 .. 7 and PingCache size of 8.
' Ex. Eth_SendPing(Eth_SendARP(user_ip_addr),0) Send Ping at user_ip_addr and put result in Slot 0.
' PingCache format :
' PingCache[Slot].IpP as byte[4]
' PingCache[Slot].MacP as byte[6]
' PingCache[Slot].Time as word
' PingCache[Slot].TTL as byte.
Code: Select all
' Sub Procedure CopyEthMemToRam(dim start_eth_address, dest_ram_address, length_w as word)
' Ex. CopyEthMemToRam(AddrPacket+6,@dest_mac_addr,6)
' Sub Procedure CopyRamToEthMem(dim start_ram_address, dest_eth_address, length_w as word)
' Ex. CopyRamToEthMem(@eth_mac,TXSTART+22,6)
' Sub Procedure CopyFlashToEthMem(dim start_Flash_address as longint, dim dest_eth_address, length_w as word)
' Ex. CopyFlashToEthMem(@httpHeader,TXSTART+54,30)
' Sub Procedure CopyEthMemToEthMem(dim start_eth_address, dest_eth_address, length_w as word, dim where as byte)
' where = 0 copy from Eth RxBuf to Eth TxBuf
' where = 1 copy from Eth TxBuf to Eth TxBuf
' Ex. CopyEthMemToEthMem(AddrPacket+38,TXSTART+28,4,0)
' Sub Procedure WriteToEthMem(dim dest_eth_address as word, dim value as byte)
' Ex. WriteToEthMem(TXSTART+12,$08)
' Sub Function ReadFromEthMem(dim start_eth_address as word) as byte
' Ex. data = ReadFromEthMem(AddrPacket+38)
' Sub Function EthMemCompareWithRam(dim start_eth_address, start_ram_address, length_w as word) as boolean
' Ex. bol = EthMemCompareWithRam(AddrPacket+30,@eth_ip_addr,4)
' Sub Function EthMemCompareWithFlash(dim start_eth_address as word, dim start_Flash_address as longint, dim length_w as word) as boolean
' Ex. bol = EthMemCompareWithFlash(AddrPacket+54, @httpHeader, 30)
' Sub Function Eth_Cksum(dim start_eth_address, length_w as word) as word
' Ex. cksum_ip = Eth_Cksum(TXSTART+14,20)
' Sub Procedure Eth_WritePHYReg(dim register_address as byte, dim data as word)
' Write to PHY registers
' Sub Procedure Eth_SetLedConfig(dim NewConfig as word)
' Set Eth Led configuration. See datasheet for more detail.
' Sub Function Eth_ReadPacket as word
' Read packet and return TYPE OF SERVICE.
' Sub Procedure Eth_Send(dim length_w as word)
' Send packet from Tx buffer.
Definitions files for this MCU family, you found here : http://www.mikroe.com/forum/viewtopic.php?t=10454
UDP Bootloader for PIC18F97J60 family, you found here : http://www.mikroe.com/forum/viewtopic.php?t=11260
Good luck !
Best regards, Florin Medrea.