15 #include <epicsMath.h> 36 ,shadowWaveformlength(0)
39 epicsUInt32 val=
READ32(base, OutputCMLEna(
N));
48 throw std::invalid_argument(
"Invalid CML kind");
51 for(
size_t i=0; i<NELEMENTS(shadowPattern); i++) {
53 shadowPattern[i] =
new epicsUInt32[L];
54 std::fill(shadowPattern[i], shadowPattern[i]+L, 0);
62 for(
size_t i=0; i<NELEMENTS(shadowPattern); i++)
63 delete[] shadowPattern[i];
93 throw std::out_of_range(
"Invalid CML Mode");
99 WRITE32(base, OutputCMLEna(
N), shadowEnable);
104 WRITE32(base, OutputCMLPatLength(
N), 0);
112 WRITE32(base, OutputCMLPatLength(
N), shadowWaveformlength-1);
122 WRITE32(base, OutputCMLEna(
N), shadowEnable);
138 WRITE32(base, OutputCMLEna(
N), shadowEnable);
154 WRITE32(base, OutputCMLEna(
N), shadowEnable);
170 WRITE32(base, OutputCMLEna(
N), shadowEnable);
180 return READ32(base, GTXDelay(
N))/1024.0;
187 printf(
"Delay will be set to 1024 instead of %f\n", v);
200 WRITE32(base, OutputCMLEna(
N), shadowEnable);
212 epicsUInt32 val =
READ32(base, OutputCMLCount(
N));
220 epicsUInt32 val =
READ32(base, OutputCMLCount(
N));
236 v = std::max(kind==
typeTG300?40u:20u, std::min(v, 65535u));
238 epicsUInt32 val =
READ32(base, OutputCMLCount(
N));
241 WRITE32(base, OutputCMLCount(
N), val);
247 v = std::max(kind==
typeTG300?40u:20u, std::min(v, 65535u));
249 epicsUInt32 val =
READ32(base, OutputCMLCount(
N));
252 WRITE32(base, OutputCMLCount(
N), val);
258 v = std::min(v, 65535u);
263 WRITE32(base, OutputCMLEna(
N), shadowEnable);
269 double period=1.0/(mult*owner.
clock());
277 double period=1.0/(mult*owner.
clock());
285 double period=1.0/(mult*owner.
clock());
293 double period=1.0/(mult*owner.
clock());
301 double period=1.0/(mult*owner.
clock());
309 double period=1.0/(mult*owner.
clock());
329 WRITE32(base, OutputCMLEna(
N), shadowEnable);
336 return mult*shadowWaveformlength;
356 blen = std::min(plen, blen);
359 for(epicsUInt32 i=0; i<blen; i++) {
360 size_t cmlword = (i/mult);
361 size_t cmlbit = (i%mult);
363 size_t cpuword, cpubit;
369 cpubit = 19 - cmlbit;
371 first = cmlbit==0 || cmlbit==8;
372 cpuword = 2*cmlword + (cmlbit<8 ? 0 : 1);
373 cpubit = cmlbit<8 ? 7-cmlbit : 31-(cmlbit-8);
377 val=shadowPattern[p][cpuword];
393 printf(
"Given length is not a multiple of %u (CML word size). Truncating...\n", mult);
398 throw std::out_of_range(
"Pattern is too long");
402 for(epicsUInt32 i=0; i<blen; i++) {
403 size_t cmlword = (i/mult);
404 size_t cmlbit = (i%mult);
405 size_t cpuword, cpubit;
408 cpubit = 19 - cmlbit;
410 cpuword = 2*cmlword + (cmlbit<8 ? 0 : 1);
411 cpubit = cmlbit<8 ? 7-cmlbit : 31-(cmlbit-8);
414 val|=(!!buf[i])<<cpubit;
419 shadowPattern[p][cpuword] = val;
425 shadowWaveformlength = blen/mult;
434 WRITE32(base, OutputCMLPatLength(
N), shadowWaveformlength-1);
458 throw std::logic_error(
"syncPattern: invalid state 20");
472 WRITE32(base, OutputCMLPat(
N, 1), shadowPattern[patternLow][1]);
477 WRITE32(base, OutputCMLPat(
N, 3), shadowPattern[patternRise][1]);
482 WRITE32(base, OutputCMLPat(
N, 5), shadowPattern[patternFall][1]);
487 WRITE32(base, OutputCMLPat(
N, 7), shadowPattern[patternHigh][1]);
498 for(
size_t i=0; i<shadowWaveformlength*wordlen; i++)
508 throw std::logic_error(
"syncPattern: invalid state 40");
virtual void setTimeLow(double) OVERRIDE FINAL
virtual double timeInit() const OVERRIDE FINAL
virtual void setFineDelay(double) OVERRIDE FINAL
virtual bool inReset() const OVERRIDE FINAL
virtual double timeLow() const OVERRIDE FINAL
#define READ32(base, offset)
virtual double clock() const OVERRIDE FINAL
#define OutputCMLEna_cycl
#define OutputCMLCount_mask
virtual double timeHigh() const OVERRIDE FINAL
epicsUInt32 lenPatternMax() const
#define OutputCMLEna_mode_mask
virtual epicsUInt32 countInit() const OVERRIDE FINAL
virtual void setTimeHigh(double) OVERRIDE FINAL
#define OutputCMLEna_type_203
virtual bool polarityInvert() const OVERRIDE FINAL
Trigger level.
Modular Register Map Event Receivers.
virtual epicsUInt32 countHigh() const OVERRIDE FINAL
#define OutputCMLEna_ftrig_shft
#define OutputCMLCount_low_shft
#define OutputCMLEna_ftrg
#define OutputCMLEna_mode_patt
#define OutputCMLEna_ftrig_mask
virtual double fineDelay() const OVERRIDE FINAL
delay by fraction of one event clock period. Units of sec
MRMCML(const std::string &, unsigned char, EVRMRM &, outkind, formFactor)
virtual void setTimeInit(double) OVERRIDE FINAL
virtual void setRecyclePat(bool) OVERRIDE FINAL
#define OutputCMLEna_type_300
virtual void lock() const OVERRIDE FINAL
virtual void setCountHigh(epicsUInt32) OVERRIDE FINAL
virtual void setCountLow(epicsUInt32) OVERRIDE FINAL
#define OutputCMLEna_type_mask
#define OutputCMLEna_mode_freq
virtual void power(bool) OVERRIDE FINAL
virtual void reset(bool) OVERRIDE FINAL
virtual cmlMode mode() const OVERRIDE FINAL
virtual bool recyclePat() const OVERRIDE FINAL
virtual bool enabled() const OVERRIDE FINAL
#define OutputCMLCount_high_shft
virtual void setMode(cmlMode) OVERRIDE FINAL
virtual epicsUInt32 countLow() const OVERRIDE FINAL
virtual void setCountInit(epicsUInt32) OVERRIDE FINAL
virtual void unlock() const OVERRIDE FINAL
virtual bool powered() const OVERRIDE FINAL
virtual epicsUInt32 getPattern(pattern, unsigned char *, epicsUInt32) const OVERRIDE FINAL
virtual void lock() const OVERRIDE FINAL
#define OutputCMLPatLengthMax
epicsUInt32 roundToUInt(double val, epicsUInt32 max)
virtual void setPattern(pattern, const unsigned char *, epicsUInt32) OVERRIDE FINAL
epicsUInt32 lenPattern() const
#define WRITE32(base, offset, value)
virtual void setPolarityInvert(bool) OVERRIDE FINAL
virtual void enable(bool) OVERRIDE FINAL
#define OutputCMLEna_mode_orig
virtual void unlock() const OVERRIDE FINAL