#include <ctype.h>
#include <string.h>
#include <stdio.h>
-#include <muxLib.h>
-#include <ipProto.h>
-#include <wvLib.h>
+#include <muxLib.h>
+#include <ipProto.h>
+#include <wvLib.h>
+#include <sysLib.h>
#include "oshw.h"
#include "osal.h"
/** second MAC word is used for identification */
#define RX_SEC secMAC[1]
+/* usec per tick for timeconversion, default to 1kHz */
+#define USECS_PER_SEC 1000000
+static unsigned int usec_per_tick = 1000;
+
/** Receive hook called by Mux driver. */
static int mux_rx_callback(void* pCookie, long type, M_BLK_ID pMblk, LL_HDR_INFO *llHdrInfo, void *muxUserArg);
int unit_no = -1;
ETHERCAT_PKT_DEV * pPktDev;
+ /* Get systick info, sysClkRateGet return ticks per second */
+ usec_per_tick = USECS_PER_SEC / sysClkRateGet();
+ /* Don't allow 0 since it is used in DIV */
+ if(usec_per_tick == 0)
+ usec_per_tick = 1;
/* Make reference to packet device struct, keep track if the packet
* device is the redundant or not.
*/
pPktDev = &(port->pktDev);
pPktDev->redundant = 0;
}
-
+
/* Clear frame counters*/
pPktDev->tx_count = 0;
pPktDev->rx_count = 0;
break;
}
}
-
+
/* Detach IP stack */
//ipDetach(pktDev.unit,pktDev.name);
-
+
pPktDev->port = port;
-
+
/* Bind to mux driver for given interface, include ethercat driver pointer
* as user reference
*/
}
}
ecx_clear_rxbufstat(&(port->rxbufstat[0]));
- }
-
+ }
+
/* setup ethernet headers in tx buffers so we don't have to repeat it */
for (i = 0; i < EC_MAXBUF; i++)
{
port->rxbufstat[i] = EC_BUF_EMPTY;
}
ec_setupheader(&(port->txbuf2));
-
+
return 1;
-
+
exit:
return 0;
{
int bytesrx = 0;
MSG_Q_ID msgQId;
- int tick_timeout = max((timeout / 1000), 1);
+ int tick_timeout = max((timeout / usec_per_tick), 1);
if (stacknumber == 1)
{