forked from epics_driver_modules/motorBase
- 64-bit compatiability.
- changed IRS/task comm. mechanism from epicsRingPointer to epicsRingByte.
This commit is contained in:
+39
-39
@@ -2,9 +2,9 @@
|
||||
FILENAME... drvOms.cc
|
||||
USAGE... Driver level support for OMS models VME8, VME44 and VS4.
|
||||
|
||||
Version: $Revision: 1.26 $
|
||||
Modified By: $Author: rivers $
|
||||
Last Modified: $Date: 2008-01-11 21:53:05 $
|
||||
Version: $Revision: 1.27 $
|
||||
Modified By: $Author: sluiter $
|
||||
Last Modified: $Date: 2008-03-14 20:36:10 $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -70,6 +70,9 @@ Last Modified: $Date: 2008-01-11 21:53:05 $
|
||||
* `tree_list' not supported..." compiler error message.
|
||||
* .11 03-23-05 rls - Make OSI.
|
||||
* .12 05-02-05 rls - Bug fix for stale data delay; set delay = 10ms.
|
||||
* .13 03-14-08 rls - 64-bit compatiability.
|
||||
* - changed IRS to task comm. mechanism from epicsRingPointer
|
||||
* to epicsRingByte.
|
||||
*/
|
||||
|
||||
/*========================stepper motor driver ========================
|
||||
@@ -105,8 +108,6 @@ Last Modified: $Date: 2008-01-11 21:53:05 $
|
||||
#include "drvOms.h"
|
||||
#include "epicsExport.h"
|
||||
|
||||
#define PRIVATE_FUNCTIONS 1 /* normal:1, debug:0 */
|
||||
|
||||
/* Define for return test on devNoResponseProbe() */
|
||||
#define PROBE_SUCCESS(STATUS) ((STATUS)==S_dev_addressOverlap)
|
||||
|
||||
@@ -210,9 +211,8 @@ static long report(int level)
|
||||
{
|
||||
for (card = 0; card < oms44_num_cards; card++)
|
||||
if (motor_state[card])
|
||||
printf(" Oms VME8/44 motor card %d @ 0x%X, id: %s \n", card,
|
||||
(epicsUInt32) motor_state[card]->localaddr,
|
||||
motor_state[card]->ident);
|
||||
printf(" Oms VME8/44 motor card %d @ %p, id: %s \n", card,
|
||||
motor_state[card]->localaddr, motor_state[card]->ident);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
@@ -636,14 +636,14 @@ static int omsGet(int card, char *pchar, bool timeout)
|
||||
if (irqdata->irqEnable)
|
||||
{
|
||||
/* Get character from isr - if available */
|
||||
while (irqdata->recv_rng->isEmpty() && timeout == true && retry < 5)
|
||||
while (epicsRingBytesIsEmpty(irqdata->recv_rng) && timeout == true && retry < 5)
|
||||
{
|
||||
irqdata->recv_sem->wait(0.05); /* Wait 250ms for character */
|
||||
retry ++;
|
||||
}
|
||||
if (!irqdata->recv_rng->isEmpty())
|
||||
if (!epicsRingBytesIsEmpty(irqdata->recv_rng))
|
||||
{
|
||||
*pchar = (char) ((epicsUInt32) irqdata->recv_rng->pop() & 0xFF);
|
||||
epicsRingBytesGet(irqdata->recv_rng, pchar, 1);
|
||||
getCnt = 1;
|
||||
}
|
||||
}
|
||||
@@ -679,28 +679,21 @@ static RTN_STATUS omsPut(int card, char *pmess)
|
||||
volatile struct controller *pmotorState;
|
||||
volatile struct vmex_motor *pmotor;
|
||||
struct irqdatastr *irqdata;
|
||||
int key;
|
||||
char *putptr;
|
||||
int key, msgsize;
|
||||
|
||||
pmotorState = motor_state[card];
|
||||
irqdata = (struct irqdatastr *) pmotorState->DevicePrivate;
|
||||
pmotor = (struct vmex_motor *) pmotorState->localaddr;
|
||||
msgsize = strlen(pmess);
|
||||
|
||||
if (irqdata->irqEnable)
|
||||
{
|
||||
putptr = pmess;
|
||||
/* Put string into isr transmitt buffer */
|
||||
while (*putptr != (char) NULL)
|
||||
{
|
||||
char outchar = *putptr;
|
||||
if (!irqdata->send_rng->push((char *) outchar))
|
||||
{
|
||||
errlogPrintf("omsPut: card %d send ring full, lost '%c'\n",
|
||||
card, *putptr);
|
||||
return(ERROR);
|
||||
}
|
||||
putptr++;
|
||||
}
|
||||
if (epicsRingBytesPut(irqdata->send_rng, pmess, msgsize) != msgsize)
|
||||
{
|
||||
errlogPrintf("omsPut: card %d send ring full!\n", card);
|
||||
return(ERROR);
|
||||
}
|
||||
|
||||
/* Turn-on transmit buffer interrupt */
|
||||
key = epicsInterruptLock();
|
||||
@@ -709,6 +702,8 @@ static RTN_STATUS omsPut(int card, char *pmess)
|
||||
}
|
||||
else
|
||||
{
|
||||
char *putptr;
|
||||
|
||||
/* Send next message */
|
||||
for (putptr = pmess; *putptr != '\0'; putptr++)
|
||||
{
|
||||
@@ -844,10 +839,13 @@ static void motorIsr(int card)
|
||||
/* Send message */
|
||||
if (status & STAT_TRANS_BUF_EMPTY)
|
||||
{
|
||||
if (irqdata->send_rng->isEmpty())
|
||||
if (epicsRingBytesIsEmpty(irqdata->send_rng))
|
||||
control &= ~IRQ_TRANS_BUF; /* Transmit done - disable irq */
|
||||
else
|
||||
pmotor->data = (char) ((epicsUInt32) irqdata->send_rng->pop() & 0xFF);
|
||||
{
|
||||
epicsRingBytesGet(irqdata->send_rng, &dataChar, 1);
|
||||
pmotor->data = dataChar;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read Response */
|
||||
@@ -855,10 +853,9 @@ static void motorIsr(int card)
|
||||
{
|
||||
dataChar = pmotor->data;
|
||||
|
||||
if (!irqdata->recv_rng->push((char *) dataChar))
|
||||
if (epicsRingBytesPut(irqdata->recv_rng, &dataChar, 1) == 0)
|
||||
{
|
||||
errlogPrintf("card %d recv ring full, lost '%c'\n", card,
|
||||
dataChar);
|
||||
errlogPrintf("card %d recv ring full, lost '%c'\n", card, dataChar);
|
||||
irqdata->irqErrno |= STAT_INPUT_BUF_FULL;
|
||||
}
|
||||
irqdata->recv_sem->signal();
|
||||
@@ -919,10 +916,10 @@ static int motorIsrEnable(int card)
|
||||
/* Setup card for interrupt-on-done */
|
||||
pmotor->vector = omsInterruptVector + card;
|
||||
|
||||
irqdata->recv_rng = new epicsRingPointer<char>(OMS_RESP_Q_SZ);
|
||||
irqdata->recv_rng = epicsRingBytesCreate(OMS_RESP_Q_SZ);
|
||||
irqdata->recv_sem = new epicsEvent(epicsEventEmpty);
|
||||
|
||||
irqdata->send_rng = new epicsRingPointer<char>(MAX_MSG_SIZE * 2);
|
||||
irqdata->send_rng = epicsRingBytesCreate(MAX_MSG_SIZE * 2);
|
||||
|
||||
irqdata->irqEnable = TRUE;
|
||||
irqdata->irqErrno = 0;
|
||||
@@ -963,8 +960,8 @@ static void motorIsrDisable(int card)
|
||||
/* Remove interrupt control functions */
|
||||
irqdata->irqEnable = FALSE;
|
||||
irqdata->irqErrno = 0;
|
||||
delete irqdata->recv_rng;
|
||||
delete irqdata->send_rng;
|
||||
epicsRingBytesDelete(irqdata->recv_rng);
|
||||
epicsRingBytesDelete(irqdata->send_rng);
|
||||
delete irqdata->recv_sem;
|
||||
}
|
||||
|
||||
@@ -986,9 +983,13 @@ int omsSetup(int num_cards, /* maximum number of cards in rack */
|
||||
oms44_num_cards = num_cards;
|
||||
|
||||
/* Check boundary(16byte) on base address */
|
||||
#ifdef __LP64__
|
||||
if ((motorUInt64) addrs & 0xF)
|
||||
#else
|
||||
if ((epicsUInt32) addrs & 0xF)
|
||||
#endif
|
||||
{
|
||||
Debug(1, "omsSetup: invalid base address 0x%X\n", (epicsUInt32) addrs);
|
||||
Debug(1, "omsSetup: invalid base address %p\n", addrs);
|
||||
oms_addrs = (char *) OMS_NUM_ADDRS;
|
||||
}
|
||||
else
|
||||
@@ -1072,8 +1073,7 @@ static int motor_init()
|
||||
startAddr = (epicsInt8 *) probeAddr + 1;
|
||||
endAddr = startAddr + OMS_BRD_SIZE;
|
||||
|
||||
Debug(9, "motor_init: devNoResponseProbe() on addr 0x%x\n",
|
||||
(epicsUInt32) probeAddr);
|
||||
Debug(9, "motor_init: devNoResponseProbe() on addr %p\n", probeAddr);
|
||||
/* Scan memory space to assure card id */
|
||||
#ifdef vxWorks
|
||||
do
|
||||
@@ -1099,7 +1099,7 @@ static int motor_init()
|
||||
return (ERROR);
|
||||
}
|
||||
#endif
|
||||
Debug(9, "motor_init: localaddr = %x\n", (epicsUInt32) localaddr);
|
||||
Debug(9, "motor_init: localaddr = %p\n", localaddr);
|
||||
pmotor = (struct vmex_motor *) localaddr;
|
||||
|
||||
Debug(9, "motor_init: malloc'ing motor_state\n");
|
||||
@@ -1176,7 +1176,7 @@ static int motor_init()
|
||||
set_status(card_index, motor_index);
|
||||
}
|
||||
|
||||
Debug(2, "Init Address=0x%8.8x\n", (epicsUInt32) localaddr);
|
||||
Debug(2, "Init Address=%p\n", localaddr);
|
||||
Debug(3, "Total encoders = %d\n\n", total_encoders);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -3,9 +3,9 @@ FILENAME... drvOms.h
|
||||
USAGE... This file contains OMS driver "include" information that is
|
||||
specific to OMS models VME8 and VME44.
|
||||
|
||||
Version: $Revision: 1.4 $
|
||||
Version: $Revision: 1.5 $
|
||||
Modified By: $Author: sluiter $
|
||||
Last Modified: $Date: 2003-10-28 16:40:05 $
|
||||
Last Modified: $Date: 2008-03-14 20:36:10 $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -41,6 +41,7 @@ Last Modified: $Date: 2003-10-28 16:40:05 $
|
||||
#define INCdrvOmsh 1
|
||||
|
||||
#include "drvOmsCom.h"
|
||||
#include "epicsRingBytes.h"
|
||||
|
||||
/*
|
||||
* VME8/44 default profile
|
||||
@@ -100,9 +101,9 @@ struct irqdatastr /* Used only for VME44. */
|
||||
/* Interrupt Handling control elements */
|
||||
int irqErrno; /* Error indicator from isr */
|
||||
epicsUInt8 irqEnable;
|
||||
epicsRingPointer<char> *recv_rng; /* message receiving control */
|
||||
epicsRingBytesId recv_rng; /* message receiving control */
|
||||
epicsEvent *recv_sem;
|
||||
epicsRingPointer<char> *send_rng; /* message transmitting control */
|
||||
epicsRingBytesId send_rng; /* message transmitting control */
|
||||
};
|
||||
|
||||
#endif /* INCdrvOmsh */
|
||||
|
||||
Reference in New Issue
Block a user