A stack which works with or without an Mbed os library. Provides IPv4 or IPv6 with a full 1500 byte buffer.
Dependents: oldheating gps motorhome heating
link/link.c
- Committer:
- andrewboyson
- Date:
- 2018-12-05
- Revision:
- 94:e2973a2c488e
- Parent:
- 86:55bc5ddac16c
- Child:
- 97:d91f7db00235
File content as of revision 94:e2973a2c488e:
#include <stdbool.h> #include "gpio.h" #include "log.h" #include "eth.h" #include "action.h" #include "mac.h" #include "net.h" #include "link.h" #include "nic.h" #include "led.h" #define LINK_PIN FIO1PIN(25) #define SPEED_PIN FIO1PIN(26) bool LinkTrace = false; bool LinkPhyLink = false; bool LinkPhySpeed = false; bool LinkActivity = false; void LinkMain() { //Flash lights LinkPhyLink = ! LINK_PIN; LinkPhySpeed = !SPEED_PIN; if (!NicLinkIsUp()) return; //Handle packets int sizeRx; int sizeTx; char* pRx = NicGetReceivedPacketOrNull(&sizeRx); char* pTx = NicGetTransmitPacketOrNull(&sizeTx); int action = DO_NOTHING; NetTraceHostResetMatched(); LinkActivity = false; if (pRx) { LinkActivity = true; if (pTx) action = EthHandlePacket(pRx, sizeRx, pTx, &sizeTx); NicReleaseReceivedPacket(); } if (pTx) { if (!action) action = EthPollForPacketToSend(pTx, &sizeTx); if ( action) { LinkActivity = true; NicSendTransmitPacket(sizeTx); } } } void LinkInit() { NicInit(); NicLinkAddress(MacLocal); if (LinkTrace) { Log("\r\n"); LogTime("MAC: "); MacLog(MacLocal); Log("\r\n"); } }