forked from epics-modules/mrfioc2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
165 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/*************************************************************************\ | ||
* Copyright (c) 2022 Cosylab d.d., Ljubljana, Slovenia | ||
* mrfioc2 is distributed subject to a Software License Agreement found | ||
* in file LICENSE that is included with this distribution. | ||
\*************************************************************************/ | ||
|
||
#include "delayModuleRP.h" | ||
|
||
#include <drvem.h> | ||
#include <evrRegMap.h> | ||
|
||
#define MAX_DELAY (8.686) | ||
|
||
static inline epicsUInt32 delay2Int(double val) { | ||
if(val < 0) val = 0; | ||
if(val > MAX_DELAY) val = MAX_DELAY; | ||
return val / MAX_DELAY * 1023.0; | ||
} | ||
|
||
static inline double int2Delay(epicsUInt32 val) { | ||
return val * MAX_DELAY / 1023.0; | ||
} | ||
|
||
DelayModuleRP::DelayModuleRP(const std::string& n, EVRMRM* o, unsigned int idx) | ||
: DelayModuleEvr(n) | ||
,evr_(o) | ||
,N_(idx) | ||
{ | ||
} | ||
|
||
DelayModuleRP::~DelayModuleRP() | ||
{ | ||
} | ||
|
||
void DelayModuleRP::setDelay0(double val) | ||
{ | ||
WRITE32(evr_->base, RTMDLY(2 * N_), delay2Int(val)); | ||
} | ||
|
||
double DelayModuleRP::getDelay0() const | ||
{ | ||
return int2Delay(READ32(evr_->base, RTMDLY(2 * N_))); | ||
} | ||
|
||
void DelayModuleRP::setDelay1(double val) | ||
{ | ||
WRITE32(evr_->base, RTMDLY(2 * N_ + 1), delay2Int(val)); | ||
} | ||
|
||
double DelayModuleRP::getDelay1() const | ||
{ | ||
return int2Delay(READ32(evr_->base, RTMDLY(2 * N_ + 1))); | ||
} | ||
|
||
void DelayModuleRP::setState(bool) { | ||
|
||
} | ||
|
||
bool DelayModuleRP::enabled() const { | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/*************************************************************************\ | ||
* Copyright (c) 2015 Paul Scherrer Institute (PSI), Villigen, Switzerland | ||
* Copyright (c) 2022 Cosylab d.d., Ljubljana, Slovenia | ||
* mrfioc2 is distributed subject to a Software License Agreement found | ||
* in file LICENSE that is included with this distribution. | ||
\*************************************************************************/ | ||
#ifndef DELAYMODULERP_H | ||
#define DELAYMODULERP_H | ||
|
||
#include "evr/delay.h" | ||
|
||
#include "mrmGpio.h" | ||
|
||
|
||
class EVRMRM; | ||
|
||
class DelayModuleRP : public DelayModuleEvr | ||
{ | ||
public: | ||
DelayModuleRP(const std::string&, EVRMRM*, unsigned int); | ||
virtual ~DelayModuleRP(); | ||
|
||
/** | ||
* @brief setDelay0 Sets the delay of the output 0 in the module | ||
* @param val Delay in range of 0ns - 8.686ns. If the value is greater it will be set to maximum range value, if it is smaller it will be set to minimum range value. | ||
*/ | ||
virtual void setDelay0(double val) OVERRIDE FINAL; | ||
/** | ||
* @brief getDelay0 Returns the last set delay for the output 0 in the module | ||
* @return The delay in [ns] | ||
*/ | ||
virtual double getDelay0() const OVERRIDE FINAL; | ||
|
||
/** | ||
* @brief setDelay1 Sets the delay of the output 1 in the module | ||
* @param val Delay in range of 0ns - 8.686ns. If the value is greater it will be set to maximum range value, if it is smaller it will be set to minimum range value. | ||
*/ | ||
virtual void setDelay1(double val) OVERRIDE FINAL; | ||
/** | ||
* @brief getDelay1R eturns the last set delay for the output 1 in the module | ||
* @return The delay in [ns] | ||
*/ | ||
virtual double getDelay1() const OVERRIDE FINAL; | ||
|
||
/** | ||
* @brief setState Sets the enabled state of the delay module. If disabled, the module will output logic low on both ouputs. | ||
* @param enabled True for enabled and false for disabled | ||
*/ | ||
virtual void setState(bool enabled) OVERRIDE FINAL; | ||
/** | ||
* @brief enabled Checks if the module is enabled or not. | ||
* @return True if the module is enabled, false othwerwise. | ||
*/ | ||
virtual bool enabled() const OVERRIDE FINAL; | ||
|
||
//void set(bool a, bool b, epicsUInt16 c, epicsUInt16 d){setDelay(a,b,c,d);} | ||
|
||
private: | ||
EVRMRM* evr_; | ||
const unsigned int N_; | ||
epicsUInt16 dly0_, dly1_; | ||
|
||
// There is no locking needed, but methods must be present since there are virtual in mrf::Object class | ||
virtual void lock() const OVERRIDE FINAL {} | ||
virtual void unlock() const OVERRIDE FINAL {} | ||
}; | ||
|
||
#endif // DELAYMODULERP_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters