Skip to content

Commit

Permalink
feat: MTCA EVM expanded with the Backplane and Transition Board outputs
Browse files Browse the repository at this point in the history
Merge pull request #182 from jerzyjamroz/evg-io
  • Loading branch information
jerzyjamroz authored Sep 30, 2024
2 parents 2074661 + a1cb801 commit 80d80e6
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 33 deletions.
33 changes: 29 additions & 4 deletions evgMrmApp/Db/evm-mtca-300.uv.substitutions
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,38 @@ file "evgMxc.db"
{"\$(P)Mxc7", "$(EVG):Mxc7"}
}

# Irrelevant to MTCA
# file "evgOutput.db"
# {pattern
# {P, OBJ}
# {"\$(P)OutFront0", "$(EVG):FrontOut0"}
# {"\$(P)OutFront1", "$(EVG):FrontOut1"}
# {"\$(P)OutFront2", "$(EVG):FrontOut2"}
# {"\$(P)OutFront3", "$(EVG):FrontOut3"}
# }

file "evgOutput.db"
{pattern
{P, OBJ}
{"\$(P)OutFront0", "$(EVG):FrontOut0"}
{"\$(P)OutFront1", "$(EVG):FrontOut1"}
{"\$(P)OutFront2", "$(EVG):FrontOut2"}
{"\$(P)OutFront3", "$(EVG):FrontOut3"}
{"\$(P)OutBack0", "$(EVG):BackOut0"}
{"\$(P)OutBack1", "$(EVG):BackOut1"}
{"\$(P)OutBack2", "$(EVG):BackOut2"}
{"\$(P)OutBack3", "$(EVG):BackOut3"}
{"\$(P)OutBack4", "$(EVG):BackOut4"}
{"\$(P)OutBack5", "$(EVG):BackOut5"}
{"\$(P)OutBack6", "$(EVG):BackOut6"}
{"\$(P)OutBack7", "$(EVG):BackOut7"}

{"\$(P)OutRear0", "$(EVG):RearOut0"}
{"\$(P)OutRear1", "$(EVG):RearOut1"}
{"\$(P)OutRear2", "$(EVG):RearOut2"}
{"\$(P)OutRear3", "$(EVG):RearOut3"}
{"\$(P)OutRear4", "$(EVG):RearOut4"}
{"\$(P)OutRear5", "$(EVG):RearOut5"}
{"\$(P)OutRear6", "$(EVG):RearOut6"}
{"\$(P)OutRear7", "$(EVG):RearOut7"}
{"\$(P)OutRear8", "$(EVG):RearOut8"}
{"\$(P)OutRear9", "$(EVG):RearOut9"}
}

file "mrmSoftSeq.template"
Expand Down
16 changes: 12 additions & 4 deletions evgMrmApp/src/evgInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,53 +62,61 @@ struct VMECSRID vmeEvgIDs[] = {
VMECSR_END
};

//Model , numFrontInp, numUnivInp, numRearInp, numBackInp;
static const evgMrm::Config conf_vme_evg_230 = {
"VME-EVG-230",
2,
4,
16,
0,
};

static const evgMrm::Config conf_vme_evm_300 = {
"VME-EVM-300",
3,
16,
16,
0,
};

static const evgMrm::Config conf_pci_misc = {
"Unknown PCI",
2,
4,
16,
0,
};

static const evgMrm::Config conf_cpci_evg_220 = {
"cPCI-EVG-220",
2,
4,
16,
0,
};

static const evgMrm::Config conf_cpci_evg_230 = {
"cPCI-EVG-230",
2,
4,
16,
0,
};

static const evgMrm::Config conf_cpci_evg_300 = {
"cPCI-EVG-300",
2,
4,
16,
0,
};

static const evgMrm::Config conf_mtca_evm_300 = {
"mTCA-EVM-300",
3,
16,
16,
8,
};

static bool
Expand Down Expand Up @@ -318,8 +326,8 @@ mrmEvgSetupVME (

}

printf("%s #Inputs FP:%u UV:%u RB:%u\n", conf->model, conf->numFrontInp,
conf->numUnivInp, conf->numRearInp);
printf("%s #Inputs FP:%u UV:%u TB:%u BP:%u\n", conf->model, conf->numFrontInp,
conf->numUnivInp, conf->numRearInp, conf->numBackInp);

evgMrm* evg = new evgMrm(id, conf, bus, regCpuAddr, NULL);

Expand Down Expand Up @@ -530,8 +538,8 @@ mrmEvgSetupPCI (
case PCI_DEVICE_ID_MRF_MTCA_EVM_300: conf = &conf_mtca_evm_300; break;
}

