/*============================================================================= Name: devWfPadLlrf.c Abs: Device support for pumping data of a 4-channel PAD into a single waveform. Modelled after T.Straumann's BPM Application Code. Uses UdpComm-R2-x-y Auth: Shantha Condamoor (scondam) Rev: May 23 2011 - Initial Release -----------------------------------------------------------------------------*/ #if 0 #include "copyright_SLAC.h" /* SLAC copyright comments */ #endif /*----------------------------------------------------------------------------- Mod: (see CVS log) =============================================================================*/ #include #include #include #include #include #ifdef BASE_HAS_NO_NTP_PATCH #include #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* RTEMS priorities of the most important threads */ /* IIRC the highest priority task we start are the watchdog (19) * and the lanIpBasic callout task which is at 25. * * Hence we use numbers below that. */ /* The padThread is the worker who copies data from * the ADC FIFOs to the 9118 Lan chip. * It has the highest priority. */ #define PAD_THREAD_PRI 10 /* The udp listener is the task that handles padRequests * etc. It is responsible for setting the stream timestamp * and therefore has the second-highest priority */ #define UDP_LISTEN_PRI 12 /* If neither of the above have any work to do then * the next important thing is handling lanIpBasic * networking. */ #define LAN_IPBASIC_PRI 14 /* #include */ #include #include #include #include #include /* Re-define symbols for rtems 4.9.1 */ #if !defined(__RTEMS_MAJOR__) #error "missing header" #elif (__RTEMS_MAJOR__ > 4) || (__RTEMS_MAJOR__ == 4 && __RTEMS_MINOR__ >= 9) #include #define Timer_initialize() benchmark_timer_initialize() #define Read_timer() benchmark_timer_read() #endif #include #include #define DEVSUPNAM "devWfPadLlrf" /* Align up to next multiple of 8. * We strictly only need multiples of 4 (4 channels) * but making sure we always have an even number of * samples makes storing the row-major format easier */ #define CHANNEL_NO_ALIGN(x) (((x)+7) & ~7) /* Which chip select we are using - this is setup by the BSP * but not published :-( */ #define CS1_BASE_ADDR 0x30000000 /* Direct access to the LAN9118 FIFO -- an ugly hack * but it's much faster... */ #define LAN9118_FIFO_HACK ((volatile void*)0x31000800) /* Just a name for sake of readability */ #define CS1 1 /* Shall we interrupt on the falling (trigger detected) or * raising ('fifo full' [rather: N clocks expired]) edge? * The former is OK if the clock rate is faster than * we can read the fifo (~8MB/s -> clock > 1MHz). */ #define IRQ_EDGE EPORT_FALLING #define STATIC #define DEBUG_PROC (1<<0) #define DEBUG_TIMING (1<<1) #define DEBUG_IRQ (1<<3) #define PAD_MAX_INT (2147483647) /* 4 byte int - 1 bit for sign */ int pad_debug=0; short data_ondemand = 0; typedef struct { int channel; uint32_t mcaddr; } *PadUdpThreadArg; int drvPadLlrfTrigPin = TRIG_PIN_DFLT; int drvPadLlrfIrqPin = IRQ_PIN_DFLT; LOCAL int prev_intrCount = 0; /* scondam: 04.18.11: added to calculate trigger rate */ LOCAL int cur_intrCount = 0; /* scondam: 04.18.11: added to calculate trigger rate */ int devWfPadLlrfDebug = DEBUG_IRQ | DEBUG_TIMING; int devWfPadLlrfIrqs = 0; int readMethod = 0; typedef int16_t __attribute__ ((may_alias)) int16_t_a; typedef uint32_t __attribute__ ((may_alias)) uint32_t_a; epicsThreadId devWfPadThread = 0; static DBADDR dbAddrRarm = {0}; static epicsThreadId drvPadStreamInit(); /* static int gotCalt; */ typedef struct DevWfPadDpvt_ts_ { waveformRecord *rec_p; CALLBACK cb_s; int irq_pin; int trig_pin; volatile int irq; int orarm; epicsEventId sync; unsigned long nusr; /* support user resizing of array */ void (*readFifos)(volatile void*, int, int, int, int); } DevWfPadDpvt_ts, *DevWfPadDpvt_tps; /* Forward Declarations */ static int start_stop_cb(PadRequest req, PadStrmCommand start, void *uarg); static void isr(void *arg_p); static void padThread(void *arg); /* Little Helpers */ static void trigRaise(int trig_pin) { coldfEportEpdrSet(trig_pin, 1); } static void disarm(DevWfPadDpvt_tps dpvt_ps) { /* if the device is currently armed we can't * really disarm it, i.e., we can't prevent * the next trigger from happening. */ coldfEportIntDisable(dpvt_ps->irq_pin); /* If a hw trigger happens after the board * is disarmed the following can happen * on the next 'arm' operation: * a) FIFO full -> everything OK * b) FIFO still filling -> OK, next trigger will be caught * c) FIFO still filling, SW trigger -> BAD will effectively * disarm board. * ==> SW trigger should verify that fifo is not * currently filling. If it is then * just run the ISR so the current data * is sucked. */ } /* * Read RARM field directly from the record * (we assume reading an 'int' is atomical). */ int devPadWfGetRarm(int *p_val) { if ( ! dbAddrRarm.precord ) { errlogPrintf("devPadWfGetRarm: dbAddr not initialized\n"); return -1; } *p_val = (int)((waveformRecord*)dbAddrRarm.precord)->rarm; return 0; } /* Write RARM field through database */ int devPadWfSetRarm(int val) { long x = val; if ( ! dbAddrRarm.precord ) { errlogPrintf("devPadWfSetRarm: dbAddr not initialized\n"); return -1; } return dbPutField(&dbAddrRarm, DBR_LONG, &x, 1); } static void arm(DevWfPadDpvt_tps dpvt_ps, int doSwTrig) { int intEnable = 1; /* to keep things simple, we disable interrupts here * so the ISR doesn't change EPORT bits under our feet. */ coldfEportIntDisable(dpvt_ps->irq_pin); /* clear old flag set by any pre-arm triggers */ coldfEportFlagClr(dpvt_ps->irq_pin); /* clear old CAL flag */ /* drvPadAfeGotCalt(1); */ /* release trigger pin */ coldfEportEpdrSet(dpvt_ps->trig_pin, 0); if ( doSwTrig ) { intEnable = ( 0 == drvPadAdcTrigger(dpvt_ps->trig_pin, dpvt_ps->irq_pin) ); if ( !intEnable ) { /* no; it appears above we cleared the interrupt * that caused this acquisition. * just fake an IRQ here. */ dpvt_ps->irq = 1; /* signal IRQ */ callbackRequestProcessCallback(&dpvt_ps->cb_s, priorityHigh, dpvt_ps->rec_p); /* If we just signalled an IRQ manually then we must not * enable interrupts (arm()) */ } } if ( intEnable ) coldfEportIntEnable(dpvt_ps->irq_pin); } /* The PAD 'getdata' callback arguments 'channels' and 'nsamples' have the following semantics: 'nsamples' is the number of samples per channel that must be transferred. The total number of transferred samples is the number of channels * nsamples. 'channels' specifies which and how many channels are to be transferred. If 'channels' == PADRPLY_STRM_NCHANNELS then all four channels need to be transferred ('nsamples' for each of them). If 'channels' is a number from 0..3 then only a single channel is read and 'nsamples' are to be transferred from the specified channel. This is because in row-major mode, if the stream needs to be fragmented then each fragment carries only samples from a single channel (even if the entire message contains samples from all channels). Hence, 'getdata' has to make sure samples from the correct channel are fetched. */ static void * getdata(void *packBuffer, int idx, int channels, int nsamples, int d32, int endianLittle, int colMajor, void *uarg) { int chmsk; assert ( 0 == ( nsamples & 1 ) ); /* We do our own thing here. The user should have requested * a single channel (i.e., nchannels gives the channel # the * user requested with the 'start stream' command). * However, we ignore that wish and demultiplex the four * channels into four 'kinds' of data. */ /* convert channel number in mask */ if ( PADRPLY_STRM_NCHANNELS == channels ) { /* If user didn't switch to single channel mode then * we still need to honor all channels */ chmsk = PADCMD_STRM_CHANNELS_ALL; } else { /* The default drvPadAdcStream_getdata() routine would * already do this for us - but that's not what we want * here... chmsk = (1<irq_pin); /* Clear interrupt here so we can detect a trigger overrun */ coldfEportFlagClr(info_ps->irq_pin); /* Check and clear CAL trigger flag */ /* gotCalt = drvPadAfeGotCalt(1); */ /* if ( -1 == gotCalt ) { static int simt=0; */ /* If no AFE is present we are in lab/simulation mode * and fake the cal triggers... */ /* if ( 3 == ++simt ) simt = 0; gotCalt = (simt != 0); } */ /* disarm by raising SW trigger * * NOTE: THIS REQUIRES THE TRIGGER INPUT BEING 'active high' * w/o this arrangement there is no way to disarm * the PAD and preserve its FIFO. * We use this triggering scheme as a workaround: * * Trigger: ---------------- ------------------ * | 10ns | | overrun * |______| |___ * * IRQ: ------------- * fifo | * full | * ______________________________| * * SW-TRIG: -------- * | * 'armed' ISR |disarmed * _____________________________________| */ trigRaise(info_ps->trig_pin); if ( (devWfPadLlrfDebug & DEBUG_IRQ) > 0 ) { epicsInterruptContextMessage(DEVSUPNAM": Interrupt\n"); } devWfPadLlrfIrqs++; epicsEventSignal(info_ps->sync); } static void set_pri(const char *nm, rtems_id tid, rtems_task_priority p) { rtems_status_code sc; rtems_task_priority old; sc = rtems_task_set_priority(tid, p, &old); if ( RTEMS_SUCCESSFUL != sc ) { rtems_error(sc,"WARNING: Unable to adjust task priority for '%s' -- may affect RT performance!\n", nm); } } static long init_record(void *record_p) { waveformRecord *waveform_ps = record_p; DevWfPadDpvt_tps dpvt_ps; char rarm_name[100]; int edge = IRQ_EDGE; rtems_id tid; rtems_status_code sc; /* Check DB configuration */ if ( waveform_ps->nelm & 3 ) { errlogPrintf(DEVSUPNAM": Warning -- NELM should be a multiple of four, truncating\n"); waveform_ps->nelm &= ~3; if ( ! waveform_ps->nelm ) { errlogPrintf(DEVSUPNAM": Error -- NELM zero\n"); goto egress; } } if ( waveform_ps->ftvl != menuFtypeSHORT ) { errlogPrintf(DEVSUPNAM": Error -- FTVL should be SHORT (is %i)\n", waveform_ps->ftvl); goto egress; } if ( VME_IO != waveform_ps->inp.type ) { errlogPrintf(DEVSUPNAM": Error -- INP is not VME_IO (but type %i)\n", waveform_ps->inp.type); goto egress; } if ( !(dpvt_ps = waveform_ps->dpvt = malloc(sizeof(*dpvt_ps))) ) { errlogPrintf(DEVSUPNAM": No memory to allocate DPVT\n"); waveform_ps->pact = 1; return -1; } dpvt_ps->rec_p = waveform_ps; dpvt_ps->irq_pin = drvPadLlrfIrqPin; dpvt_ps->trig_pin = drvPadLlrfTrigPin; dpvt_ps->irq = 0; dpvt_ps->orarm = waveform_ps->rarm; dpvt_ps->nusr = waveform_ps->nelm; if ( ! (dpvt_ps->sync = epicsEventCreate(0)) ) { errlogPrintf(DEVSUPNAM": Unable to create EPICS event\n"); waveform_ps->pact = 1; return -1; } if ( devWfPadThread ) { errlogPrintf(DEVSUPNAM": Only ONE raw waveform record can be present\n"); waveform_ps->pact = 1; return -1; } /* Start task that does the interrupt work */ devWfPadThread = epicsThreadCreate( "padT", epicsThreadPriorityMax, epicsThreadGetStackSize(epicsThreadStackMedium), padThread, waveform_ps); if ( 0 == (tid = (rtems_id)drvPadAdcStreamInit(start_stop_cb)) ) { errlogPrintf(DEVSUPNAM": Warning - no streaming mode available\n"); } /* RTEMS priorities are not a accessible to epics OSI :-( */ set_pri("padThread", (rtems_id)devWfPadThread, PAD_THREAD_PRI); set_pri("padUdpListener", tid, UDP_LISTEN_PRI); /* Ugly hack to change driver task priority; we should fix that * in lanIpBasic itself but I don't want to have to do a new * release :-( */ sc = rtems_task_ident( rtems_build_name('9','1','1','8'), RTEMS_SEARCH_ALL_NODES, &tid ); if ( sc ) { rtems_error(sc,"WARNING: Unable to determine ID of lanIpBasic driver task -- cannot readjust priority\n This may affect RT behavior!\n"); } else { set_pri("lanIpBasic", tid, LAN_IPBASIC_PRI); } strcpy(rarm_name, waveform_ps->name); strcat(rarm_name, ".RARM"); if ( dbNameToAddr(rarm_name, &dbAddrRarm) ) { errlogPrintf(DEVSUPNAM": Unable to resolve dbAddr of RARM field\n"); waveform_ps->pact = 1; return -1; } { const char *x = waveform_ps->inp.value.vmeio.parm; if ( x && strstr(x, "RowMajor") ) /* only RowMajor format supported for LLRF PADs */ dpvt_ps->readFifos = drvPadReadFifosRowMajor; } /* Setup Chip Select */ coldfCsSetup(CS1, CSELECT_FLAG_AA | CSELECT_FLAG_WS(1)); coldfEportIntDisable_inl(dpvt_ps->irq_pin); /* Setup trigger */ /* Configure eport as output, hold trigger high */ trigRaise(dpvt_ps->trig_pin); coldfEportSetup(dpvt_ps->trig_pin, EPORT_OUTPUT); /* Setup Interrupt */ /* Configure EPORT for edge interrupt; clear any pending IRQS */ coldfEportFlagClr(dpvt_ps->irq_pin); /* Special HACK -- we have a stripped-down prototype board * without any digitizer/FIFO hardware. * We can still make simulation mode work if we use a single * pin for triggering and IRQ (the trigger immediately causes * an interrupt as if there was a FIFO). * However, we must make sure we use EPORT_RAISING in this * case. */ if ( dpvt_ps->trig_pin == dpvt_ps->irq_pin ) edge = EPORT_RAISING; coldfEportSetup(dpvt_ps->irq_pin, edge); /* Special HACK -- we have a stripped-down prototype board * without any digitizer/FIFO hardware. * We can still make simulation mode work if we use a single * pin for triggering and IRQ (the trigger immediately causes * an interrupt as if there was a FIFO). * However, in that case we must make the trigger pin an output * again, AFTER setting the IRQ edge mode. */ if ( dpvt_ps->trig_pin == dpvt_ps->irq_pin ) coldfEportSetup(dpvt_ps->trig_pin, EPORT_OUTPUT); devConnectInterruptVME(64 + dpvt_ps->irq_pin, isr, dpvt_ps); if ( dpvt_ps->orarm ) { arm(dpvt_ps, dpvt_ps->orarm < 0); } errlogPrintf("Nord:%d Nusr:%d Nelem:%d\n", waveform_ps->nord,dpvt_ps->nusr,waveform_ps->nelm ); return 0; egress: waveform_ps->pact = 1; return -1; } #if 0 static long get_ioint_info(int cmd, struct dbCommon *record_ps, IOSCANPVT *pvt_ps) { DevWfPadDpvt_tps dpvt_ps = record_ps->dpvt; *pvt_ps = *dpvt_ps->scan_p; return 0; } #endif static long read_waveform(void *record_p) { waveformRecord *waveform_ps = record_p; DevWfPadDpvt_tps dpvt_ps = waveform_ps->dpvt; long rval = 0; int post = 0; uint32_t then,now; int needsArm = 0; /* Record can be processed due to a PUTF or an interrupt (or both) */ if ( devWfPadLlrfDebug & DEBUG_PROC ) { errlogPrintf("Entering READ\n"); } if (pad_debug) { errlogPrintf("arm: %d ord:%d usr:%d elem:%d post:%d\n", waveform_ps->rarm, waveform_ps->nord,dpvt_ps->nusr,waveform_ps->nelm, post ); } if ( waveform_ps->nord && waveform_ps->nord != dpvt_ps->nusr ) { unsigned long a; /* user may have resized the array (by writing an array of the * desired size to 'VAL'. * Omit setting 'nusr' if 'nord' is zero - we could have written * zero as a result of a data acq. failure. */ dpvt_ps->nusr = waveform_ps->nord; /* must always be a multiple of eight; bump up */ a = CHANNEL_NO_ALIGN(dpvt_ps->nusr); if ( a > waveform_ps->nelm ) { a = waveform_ps->nelm; } if ( a != dpvt_ps->nusr ) { waveform_ps->nord = a; /* clear excess elements */ while ( --a >= dpvt_ps->nusr ) { ((int16_t*)waveform_ps->bptr)[a] = 0; } dpvt_ps->nusr = waveform_ps->nord; } /* It seems the waveform record doesn't post monitors if users change the size * of the array. Therefore we post here anyways (whether we aligned or not). */ post |= 1; if ( pad_debug ) errlogPrintf("rarm: %d nord:%d nusr:%d nelem:%d post:%d\n", waveform_ps->rarm, waveform_ps->nord,dpvt_ps->nusr,waveform_ps->nelm, post ); } if ( dpvt_ps->irq ) { extern uint32_t Read_timer(); dpvt_ps->irq = 0; then = Read_timer(); dpvt_ps->readFifos( waveform_ps->bptr, 0, 0, dpvt_ps->nusr, 0 ); now = Read_timer(); /* if ( devWfPadLlrfDebug & DEBUG_TIMING ) errlogPrintf("Reading FIFOs took %luus\n",now-then); */ if ( coldfEportFlagClr(dpvt_ps->irq_pin) ) { errlogPrintf(DEVSUPNAM": triggering too fast\n"); recGblSetSevr(waveform_ps, SCAN_ALARM, MAJOR_ALARM); waveform_ps->nord = 0; post |= 1; rval = -1; } else { /* SUCCESS */ if ( waveform_ps->nord != dpvt_ps->nusr ) post |= 1; waveform_ps->nord = dpvt_ps->nusr; if ( pad_debug ) errlogPrintf("Rarm: %d Nord:%d Nusr:%d Nelem:%d Post:%d\n", waveform_ps->rarm, waveform_ps->nord,dpvt_ps->nusr,waveform_ps->nelm, post ); } if ( waveform_ps->rarm > 1 ) { /* auto-rearm */ needsArm = 1; } else if ( waveform_ps->rarm == -10 ) { /* special, soft-triggered simulation mode; */ needsArm = 1; waveform_ps->rarm = 10; post |= 2; } else { /* disarm (leave IRQ disabled) */ waveform_ps->rarm = dpvt_ps->orarm = 0; post |= 2; } if ( pad_debug ) errlogPrintf("RArm: %d NOrd:%d NUsr:%d NElem:%d POst:%d\n", waveform_ps->rarm, waveform_ps->nord,dpvt_ps->nusr,waveform_ps->nelm, post ); } /* handle rearm and soft trigger */ if ( dpvt_ps->orarm != waveform_ps->rarm ) { if ( devWfPadLlrfDebug & DEBUG_PROC ) errlogPrintf("RARM changed (from %i to %i)\n",dpvt_ps->orarm, waveform_ps->rarm); if ( 0 > waveform_ps->rarm ) { /* Soft Trigger */ needsArm = 2; } else { if ( waveform_ps->rarm ) { needsArm = 1; } else { disarm(dpvt_ps); } } dpvt_ps->orarm = waveform_ps->rarm; if ( pad_debug ) errlogPrintf("RARm: %d NORd:%d NUSr:%d NELem:%d POSt:%d\n", waveform_ps->rarm, waveform_ps->nord,dpvt_ps->nusr,waveform_ps->nelm, post ); } if ( needsArm ) { arm(dpvt_ps, needsArm > 1); } if (( post & 1 ) || (data_ondemand)) db_post_events(waveform_ps, &waveform_ps->nord, (DBE_VALUE|DBE_LOG)); if ( post & 2 ) db_post_events(waveform_ps, &waveform_ps->rarm, (DBE_VALUE|DBE_LOG)); if ( devWfPadLlrfDebug & DEBUG_PROC ) { errlogPrintf("Leaving READ post:%d\n",post); } if (pad_debug) { errlogPrintf("RARM: %d NORD:%d NUSR:%d NELEM:%d POST:%d\n", waveform_ps->rarm, waveform_ps->nord,dpvt_ps->nusr,waveform_ps->nelm, post ); pad_debug--; } return rval; } struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN read; } devWfPadLlrf = { 5, report, init, init_record, 0 /* get_ioint_info */, read_waveform }; epicsExportAddress(dset, devWfPadLlrf); /* Stuff below should eventually move to a separate module */ #include #include #include #include #undef DEBUG static int start_stop_cb(PadRequest req, PadStrmCommand start, void *uarg) { int old_rarm; int msk; /* We only support 16-bit, row-major and single-channel mode. */ if ( start ) { /* Check acceptable parameters */ if ( (start->flags & (PADCMD_STRM_FLAG_32 | PADCMD_STRM_FLAG_CM) ) ) { /* unsupported */ return -ENOTSUP; } /* start->channels bitmask must have exactly one bit set */ msk = (start->channels & PADCMD_STRM_CHANNELS_ALL); if ( !msk ) return -EOPNOTSUPP; while ( ! (msk &1) ) { msk >>=1 ; } msk >>= 1; /* more than 1 bit set - they request more than one channel! */ if ( msk ) return -EOPNOTSUPP; } if ( PADPROTO_VERSION3 != req->version ) { /* unrecognized version */ return -ENOTSUP; } if ( 0 == devPadWfGetRarm(&old_rarm) ) { /* * Skip all unnecessary cases * (start && already started or !start && already stopped) * * If we're in simulator mode RARM is 10 or -10 if a SW trigger * is just being processed. The 'abs' takes care of this last * special case. * */ if ( (start && abs(old_rarm) > 1) || (!start && old_rarm == 0) ) { /* nothing to do */ return 0; } } return devPadWfSetRarm(start ? 2 : 0); } int padStreamNoSpc = 0; static void padThread(void *arg) { waveformRecord *waveform_ps = arg; DevWfPadDpvt_tps dpvt_ps = waveform_ps->dpvt; int status; while (1) { epicsEventWait( dpvt_ps->sync ); if ( abs(waveform_ps->rarm) != 10 ) { /* Send channel 0 last; drvPadUdpComm initiates * record scanning when kind-0 is received. * Order of the other channels/kinds doesn't matter. */ if ( pad_debug ) { errlogPrintf("arm: %d ord:%d usr:%d elem:%d\n", waveform_ps->rarm, waveform_ps->nord,dpvt_ps->nusr,waveform_ps->nelm); pad_debug--; } if (data_ondemand) { status = data_ondemand; } else { {static int modcnt = 0; /* if ( ++modcnt == 1500 ) */ { status = padStreamSend(getdata, 3, (void*)3); if ( ( -ENOSPC == status ) ) { padStreamNoSpc++; } status = padStreamSend(getdata, 2, (void*)2); if ( ( -ENOSPC == status ) ) { padStreamNoSpc++; } status = padStreamSend(getdata, 1, (void*)1); if ( ( -ENOSPC == status ) ) { padStreamNoSpc++; } status = padStreamSend(getdata, 0, (void*)0); if ( ( -ENOSPC == status ) ) { padStreamNoSpc++; status = 0; } modcnt = 0; /* isr counter increments shows pad's heartbeats. */ if (devWfPadLlrfIrqs>= PAD_MAX_INT) devWfPadLlrfIrqs= 0; } } } } /* If we can't send streaming data then * 'ordinary' record support is engaged. */ if ( status ) { dpvt_ps->irq = 1; /* signal IRQ */ if ( epicsTimeEventDeviceTime == waveform_ps->tse ) { #ifdef BASE_HAS_NO_NTP_PATCH struct ntptimeval ntv; if ( 0 == ntp_gettime(&ntv) ) { #ifdef NTP_NANO epicsTimeFromTimespec(&waveform_ps->time, &ntv.time); #else epicsTimeFromTimeval(&waveform_ps->time, &ntv.time); #endif } else #endif epicsTimeGetEvent(&waveform_ps->time, epicsTimeEventCurrentTime); } /* stream not active; process record */ callbackRequestProcessCallback(&dpvt_ps->cb_s, priorityHigh, dpvt_ps->rec_p); } else { /* Clear interrupt here so we can detect a trigger overrun */ coldfEportFlagClr(dpvt_ps->irq_pin); /* release trigger pin */ coldfEportEpdrSet(dpvt_ps->trig_pin, 0); coldfEportIntEnable(dpvt_ps->irq_pin); } } }