Add asynUInt32Digital interface support to asyn motors (allows bo & bi records)

This commit is contained in:
Peter Denison
2008-05-19 15:30:20 +00:00
parent dce970eb15
commit c235bb8b99
+114 -4
View File
@@ -19,9 +19,9 @@
* of this distribution.
* ************************************************************************
*
* Version: $Revision: 1.18 $
* Modified by: $Author: sluiter $
* Last Modified: $Date: 2008-04-02 19:47:34 $
* Version: $Revision: 1.19 $
* Modified by: $Author: peterd $
* Last Modified: $Date: 2008-05-19 15:30:20 $
*
* Original Author: Peter Denison
* Current Author: Peter Denison
@@ -48,6 +48,7 @@
#include <asynDriver.h>
#include <asynInt32.h>
#include <asynUInt32Digital.h>
#include <asynFloat64.h>
#include <asynFloat64Array.h>
#include <asynMotorStatus.h>
@@ -135,6 +136,8 @@ typedef struct drvmotorPvt {
asynInterface common;
asynInterface int32;
void *int32InterruptPvt;
asynInterface uint32digital;
void *uint32digitalInterruptPvt;
asynInterface float64;
void *float64InterruptPvt;
asynInterface float64Array;
@@ -149,6 +152,10 @@ static asynStatus readInt32 (void *drvPvt, asynUser *pasynUser,
epicsInt32 *value);
static asynStatus writeInt32 (void *drvPvt, asynUser *pasynUser,
epicsInt32 value);
static asynStatus readUInt32Digital (void *drvPvt, asynUser *pasynUser,
epicsUInt32 *value, epicsUInt32 mask);
static asynStatus writeUInt32Digital (void *drvPvt, asynUser *pasynUser,
epicsUInt32 value, epicsUInt32 mask);
static asynStatus getBounds (void *drvPvt, asynUser *pasynUser,
epicsInt32 *low, epicsInt32 *high);
static asynStatus readFloat64 (void *drvPvt, asynUser *pasynUser,
@@ -188,6 +195,16 @@ static asynInt32 drvMotorInt32 = {
getBounds
};
static asynUInt32Digital drvMotorUInt32Digital = {
writeUInt32Digital,
readUInt32Digital,
NULL,
NULL,
NULL,
NULL,
NULL
};
static asynFloat64 drvMotorFloat64 = {
writeFloat64,
readFloat64
@@ -237,6 +254,9 @@ int drvAsynMotorConfigure(const char *portName, const char *driverName,
pPvt->int32.interfaceType = asynInt32Type;
pPvt->int32.pinterface = (void *)&drvMotorInt32;
pPvt->int32.drvPvt = pPvt;
pPvt->uint32digital.interfaceType = asynUInt32DigitalType;
pPvt->uint32digital.pinterface = (void *)&drvMotorUInt32Digital;
pPvt->uint32digital.drvPvt = pPvt;
pPvt->float64.interfaceType = asynFloat64Type;
pPvt->float64.pinterface = (void *)&drvMotorFloat64;
pPvt->float64.drvPvt = pPvt;
@@ -273,6 +293,14 @@ int drvAsynMotorConfigure(const char *portName, const char *driverName,
pasynManager->registerInterruptSource(portName, &pPvt->int32,
&pPvt->int32InterruptPvt);
status = pasynUInt32DigitalBase->initialize(pPvt->portName,&pPvt->uint32digital);
if (status != asynSuccess) {
errlogPrintf("drvAsynMotorConfigure ERROR: Can't register uint32digital\n");
return -1;
}
pasynManager->registerInterruptSource(portName, &pPvt->uint32digital,
&pPvt->uint32digitalInterruptPvt);
status = pasynFloat64Base->initialize(pPvt->portName,&pPvt->float64);
if (status != asynSuccess) {
errlogPrintf("drvAsynMotorConfigure ERROR: Can't register float64\n");
@@ -399,6 +427,45 @@ static asynStatus readInt32(void *drvPvt, asynUser *pasynUser,
return(asynSuccess);
}
static asynStatus readUInt32Digital(void *drvPvt, asynUser *pasynUser,
epicsUInt32 *value, epicsUInt32 mask)
{
drvmotorPvt *pPvt = (drvmotorPvt *)drvPvt;
drvmotorAxisPvt *pAxis;
int channel;
motorCommand command = pasynUser->reason;
pasynManager->getAddr(pasynUser, &channel);
if (channel >= pPvt->numAxes) {
epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize,
"drvMotorAsyn::readInt32 Invalid axis %d", channel);
return(asynError);
}
pAxis = &pPvt->axisData[channel];
if (!pAxis->axis) {
epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize,
"drvMotorAsyn::readInt32 Uninitialised axis %d", pAxis->num);
return(asynError);
}
switch(command) {
case -1: /* This is commands we know about but don't want uint32digital interface for */
epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize,
"drvMotorAsyn::readUInt32Digital invalid command=%d",
command);
return(asynError);
default:
(*pPvt->drvset->getInteger)(pAxis->axis, command, value);
break;
}
*value = *value & mask;
asynPrint(pasynUser, ASYN_TRACEIO_DRIVER,
"drvMotorAsyn::readUInt32Digital, reason=%d, value=%d\n",
command, *value);
return(asynSuccess);
}
static asynStatus readFloat64(void *drvPvt, asynUser *pasynUser,
epicsFloat64 *value)
@@ -486,7 +553,7 @@ static asynStatus writeInt32(void *drvPvt, asynUser *pasynUser,
switch(command) {
case -1:
epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize,
"drvMotorAsyn::writeInt32D invalid command=%d",
"drvMotorAsyn::writeInt32 invalid command=%d",
command);
return(asynError);
case motorStop:
@@ -515,6 +582,49 @@ static asynStatus writeInt32(void *drvPvt, asynUser *pasynUser,
return(status);
}
static asynStatus writeUInt32Digital(void *drvPvt, asynUser *pasynUser,
epicsUInt32 value, epicsUInt32 mask)
{
drvmotorPvt *pPvt = (drvmotorPvt *)drvPvt;
drvmotorAxisPvt *pAxis;
int channel;
motorCommand command = pasynUser->reason;
asynStatus status;
epicsUInt32 temp = 0;
pasynManager->getAddr(pasynUser, &channel);
if (channel >= pPvt->numAxes) {
epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize,
"drvMotorAsyn::writeInt32 Invalid axis %d", channel);
return(asynError);
}
pAxis = &pPvt->axisData[channel];
if (!pAxis->axis) {
epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize,
"drvMotorAsyn::writeInt32 Uninitialised axis %d", pAxis->num);
return(asynError);
}
switch(command) {
case -1:
epicsSnprintf(pasynUser->errorMessage, pasynUser->errorMessageSize,
"drvMotorAsyn::writeUInt32Digital invalid command=%d",
command);
return(asynError);
default:
(*pPvt->drvset->getInteger)(pAxis->axis, command, &temp);
temp &= ~mask;
temp |= (value & mask);
status = (*pPvt->drvset->setInteger)(pAxis->axis, command, temp);
break;
}
asynPrint(pasynUser, ASYN_TRACEIO_DRIVER,
"drvMotorAsyn::writeUInt32Digital, reason=%d, value=%d\n",
command, temp);
return(status);
}
static asynStatus writeFloat64(void *drvPvt, asynUser *pasynUser,
epicsFloat64 value)
{