printf("%s #Inputs FP:%u UV:%u RB:%u\n", conf->model, conf->numFrontInp,
conf->numUnivInp, conf->numRearInp);
printf("%s #Inputs FP:%u UV:%u TB:%u BP:%u\n", conf->model, conf->numFrontInp,
conf->numUnivInp, conf->numRearInp, conf->numBackInp);

evgMrm* evg = new evgMrm(id, conf, bus, BAR_evg, cur);

Expand Down
3 changes: 2 additions & 1 deletion evgMrmApp/src/evgInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ enum InputType {
NoneInp = 0,
FrontInp,
UnivInp,
RearInp
RearInp,
BackInp
};

class evgInput : public mrf::ObjectInst<evgInput> {
Expand Down
47 changes: 34 additions & 13 deletions evgMrmApp/src/evgMrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <stdexcept>
#include <math.h>

#include <errlog.h>
#include <errlog.h>

#include <dbAccess.h>
#include <devSup.h>
Expand All @@ -29,8 +29,8 @@
#include "fct.h"

#include "mrf/version.h"
#include <mrfCommonIO.h>
#include <mrfCommon.h>
#include <mrfCommonIO.h>
#include <mrfCommon.h>
#include <devcsr.h>
#include <mrfcsr.h>

Expand Down Expand Up @@ -176,6 +176,13 @@ evgMrm::evgMrm(const std::string& id,
new evgInput(name.str(), i, RearInp, pReg + U32_RearInMap(i));
}

for(unsigned i = 0; i < conf->numBackInp; i++) {
std::ostringstream name;
name<<id<<":BackInp"<<i;
m_input[ std::pair<epicsUInt32, InputType>(i, BackInp) ] =
new evgInput(name.str(), i, BackInp, pReg + U32_BackInMap(i));
}

for(int i = 0; i < evgNumFrontOut; i++) {
std::ostringstream name;
name<<id<<":FrontOut"<<i;
Expand All @@ -190,8 +197,22 @@ evgMrm::evgMrm(const std::string& id,
new evgOutput(name.str(), i, UnivOut, pReg + U16_UnivOutMap(i));
}

for(int i = 0; i < evgNumBackOut; i++) {
std::ostringstream name;
name<<id<<":BackOut"<<i;
m_output[std::pair<epicsUInt32, evgOutputType>(i, BackOut)] =
new evgOutput(name.str(), i, BackOut, pReg + U16_BackOutMap(i));
}

for(int i = 0; i < evgNumRearOut; i++) {
std::ostringstream name;
name<<id<<":RearOut"<<i;
m_output[std::pair<epicsUInt32, evgOutputType>(i, RearOut)] =
new evgOutput(name.str(), i, RearOut, pReg + U16_RearOutMap(i));
}

init_cb(&irqExtInp_cb, priorityHigh, &evgMrm::process_inp_cb, this);

scanIoInit(&ioScanTimestamp);

if(busConfig.busType==busType_pci || (busConfig.busType==busType_vme && version()>=MRFVersion(2, 0, 0)))
Expand Down Expand Up @@ -242,12 +263,12 @@ void evgMrm::enableIRQ()
WRITE32(m_pReg, IrqEnable, shadowIrqEnable);
}

void
evgMrm::init_cb(CALLBACK *ptr, int priority, void(*fn)(CALLBACK*), void* valptr) {
callbackSetPriority(priority, ptr);
callbackSetCallback(fn, ptr);
callbackSetUser(valptr, ptr);
(ptr)->timer=NULL;
void
evgMrm::init_cb(CALLBACK *ptr, int priority, void(*fn)(CALLBACK*), void* valptr) {
callbackSetPriority(priority, ptr);
callbackSetCallback(fn, ptr);
callbackSetUser(valptr, ptr);
(ptr)->timer=NULL;
}

const std::string
Expand Down Expand Up @@ -429,7 +450,7 @@ evgMrm::process_inp_cb(CALLBACK *pCallback) {
}
evg->irqExtInp_queued=0;
}

evg->tsHandler();
scanIoRequest(evg->ioScanTimestamp);
}
Expand Down Expand Up @@ -478,7 +499,7 @@ evgMrm::tsHandler()
* 0x71 automatically. DBus5 must be triggered by the same 1PPS source.
* 2 - External: DBus5 generates the event 0x7d synchronized to DBus4. Events 0x70 and 0x71 are generated by an external source via DBus6 and 7 **/

void
void
evgMrm::setTSGenerator(epicsUInt16 TSGen)
{
m_TSGenerator = TSGen;
Expand Down Expand Up @@ -541,7 +562,7 @@ evgMrm::getInput(epicsUInt32 inpNum, InputType type) {
return inp;
}

epicsEvent*
epicsEvent*
evgMrm::getTimerEvent() {
return &m_timerEvent;
}
Expand Down
3 changes: 2 additions & 1 deletion evgMrmApp/src/evgMrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class evgMrm : public mrf::ObjectInst<evgMrm>,
const char *model;
unsigned numFrontInp,
numUnivInp,
numRearInp;
numRearInp,
numBackInp;
};

