From d498d6bae287886cc05bbcef9803a9ae4df1013e Mon Sep 17 00:00:00 2001 From: Zan Pratnemer Date: Fri, 7 Oct 2022 13:15:30 +0200 Subject: [PATCH] Add DBus bit trig for pulsers --- evrApp/Db/evrpulser.db | 21 +++++++++++++++++++++ evrApp/src/evr.cpp | 3 +++ evrApp/src/evr/pulser.h | 8 ++++++++ evrFRIBApp/src/evr_frib.h | 4 ++++ evrMrmApp/src/drvemPulser.cpp | 29 +++++++++++++++++++++++++++++ evrMrmApp/src/drvemPulser.h | 4 ++++ evrMrmApp/src/evrRegMap.h | 4 ++++ 7 files changed, 73 insertions(+) diff --git a/evrApp/Db/evrpulser.db b/evrApp/Db/evrpulser.db index 02b65ffd5..157ab3d6f 100644 --- a/evrApp/Db/evrpulser.db +++ b/evrApp/Db/evrpulser.db @@ -186,3 +186,24 @@ record(mbbiDirect, "$(PN)PSTrig-RB") field(NOBT, "8") info(autosaveFields_pass0, "RVAL") } + +# Trigger pulser generator by one or more DBus bits +record(mbboDirect, "$(PN)DBusTrig-Sel") +{ + field(DTYP, "Obj Prop uint32") + field(OUT , "@OBJ=$(OBJ), PROP=DBusTrig") + field(PINI, "YES") + field(NOBT, "8") + field(VAL , "0") + field(FLNK, "$(PN)DBusTrig-RB") + info(autosaveFields_pass0, "RVAL") +} + +record(mbbiDirect, "$(PN)DBusTrig-RB") +{ + field(DTYP, "Obj Prop uint32") + field(INP , "@OBJ=$(OBJ), PROP=DBusTrig") + field(PINI, "YES") + field(NOBT, "8") + info(autosaveFields_pass0, "RVAL") +} diff --git a/evrApp/src/evr.cpp b/evrApp/src/evr.cpp index ccffac259..c7291808a 100644 --- a/evrApp/src/evr.cpp +++ b/evrApp/src/evr.cpp @@ -2,6 +2,7 @@ * Copyright (c) 2010 Brookhaven Science Associates, as Operator of * Brookhaven National Laboratory. * Copyright (c) 2015 Paul Scherrer Institute (PSI), Villigen, Switzerland +* Copyright (c) 2022 Cosylab d.d. * mrfioc2 is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. \*************************************************************************/ @@ -187,6 +188,8 @@ OBJECT_BEGIN(Pulser) { OBJECT_PROP2("PSTrig", &Pulser::psTrig, &Pulser::setPSTrig); + OBJECT_PROP2("DBusTrig", &Pulser::dbusTrig, &Pulser::setDBusTrig); + } OBJECT_END(Pulser) diff --git a/evrApp/src/evr/pulser.h b/evrApp/src/evr/pulser.h index db67ab872..c43ba0543 100644 --- a/evrApp/src/evr/pulser.h +++ b/evrApp/src/evr/pulser.h @@ -1,6 +1,7 @@ /*************************************************************************\ * Copyright (c) 2010 Brookhaven Science Associates, as Operator of * Brookhaven National Laboratory. +* Copyright (c) 2022 Cosylab d.d. * mrfioc2 is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. \*************************************************************************/ @@ -84,6 +85,13 @@ class epicsShareClass Pulser : public mrf::ObjectInst virtual void setPSTrig(epicsUInt32)=0; /*@}*/ + /**\defgroup DBus Set DBus triggering + */ + /*@{*/ + virtual epicsUInt32 dbusTrig() const=0; + virtual void setDBusTrig(epicsUInt32)=0; + /*@}*/ + /**\defgroup pol Set output polarity * * Selects normal or inverted. diff --git a/evrFRIBApp/src/evr_frib.h b/evrFRIBApp/src/evr_frib.h index 05a4a4a29..cd11aeadc 100644 --- a/evrFRIBApp/src/evr_frib.h +++ b/evrFRIBApp/src/evr_frib.h @@ -1,6 +1,7 @@ /* * This software is Copyright by the Board of Trustees of Michigan * State University (c) Copyright 2017. + * Copyright (c) 2022 Cosylab d.d. * * Author: Michael Davidsaver */ @@ -77,6 +78,9 @@ struct PulserFRIB : public Pulser virtual epicsUInt32 psTrig() const { return 0u; } virtual void setPSTrig(epicsUInt32) {} + virtual epicsUInt32 dbusTrig() const { return 0u; } + virtual void setDBusTrig(epicsUInt32) {} + virtual bool polarityInvert() const { return false; } virtual void setPolarityInvert(bool) {} diff --git a/evrMrmApp/src/drvemPulser.cpp b/evrMrmApp/src/drvemPulser.cpp index 73ffb341e..8d578fd33 100644 --- a/evrMrmApp/src/drvemPulser.cpp +++ b/evrMrmApp/src/drvemPulser.cpp @@ -1,6 +1,7 @@ /*************************************************************************\ * Copyright (c) 2010 Brookhaven Science Associates, as Operator of * Brookhaven National Laboratory. +* Copyright (c) 2022 Cosylab d.d. * mrfioc2 is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. \*************************************************************************/ @@ -9,6 +10,7 @@ */ #include "evrRegMap.h" +#include "evgRegMap.h" #include "drvem.h" #include @@ -165,6 +167,33 @@ MRMPulser::setPSTrig(epicsUInt32 v) } } +epicsUInt32 +MRMPulser::dbusTrig() const +{ + epicsUInt32 r = 0; + for (int i = 0; i < evgNumDbusBit; i++) { + if (READ32(owner.base, DBusPulsTrig(i)) & (1 << id)) { + r |= 1 << i; + } + } + + return r; +} + +void +MRMPulser::setDBusTrig(epicsUInt32 v) +{ + for (int i = 0; i < evgNumDbusBit; i++) { + epicsUInt32 t = READ32(owner.base, DBusPulsTrig(i)); + if (v & (1 << i)) { + t |= 1 << id; + } else { + t &= ~(1 << id); + } + WRITE32(owner.base, DBusPulsTrig(i), t); + } +} + bool MRMPulser::polarityInvert() const { diff --git a/evrMrmApp/src/drvemPulser.h b/evrMrmApp/src/drvemPulser.h index 7f80b04ba..f3bec4710 100644 --- a/evrMrmApp/src/drvemPulser.h +++ b/evrMrmApp/src/drvemPulser.h @@ -1,6 +1,7 @@ /*************************************************************************\ * Copyright (c) 2010 Brookhaven Science Associates, as Operator of * Brookhaven National Laboratory. +* Copyright (c) 2022 Cosylab d.d. * mrfioc2 is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. \*************************************************************************/ @@ -49,6 +50,9 @@ class MRMPulser : public mrf::ObjectInst virtual epicsUInt32 psTrig() const OVERRIDE FINAL; virtual void setPSTrig(epicsUInt32) OVERRIDE FINAL; + virtual epicsUInt32 dbusTrig() const OVERRIDE FINAL; + virtual void setDBusTrig(epicsUInt32) OVERRIDE FINAL; + virtual bool polarityInvert() const OVERRIDE FINAL; virtual void setPolarityInvert(bool) OVERRIDE FINAL; diff --git a/evrMrmApp/src/evrRegMap.h b/evrMrmApp/src/evrRegMap.h index e76754e47..e852bcc0a 100755 --- a/evrMrmApp/src/evrRegMap.h +++ b/evrMrmApp/src/evrRegMap.h @@ -2,6 +2,7 @@ * Copyright (c) 2010 Brookhaven Science Associates, as Operator of * Brookhaven National Laboratory. * Copyright (c) 2015 Paul Scherrer Institute (PSI), Villigen, Switzerland +* Copyright (c) 2022 Cosylab d.d. * mrfioc2 is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. \*************************************************************************/ @@ -193,6 +194,9 @@ # define ScalerPhasOffs_offset 0x20 #define U32_ScalerPulsTrig(N) (U32_ScalerN + 0x40 + (4*(N))) +#define U32_DBusTrigN 0x180 +#define U32_DBusPulsTrig(N) (U32_DBusTrigN + (4*(N))) + #define U32_PulserNCtrl 0x200 #define U32_PulserNScal 0x204 #define U32_PulserNDely 0x208