Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pulser trigger with DBus bits and prescalers #61

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions evrApp/Db/evrpulser.db
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,45 @@ 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")
}

# 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")
}
4 changes: 4 additions & 0 deletions evrApp/src/evr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ OBJECT_BEGIN(Pulser) {

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

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

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

} OBJECT_END(Pulser)


Expand Down
14 changes: 14 additions & 0 deletions evrApp/src/evr/pulser.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ 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 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
6 changes: 6 additions & 0 deletions evrFRIBApp/src/evr_frib.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ 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 epicsUInt32 dbusTrig() const { return 0u; }
virtual void setDBusTrig(epicsUInt32) {}

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

Expand Down
54 changes: 54 additions & 0 deletions evrMrmApp/src/drvemPulser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,60 @@ 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);
}
}

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

return r;
}

void
MRMPulser::setDBusTrig(epicsUInt32 v)
{
for (int i = 0; i < evrNumDbusBit; 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
6 changes: 6 additions & 0 deletions evrMrmApp/src/drvemPulser.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ 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 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
10 changes: 8 additions & 2 deletions evrMrmApp/src/evrRegMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
* do this assuming 32-bit data width.
*/

#define evrNumDbusBit 8

#define U32_Status 0x000
# define Status_dbus_mask 0xff000000
# define Status_dbus_shift 24
Expand Down Expand Up @@ -190,10 +192,14 @@


#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_DBusTrigN 0x180
#define U32_DBusPulsTrig(N) (U32_DBusTrigN + (4*(N)))

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