I finished in this weekend BETA version of Eth_V2 library with WEB SERVER example for PIC18F97J60 family MCU.
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
- Procedure Eth_SetParameters;
// Set your IP, Mac, Mask ... etc... here.
- Procedure Eth_Init;
// Init MCU Ethernet.
- Procedure Eth_Reset;
// Reset MCU Ethernet.
- Procedure Eth_DoPacket;
// Process incoming packets.
- Function Eth_UserTCP(var dest_ip_addr_T : array[4] of byte; var source_port_T, dest_port_T, len_T : word) : word;
// This function is called by library. Put your TCP response for WEB server parameters here. See example.
- Function Eth_UserUDP(var dest_ip_addr_U : array[4] of byte; var dest_port_U, source_port_U, len_U : word) : word;
// This function is called by library. Put your UDP response here. See example. ( ECHO example )
- Procedure Eth_PutByte(value : byte);
// Put one byte in ETH memory.
- Function Eth_GetByte : byte;
// Get one byte from ETH memory.
- Function CopyFlashToEthMem_CP(start_Flash_address : longint): 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);
- Function CopyRamToEthMem_CP(var s : array[255] of byte): word;
// Copy var data to Eth Memory and return length of var data.
// Var data must be defined as ARRAY. (and must be zero terminated)
// Ex. len := CopyRamToEthMem_CP('data data data');
- Function Eth_SendARP(var ip_dest : Array[4] of Byte) : Boolean;
// Get ARP request. Return True if Mac exist.
// Return dest. mac address in var dest_mac : array[6] of bytes;.
// Return dest. ip address in var dest_ip_addr : array[4] of byte;.
// Ex. bol := Eth_SendARP(user_ip_addr);
// First function search in ArpCache (size of 9) ...
- Procedure SendUDP(dest_port_S, source_port_S, len_data : word; var data_udp : array[1472] of byte);
// Send UDP mesage. Max 1472 bytes.
// Ex. If Eth_SendARP(user_ip_addr) then SendUDP(dest_port, eth_port, 10, 'Test Test ');
- Procedure Eth_SendPing(SlotState : boolean; PingSlot : 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 : array[4] of byte;
// PingCache[Slot].MacP : array[6] of byte;
// PingCache[Slot].Time : word;
// PingCache[Slot].TTL : byte.
Code: Select all
(AddrPacket is address of received packet, TXSTART is start address of transmited packet)
- Procedure CopyEthMemToRam(start_eth_address, dest_ram_address, length_w : word);
// Ex. CopyEthMemToRam(AddrPacket+6,@dest_mac_addr,6);
- Procedure CopyRamToEthMem(start_ram_address, dest_eth_address, length_w : word);
// Ex. CopyRamToEthMem(@eth_mac,TXSTART+22,6);
- Procedure CopyFlashToEthMem(start_Flash_address : longint; dest_eth_address, length_w : word);
// Ex. CopyFlashToEthMem(@httpHeader,TXSTART+54,30);
- Procedure CopyEthMemToEthMem(start_eth_address, dest_eth_address, length_w : word; where : 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);
- Procedure WriteToEthMem(dest_eth_address : word; value : byte);
// Ex. WriteToEthMem(TXSTART+12,$08);
- Function ReadFromEthMem(start_eth_address : word) : byte;
// Ex. data := ReadFromEthMem(AddrPacket+38);
- Function EthMemCompareWithRam(start_eth_address, start_ram_address, length_w : word) : boolean;
// Ex. bol := EthMemCompareWithRam(AddrPacket+30,@eth_ip_addr,4);
- Function EthMemCompareWithFlash(start_eth_address : word; start_Flash_address : longint; length_w : word) : boolean;
// Ex. bol := EthMemCompareWithFlash(AddrPacket+54, @httpHeader, 30);
- Function Eth_Cksum(start_eth_address, length_w : word) : word;
// Ex. cksum_ip := Eth_Cksum(TXSTART+14,20);
- Procedure Eth_WritePHYReg(register_address : byte; data : word);
// Write to PHY registers;
- Procedure Eth_SetLedConfig(NewConfig: word);
// Set Eth Led configuration. See datasheet for more detail.
- Function Eth_ReadPacket : word;
// Read packet and return TYPE OF SERVICE.
- Procedure Eth_Send(length_w : word);
// Send packet from Tx buffer.
Good luck !
Best regards Florin Medrea.