Mbed library for ENC28J60 Ethernet modules. Full support for TCP/IP and UDP Server, Client and HTTP server (webserver). DHCP and DNS is included.
Dependents: mBuino_ENC28_MQTT Nucleo_Web_ENC28J60 Nucleo_Web_ENC28J60_ADC Serial_over_Ethernet ... more
Enc28j60Eth.h
00001 /* 00002 Enc28J60Network.h 00003 UIPEthernet network driver for Microchip ENC28J60 Ethernet Interface. 00004 00005 Copyright (c) 2013 Norbert Truchsess <norbert.truchsess@t-online.de> 00006 All rights reserved. 00007 00008 based on enc28j60.c file from the AVRlib library by Pascal Stang. 00009 For AVRlib See http://www.procyonengineering.com/ 00010 00011 Modified (ported to mbed) by Zoltan Hudak <hudakz@inbox.com> 00012 00013 This program is free software: you can redistribute it and/or modify 00014 it under the terms of the GNU General Public License as published by 00015 the Free Software Foundation, either version 3 of the License, or 00016 (at your option) any later version. 00017 00018 This program is distributed in the hope that it will be useful, 00019 but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 GNU General Public License for more details. 00022 00023 You should have received a copy of the GNU General Public License 00024 along with this program. If not, see <http://www.gnu.org/licenses/>. 00025 */ 00026 #ifndef ENC28J60PHY_H 00027 #define ENC28J60PHY_H 00028 00029 #include "mbed.h" 00030 #include "MemPool.h" 00031 00032 #define UIP_RECEIVEBUFFERHANDLE 0xff 00033 00034 //#define ENC28J60DEBUG 00035 00036 class Enc28j60Eth : public MemPool 00037 { 00038 private: 00039 SPI _spi; 00040 DigitalOut _cs; 00041 static uint16_t nextPacketPtr; 00042 static uint8_t bank; 00043 00044 static struct memblock receivePkt; 00045 00046 uint16_t setReadPtr(memhandle handle, memaddress position, uint16_t len); 00047 void setERXRDPT(); 00048 void readBuffer(uint16_t len, uint8_t* data); 00049 void writeBuffer(uint16_t len, uint8_t* data); 00050 void setBank(uint8_t address); 00051 uint8_t readReg(uint8_t address); 00052 void writeReg(uint8_t address, uint8_t data); 00053 void phyWrite(uint8_t address, uint16_t data); 00054 uint16_t phyRead(uint8_t address); 00055 void clkout(uint8_t clk); 00056 00057 friend void enc28j60_mempool_block_move_callback(memaddress, memaddress, memaddress); 00058 public: 00059 Enc28j60Eth(PinName mosi, PinName miso, PinName sclk, PinName cs); 00060 uint8_t getrev(); 00061 void powerOn(); 00062 void powerOff(); 00063 bool linkStatus(); 00064 00065 void init(uint8_t* macaddr); 00066 memhandle receivePacket(); 00067 void freePacket(); 00068 size_t blockSize(memhandle handle); 00069 void sendPacket(memhandle handle); 00070 uint16_t readPacket(memhandle handle, memaddress position, uint8_t* buffer, uint16_t len); 00071 uint16_t writePacket(memhandle handle, memaddress position, uint8_t* buffer, uint16_t len); 00072 void copyPacket(memhandle dest, memaddress dest_pos, memhandle src, memaddress src_pos, uint16_t len); 00073 uint16_t chksum(uint16_t sum, memhandle handle, memaddress pos, uint16_t len); 00074 00075 uint8_t readOp(uint8_t op, uint8_t address); 00076 uint8_t readByte(uint16_t addr); 00077 void writeOp(uint8_t op, uint8_t address, uint8_t data); 00078 void writeRegPair(uint8_t address, uint16_t data); 00079 void writeByte(uint16_t addr, uint8_t data); 00080 }; 00081 00082 #endif
Generated on Tue Jul 12 2022 18:48:00 by 1.7.2