VxWorks, calculate tick receive timouts from systick, fixes #310

feature/soem_140
Andreas Karlsson 2019-06-12 14:50:38 +02:00
parent 131158dda8
commit 5c71c281fc
1 changed files with 22 additions and 12 deletions

View File

@ -38,6 +38,7 @@
#include <muxLib.h>
#include <ipProto.h>
#include <wvLib.h>
#include <sysLib.h>
#include "oshw.h"
#include "osal.h"
@ -98,6 +99,10 @@ const uint16 secMAC[3] = { 0x0404, 0x0404, 0x0404 };
/** 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);
@ -128,6 +133,11 @@ int ecx_setupnic(ecx_portt *port, const char *ifname, int secondary)
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.
*/
@ -672,7 +682,7 @@ static int ecx_recvpkt(ecx_portt *port, int idx, int stacknumber, M_BLK_ID * pMb
{
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)
{