evgMrm(const std::string& id,
Expand Down
18 changes: 14 additions & 4 deletions evgMrmApp/src/evgOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include <iostream>
#include <stdexcept>

#include <mrfCommonIO.h>
#include <errlog.h>
#include <mrfCommon.h>
#include <mrfCommonIO.h>
#include <errlog.h>
#include <mrfCommon.h>

#include "evgRegMap.h"

Expand All @@ -15,7 +15,7 @@ mrf::ObjectInst<evgOutput>(name),
m_num(num),
m_type(type),
m_pOutReg(pOutReg) {
switch(m_type) {
switch(m_type) {
case(FrontOut):
if(m_num >= evgNumFrontOut)
throw std::runtime_error("EVG Front panel output ID out of range");
Expand All @@ -26,6 +26,16 @@ m_pOutReg(pOutReg) {
throw std::runtime_error("EVG Universal output ID out of range");
break;

case(BackOut):
if(m_num >= evgNumBackOut)
throw std::runtime_error("EVG Backplane output ID out of range");
break;

case(RearOut):
if(m_num >= evgNumRearOut)
throw std::runtime_error("EVG TB (rear) output ID out of range");
break;

default:
throw std::runtime_error("Wrong EVG Output type");
}
Expand Down
6 changes: 4 additions & 2 deletions evgMrmApp/src/evgOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
enum evgOutputType {
NoneOut = 0,
FrontOut,
UnivOut
UnivOut,
BackOut,
RearOut
};

class evgOutput : public mrf::ObjectInst<evgOutput> {
Expand All @@ -19,7 +21,7 @@ class evgOutput : public mrf::ObjectInst<evgOutput> {
/* locking done internally */
virtual void lock() const{};
virtual void unlock() const{};

void setSource(epicsUInt16);
epicsUInt16 getSource() const;

Expand Down
27 changes: 23 additions & 4 deletions evgMrmApp/src/evgRegMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,25 @@
#define U16_FrontOutMap(n) (U16_FrontOutMap_base + (2*(n)))

//=====================
// Front Panel Universal Output Mapping Register Array
// Backplane Output Mapping Register Array
//
#define U16_UnivOutMap_base 0x0440 // Front Univ Output Mapping Register
#define U16_BackOutMap_base 0x0424 // Backplane Output Port Mapping Register Offset
#define U16_BackOutMap(n) (U16_BackOutMap_base + (2*(n)))

//=====================
// Universal Output Mapping Register Array
//
#define U16_UnivOutMap_base 0x0440 // Universal Output Mapping Register
#define U16_UnivOutMap(n) (U16_UnivOutMap_base + (2*(n)))

//=====================
// Front Panel Input Mapping Registers
// Transition Board Output Mapping Register Array
//
#define U16_RearOutMap_base 0x0480 // Transition Board Output Mapping Register
#define U16_RearOutMap(n) (U16_RearOutMap_base + (2*(n)))

//=====================
// Front Panel Input Mapping Registers
//
#define U32_FrontInMap_base 0x0500 // Front Input Port Mapping Register
#define U32_FrontInMap(n) (U32_FrontInMap_base + (4*(n)))
Expand All @@ -229,6 +241,11 @@
#define U32_UnivInMap_base 0x0540 // Front Univ Input Port Mapping Register
#define U32_UnivInMap(n) (U32_UnivInMap_base + (4*(n)))

//=====================
// Backplane Input Mapping Registers
//
#define U32_BackInMap_base 0x0580 // Backplane Input Port Mapping Register
#define U32_BackInMap(n) (U32_BackInMap_base + (4*(n)))

//=====================
// Rear Universal Input Mapping Registers
Expand Down Expand Up @@ -300,7 +317,7 @@

#define EVG_EXT_INP_IRQ_ENA 0x01000000
#define EVG_INP_FP_ENA 0x0F000000
#define EVG_INP_FP_ENA_shift 24
#define EVG_INP_FP_ENA_shift 24
#define EVG_INP_FP_MASK 0xF0000000
#define EVG_INP_FP_MASK_shift 28
#define EVG_INP_MXCR_ENA 0x00008000
Expand All @@ -314,6 +331,8 @@
#define evgNumDbusBit 8
#define evgNumFrontOut 6
#define evgNumUnivOut 4
#define evgNumBackOut 8
#define evgNumRearOut 16
#define evgNumSeqRam 2
#define evgAllowedTsGitter 0.5f
#define evgEndOfSeqBuf 5
Expand Down

0 comments on commit 80d80e6

Please sign in to comment.