Skip to content

Commit

Permalink
Add DBus bit trig for pulsers
Browse files Browse the repository at this point in the history
  • Loading branch information
ZanMaticPratnemer authored and jerzyjamroz committed Oct 26, 2023
1 parent 06b4097 commit fd982a1
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 0 deletions.
21 changes: 21 additions & 0 deletions evrApp/Db/evrpulser.db
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,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")
}
2 changes: 2 additions & 0 deletions evrApp/src/evr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ OBJECT_BEGIN(Pulser) {

OBJECT_PROP2("PSTrig", &Pulser::psTrig, &Pulser::setPSTrig);

OBJECT_PROP2("DBusTrig", &Pulser::dbusTrig, &Pulser::setDBusTrig);

} OBJECT_END(Pulser)


Expand Down
7 changes: 7 additions & 0 deletions evrApp/src/evr/pulser.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ class epicsShareClass Pulser : public mrf::ObjectInst<Pulser>
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.
Expand Down
3 changes: 3 additions & 0 deletions evrFRIBApp/src/evr_frib.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,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) {}

Expand Down
28 changes: 28 additions & 0 deletions evrMrmApp/src/drvemPulser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

#include "evrRegMap.h"
#include "evgRegMap.h"
#include "drvem.h"

#include <stdexcept>
Expand Down Expand Up @@ -178,6 +179,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
{
Expand Down
3 changes: 3 additions & 0 deletions evrMrmApp/src/drvemPulser.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class MRMPulser : public mrf::ObjectInst<MRMPulser, Pulser>
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;

Expand Down
3 changes: 3 additions & 0 deletions evrMrmApp/src/evrRegMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,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
Expand Down

0 comments on commit fd982a1

Please sign in to comment.