Skip to content

Commit

Permalink
Add prescaler trigger for pulsers
Browse files Browse the repository at this point in the history
  • Loading branch information
ZanMaticPratnemer committed Oct 6, 2022
1 parent a8cb48d commit 789176b
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 2 deletions.
21 changes: 21 additions & 0 deletions evrApp/Db/evrpulser.db
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,24 @@ record(waveform, "$(PN)Label-I") {
field(NELM, "128")
info(autosaveFields_pass1, "VAL")
}

# Triger pulser generator by one or more prescalers
record(mbboDirect, "$(PN)PSTrig-Sel")
{
field(DTYP, "Obj Prop uint32")
field(OUT , "@OBJ=$(OBJ), PROP=PSTrig")
field(PINI, "YES")
field(NOBT, "8")
field(VAL , "0")
field(FLNK, "$(PN)PSTrig-RB")
info(autosaveFields_pass0, "RVAL")
}

record(mbbiDirect, "$(PN)PSTrig-RB")
{
field(DTYP, "Obj Prop uint32")
field(INP , "@OBJ=$(OBJ), PROP=PSTrig")
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 @@ -185,6 +185,8 @@ OBJECT_BEGIN(Pulser) {

OBJECT_PROP2("Prescaler", &Pulser::prescaler, &Pulser::setPrescaler);

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

} 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 @@ -77,6 +77,13 @@ class epicsShareClass Pulser : public mrf::ObjectInst<Pulser>
virtual void setPrescaler(epicsUInt32)=0;
/*@}*/

/**\defgroup scaler Set prescaler triggering
*/
/*@{*/
virtual epicsUInt32 psTrig() const=0;
virtual void setPSTrig(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 @@ -74,6 +74,9 @@ struct PulserFRIB : public Pulser
virtual epicsUInt32 prescaler() const { return 1u; }
virtual void setPrescaler(epicsUInt32) {}

virtual epicsUInt32 psTrig() const { return 0u; }
virtual void setPSTrig(epicsUInt32) {}

virtual bool polarityInvert() const { return false; }
virtual void setPolarityInvert(bool) {}

Expand Down
27 changes: 27 additions & 0 deletions evrMrmApp/src/drvemPulser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,33 @@ MRMPulser::setPrescaler(epicsUInt32 v)
WRITE32(owner.base, PulserScal(id), v);
}

epicsUInt32
MRMPulser::psTrig() const
{
epicsUInt32 r = 0;
for (int i = 0; i < ScalerMax; i++) {
if (READ32(owner.base, ScalerPulsTrig(i)) & (1 << id)) {
r |= 1 << i;
}
}

return r;
}

void
MRMPulser::setPSTrig(epicsUInt32 v)
{
for (int i = 0; i < ScalerMax; i++) {
epicsUInt32 t = READ32(owner.base, ScalerPulsTrig(i));
if (v & (1 << i)) {
t |= 1 << id;
} else {
t &= ~(1 << id);
}
WRITE32(owner.base, ScalerPulsTrig(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 @@ -46,6 +46,9 @@ class MRMPulser : public mrf::ObjectInst<MRMPulser, Pulser>
virtual epicsUInt32 prescaler() const OVERRIDE FINAL;
virtual void setPrescaler(epicsUInt32) OVERRIDE FINAL;

virtual epicsUInt32 psTrig() const OVERRIDE FINAL;
virtual void setPSTrig(epicsUInt32) OVERRIDE FINAL;

virtual bool polarityInvert() const OVERRIDE FINAL;
virtual void setPolarityInvert(bool) OVERRIDE FINAL;

Expand Down
5 changes: 3 additions & 2 deletions evrMrmApp/src/evrRegMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,11 @@


#define U32_ScalerN 0x100
# define ScalerMax 3
/* 0 <= N <= 2 */
# define ScalerMax 8
/* 0 <= N <= 7 */
#define U32_Scaler(N) (U32_ScalerN + (4*(N)))
# define ScalerPhasOffs_offset 0x20
#define U32_ScalerPulsTrig(N) (U32_ScalerN + 0x40 + (4*(N)))

#define U32_PulserNCtrl 0x200
#define U32_PulserNScal 0x204
Expand Down

0 comments on commit 789176b

Please sign in to comment.