static long getIoIntInfo(int cmd, dbCommon *pr, IOSCANPVT *iopvt) { devPvt *pPvt = (devPvt *)pr->dpvt; asynStatus status; /* If initCommon failed then pPvt->pfloat64 is NULL, return error */ if (!pPvt->pfloat64) return -1; if (cmd == 0) { /* Add to scan list. Register interrupts, create ring buffer */ asynPrint(pPvt->pasynUser, ASYN_TRACE_FLOW, "%s devAsynFloat64::getIoIntInfo registering interrupt\n", pr->name); createRingBuffer(pr); status = pPvt->pfloat64->registerInterruptUser( pPvt->float64Pvt,pPvt->pasynUser, pPvt->interruptCallback,pPvt,&pPvt->registrarPvt); if(status!=asynSuccess) { printf("%s devAsynFloat64 registerInterruptUser %s\n", pr->name,pPvt->pasynUser->errorMessage); } } else { asynPrint(pPvt->pasynUser, ASYN_TRACE_FLOW, "%s devAsynFloat64::getIoIntInfo cancelling interrupt\n", pr->name); status = pPvt->pfloat64->cancelInterruptUser(pPvt->float64Pvt, pPvt->pasynUser,pPvt->registrarPvt); if(status!=asynSuccess) { printf("%s devAsynFloat64 cancelInterruptUser %s\n", pr->name,pPvt->pasynUser->errorMessage); } } *iopvt = pPvt->ioScanPvt; return 0; }
int usb_start(USBEnumerateHandler hEnumerate, USBStartHandler hStart) { enumerateHandler = hEnumerate; startHandler = hStart; currentlySending = 0xFF; if(txQueue == NULL) txQueue = createRingBuffer(TX_QUEUE_LEN); initializeDescriptors(); if(controlSendBuffer == NULL) controlSendBuffer = memalign(DMA_ALIGN, CONTROL_SEND_BUFFER_LEN); if(controlRecvBuffer == NULL) controlRecvBuffer = memalign(DMA_ALIGN, CONTROL_RECV_BUFFER_LEN); SET_REG(USB + GAHBCFG, GAHBCFG_DMAEN | GAHBCFG_BSTLEN_INCR8 | GAHBCFG_MASKINT); SET_REG(USB + GUSBCFG, GUSBCFG_PHYIF16BIT | GUSBCFG_SRPENABLE | GUSBCFG_HNPENABLE | ((5 & GUSBCFG_TURNAROUND_MASK) << GUSBCFG_TURNAROUND_SHIFT)); SET_REG(USB + DCFG, DCFG_HISPEED); // some random setting. See specs SET_REG(USB + DCFG, GET_REG(USB + DCFG) & ~(DCFG_DEVICEADDRMSK)); InEPRegs[0].control = USB_EPCON_ACTIVE; OutEPRegs[0].control = USB_EPCON_ACTIVE; SET_REG(USB + GRXFSIZ, RX_FIFO_DEPTH); SET_REG(USB + GNPTXFSIZ, (TX_FIFO_DEPTH << GNPTXFSIZ_DEPTH_SHIFT) | TX_FIFO_STARTADDR); int i; for(i = 0; i < USB_NUM_ENDPOINTS; i++) { InEPRegs[i].interrupt = USB_EPINT_INEPNakEff | USB_EPINT_INTknEPMis | USB_EPINT_INTknTXFEmp | USB_EPINT_TimeOUT | USB_EPINT_AHBErr | USB_EPINT_EPDisbld | USB_EPINT_XferCompl; OutEPRegs[i].interrupt = USB_EPINT_OUTTknEPDis | USB_EPINT_SetUp | USB_EPINT_AHBErr | USB_EPINT_EPDisbld | USB_EPINT_XferCompl; InEPRegs[i].control = (InEPRegs[i].control & ~(DCTL_NEXTEP_MASK << DCTL_NEXTEP_SHIFT)); } SET_REG(USB + GINTMSK, GINTMSK_OTG | GINTMSK_SUSPEND | GINTMSK_RESET | GINTMSK_INEP | GINTMSK_OEP | GINTMSK_DISCONNECT); SET_REG(USB + DAINTMSK, DAINTMSK_ALL); SET_REG(USB + DOEPMSK, USB_EPINT_XferCompl | USB_EPINT_SetUp | USB_EPINT_Back2BackSetup); SET_REG(USB + DIEPMSK, USB_EPINT_XferCompl | USB_EPINT_AHBErr | USB_EPINT_TimeOUT); InEPRegs[0].interrupt = USB_EPINT_ALL; OutEPRegs[0].interrupt = USB_EPINT_ALL; SET_REG(USB + DCTL, DCTL_PROGRAMDONE + DCTL_CGOUTNAK + DCTL_CGNPINNAK); udelay(USB_PROGRAMDONE_DELAYUS); SET_REG(USB + GOTGCTL, GET_REG(USB + GOTGCTL) | GOTGCTL_SESSIONREQUEST); receiveControl(controlRecvBuffer, sizeof(USBSetupPacket)); change_state(USBPowered); interrupt_enable(USB_INTERRUPT); return 0; }
static long getIoIntInfo(int cmd, dbCommon *pr, IOSCANPVT *iopvt) { devPvt *pPvt = (devPvt *)pr->dpvt; asynStatus status; static const char *functionName="getIoIntInfo"; /* If initCommon failed then pPvt->pfloat64 is NULL, return error */ if (!pPvt->pfloat64) return -1; if (cmd == 0) { /* Add to scan list. Register interrupts, create ring buffer */ asynPrint(pPvt->pasynUser, ASYN_TRACE_FLOW, "%s %s::%s registering interrupt\n", pr->name, driverName, functionName); createRingBuffer(pr); /* Set a flag indicating that we are in I/O Intr scan mode. Used in aiAverage mode. */ pPvt->isIOIntrScan = 1; /* For aiAverage we don't enable callbacks here, because they are always enabled in any scan mode. */ if (!pPvt->isAiAverage) { status = pPvt->pfloat64->registerInterruptUser( pPvt->float64Pvt,pPvt->pasynUser, pPvt->interruptCallback,pPvt,&pPvt->registrarPvt); if(status!=asynSuccess) { printf("%s %s::%s registerInterruptUser %s\n", pr->name, driverName, functionName,pPvt->pasynUser->errorMessage); } } } else { asynPrint(pPvt->pasynUser, ASYN_TRACE_FLOW, "%s %s::%s cancelling interrupt\n", pr->name, driverName, functionName); /* Set a flag indicating that we are not in I/O Intr scan mode. Used in aiAverage mode. */ pPvt->isIOIntrScan = 0; /* For aiAverage we don't disable callbacks here, because they are always enabled in any scan mode. */ if (!pPvt->isAiAverage) { status = pPvt->pfloat64->cancelInterruptUser(pPvt->float64Pvt, pPvt->pasynUser,pPvt->registrarPvt); if(status!=asynSuccess) { printf("%s %s::%s cancelInterruptUser %s\n", pr->name, driverName, functionName,pPvt->pasynUser->errorMessage); } } } *iopvt = pPvt->ioScanPvt; return 0; }
static long getIoIntInfo(int cmd, dbCommon *pr, IOSCANPVT *iopvt) { devPvt *pPvt = (devPvt *)pr->dpvt; asynStatus status; static const char *functionName="getIoIntInfo"; /* If initCommon failed then pPvt->puint32 is NULL, return error */ if (!pPvt->puint32) return -1; if (cmd == 0) { /* Add to scan list. Register interrupts */ asynPrint(pPvt->pasynUser, ASYN_TRACE_FLOW, "%s %s::%s registering interrupt\n", pr->name, driverName, functionName); createRingBuffer(pr); status = pPvt->puint32->registerInterruptUser( pPvt->uint32Pvt,pPvt->pasynUser, pPvt->interruptCallback,pPvt,pPvt->mask,&pPvt->registrarPvt); if(status!=asynSuccess) { printf("%s %s::%s registerInterruptUser %s\n", pr->name, driverName, functionName,pPvt->pasynUser->errorMessage); } } else { asynPrint(pPvt->pasynUser, ASYN_TRACE_FLOW, "%s %s::%s cancelling interrupt\n", pr->name, driverName, functionName); status = pPvt->puint32->cancelInterruptUser(pPvt->uint32Pvt, pPvt->pasynUser,pPvt->registrarPvt); if(status!=asynSuccess) { printf("%s %s::%s cancelInterruptUser %s\n", pr->name, driverName, functionName,pPvt->pasynUser->errorMessage); } } *iopvt = pPvt->ioScanPvt; return 0; }
static long initCommon(dbCommon *pr, DBLINK *plink, userCallback processCallback,interruptCallbackFloat64 interruptCallback) { devPvt *pPvt; asynStatus status; asynUser *pasynUser; asynInterface *pasynInterface; pPvt = callocMustSucceed(1, sizeof(*pPvt), "devAsynFloat64::initCommon"); pr->dpvt = pPvt; pPvt->pr = pr; /* Create asynUser */ pasynUser = pasynManager->createAsynUser(processCallback, 0); pasynUser->userPvt = pPvt; pPvt->pasynUser = pasynUser; pPvt->ringBufferLock = epicsMutexCreate(); /* Parse the link to get addr and port */ status = pasynEpicsUtils->parseLink(pasynUser, plink, &pPvt->portName, &pPvt->addr,&pPvt->userParam); if (status != asynSuccess) { printf("%s devAsynFloat64::initCommon %s\n", pr->name, pasynUser->errorMessage); goto bad; } /* Connect to device */ status = pasynManager->connectDevice(pasynUser, pPvt->portName, pPvt->addr); if (status != asynSuccess) { printf("%s devAsynFloat64::initCommon connectDevice failed %s\n", pr->name, pasynUser->errorMessage); goto bad; } status = pasynManager->canBlock(pPvt->pasynUser, &pPvt->canBlock); if (status != asynSuccess) { printf("%s devAsynFloat64::initCommon canBlock failed %s\n", pr->name, pasynUser->errorMessage); goto bad; } /*call drvUserCreate*/ pasynInterface = pasynManager->findInterface(pasynUser,asynDrvUserType,1); if(pasynInterface && pPvt->userParam) { asynDrvUser *pasynDrvUser; void *drvPvt; pasynDrvUser = (asynDrvUser *)pasynInterface->pinterface; drvPvt = pasynInterface->drvPvt; status = pasynDrvUser->create(drvPvt,pasynUser,pPvt->userParam,0,0); if(status!=asynSuccess) { printf("%s devAsynFloat64::initCommon drvUserCreate %s\n", pr->name, pasynUser->errorMessage); goto bad; } } /* Get interface asynFloat64 */ pasynInterface = pasynManager->findInterface(pasynUser, asynFloat64Type, 1); if (!pasynInterface) { printf("%s devAsynFloat64::initCommon findInterface asynFloat64Type %s\n", pr->name,pasynUser->errorMessage); goto bad; } pPvt->pfloat64 = pasynInterface->pinterface; pPvt->float64Pvt = pasynInterface->drvPvt; /* Initialize synchronous interface */ status = pasynFloat64SyncIO->connect(pPvt->portName, pPvt->addr, &pPvt->pasynUserSync, pPvt->userParam); if (status != asynSuccess) { printf("%s devAsynFloat64::initCommon Float64SyncIO->connect failed %s\n", pr->name, pPvt->pasynUserSync->errorMessage); goto bad; } scanIoInit(&pPvt->ioScanPvt); pPvt->interruptCallback = interruptCallback; /* If the info field "asyn:READBACK" is 1 and interruptCallback is not NULL * then register for callbacks on output records */ if (interruptCallback) { int enableCallbacks=0; const char *callbackString; DBENTRY *pdbentry = dbAllocEntry(pdbbase); status = dbFindRecord(pdbentry, pr->name); if (status) { asynPrint(pPvt->pasynUser, ASYN_TRACE_ERROR, "%s devAsynFloat64::initCommon error finding record\n", pr->name); goto bad; } callbackString = dbGetInfo(pdbentry, "asyn:READBACK"); if (callbackString) enableCallbacks = atoi(callbackString); if (enableCallbacks) { status = createRingBuffer(pr); if (status!=asynSuccess) goto bad; status = pPvt->pfloat64->registerInterruptUser( pPvt->float64Pvt,pPvt->pasynUser, pPvt->interruptCallback,pPvt,&pPvt->registrarPvt); if(status!=asynSuccess) { printf("%s devAsynFloat64::initRecord error calling registerInterruptUser %s\n", pr->name,pPvt->pasynUser->errorMessage); } } } return INIT_OK; bad: recGblSetSevr(pr,LINK_ALARM,INVALID_ALARM); pr->pact=1; return INIT_ERROR; }
static long initCommon(dbCommon *pr, DBLINK *plink, userCallback processCallback,interruptCallbackUInt32Digital interruptCallback, interruptCallbackEnum callbackEnum, int maxEnums, char *pFirstString, int *pFirstValue, epicsEnum16 *pFirstSeverity) { devPvt *pPvt; asynStatus status; asynUser *pasynUser; asynInterface *pasynInterface; pPvt = callocMustSucceed(1, sizeof(*pPvt), "devAsynUInt32Digital::initCommon"); pr->dpvt = pPvt; pPvt->pr = pr; /* Create asynUser */ pasynUser = pasynManager->createAsynUser(processCallback, 0); pasynUser->userPvt = pPvt; pPvt->pasynUser = pasynUser; pPvt->ringBufferLock = epicsMutexCreate(); /* Parse the link to get addr and port */ status = pasynEpicsUtils->parseLinkMask(pasynUser, plink, &pPvt->portName, &pPvt->addr, &pPvt->mask,&pPvt->userParam); if (status != asynSuccess) { printf("%s devAsynUInt32Digital::initCommon %s\n", pr->name, pasynUser->errorMessage); goto bad; } /* Connect to device */ status = pasynManager->connectDevice(pasynUser, pPvt->portName, pPvt->addr); if (status != asynSuccess) { printf("%s devAsynUInt32Digital::initCommon connectDevice failed %s\n", pr->name, pasynUser->errorMessage); goto bad; } status = pasynManager->canBlock(pPvt->pasynUser, &pPvt->canBlock); if (status != asynSuccess) { printf("%s devAsynUInt32Digital::initCommon canBlock failed %s\n", pr->name, pasynUser->errorMessage); goto bad; } /*call drvUserCreate*/ pasynInterface = pasynManager->findInterface(pasynUser,asynDrvUserType,1); if(pasynInterface && pPvt->userParam) { asynDrvUser *pasynDrvUser; void *drvPvt; pasynDrvUser = (asynDrvUser *)pasynInterface->pinterface; drvPvt = pasynInterface->drvPvt; status = pasynDrvUser->create(drvPvt,pasynUser,pPvt->userParam,0,0); if(status!=asynSuccess) { printf("%s devAsynUInt32Digital::initCommon drvUserCreate %s\n", pr->name, pasynUser->errorMessage); goto bad; } } /* Get interface asynUInt32Digital */ pasynInterface = pasynManager->findInterface(pasynUser, asynUInt32DigitalType, 1); if (!pasynInterface) { printf("%s devAsynUInt32Digital::initCommon " "findInterface asynUInt32DigitalType %s\n", pr->name,pasynUser->errorMessage); goto bad; } pPvt->puint32 = pasynInterface->pinterface; pPvt->uint32Pvt = pasynInterface->drvPvt; /* Initialize synchronous interface */ status = pasynUInt32DigitalSyncIO->connect(pPvt->portName, pPvt->addr, &pPvt->pasynUserSync, pPvt->userParam); if (status != asynSuccess) { printf("%s devAsynUInt32Digital::initCommon UInt32DigitalSyncIO->connect failed %s\n", pr->name, pPvt->pasynUserSync->errorMessage); goto bad; } pPvt->interruptCallback = interruptCallback; scanIoInit(&pPvt->ioScanPvt); /* Initialize asynEnum interfaces */ pasynInterface = pasynManager->findInterface(pPvt->pasynUser,asynEnumType,1); if (pasynInterface && (maxEnums > 0)) { size_t numRead; asynEnum *pasynEnum = pasynInterface->pinterface; void *registrarPvt; status = pasynEnumSyncIO->connect(pPvt->portName, pPvt->addr, &pPvt->pasynUserEnumSync, pPvt->userParam); if (status != asynSuccess) { printf("%s devAsynUInt32Digital::initCommon EnumSyncIO->connect failed %s\n", pr->name, pPvt->pasynUserEnumSync->errorMessage); goto bad; } status = pasynEnumSyncIO->read(pPvt->pasynUserEnumSync, pPvt->enumStrings, pPvt->enumValues, pPvt->enumSeverities, maxEnums, &numRead, pPvt->pasynUser->timeout); if (status == asynSuccess) { setEnums(pFirstString, pFirstValue, pFirstSeverity, pPvt->enumStrings, pPvt->enumValues, pPvt->enumSeverities, numRead, maxEnums); } status = pasynEnum->registerInterruptUser( pasynInterface->drvPvt, pPvt->pasynUser, callbackEnum, pPvt, ®istrarPvt); if(status!=asynSuccess) { printf("%s devAsynUInt32Digital enum registerInterruptUser %s\n", pr->name,pPvt->pasynUser->errorMessage); } } /* If the info field "asyn:READBACK" is 1 and interruptCallback is not NULL * then register for callbacks on output records */ if (interruptCallback) { int enableCallbacks=0; const char *callbackString; DBENTRY *pdbentry = dbAllocEntry(pdbbase); status = dbFindRecord(pdbentry, pr->name); if (status) { asynPrint(pPvt->pasynUser, ASYN_TRACE_ERROR, "%s devAsynUInt32Digital::initCommon error finding record\n", pr->name); goto bad; } callbackString = dbGetInfo(pdbentry, "asyn:READBACK"); if (callbackString) enableCallbacks = atoi(callbackString); if (enableCallbacks) { status = createRingBuffer(pr); if (status!=asynSuccess) goto bad; status = pPvt->puint32->registerInterruptUser( pPvt->uint32Pvt,pPvt->pasynUser, pPvt->interruptCallback,pPvt,pPvt->mask, &pPvt->registrarPvt); if(status!=asynSuccess) { printf("%s devAsynUInt32Digital::initRecord error calling registerInterruptUser %s\n", pr->name,pPvt->pasynUser->errorMessage); } } } return INIT_OK; bad: recGblSetSevr(pr,LINK_ALARM,INVALID_ALARM); pr->pact=1; return INIT_ERROR; }
RingBufferPool::RingBufferPool() : defaultRingBuffer_(createRingBuffer(DEFAULT_ID)) {}