mrfioc2  2.3.0
Public Member Functions | List of all members
mrmDataBufTx Class Reference

#include <mrmDataBufTx.h>

Inheritance diagram for mrmDataBufTx:
Inheritance graph
[legend]
Collaboration diagram for mrmDataBufTx:
Collaboration graph
[legend]

Public Member Functions

 mrmDataBufTx (const std::string &n, volatile epicsUInt8 *bufcontrol, volatile epicsUInt8 *buffer)
 
virtual ~mrmDataBufTx ()
 
virtual void lock () const OVERRIDE FINAL
 
virtual void unlock () const OVERRIDE FINAL
 
virtual bool dataTxEnabled () const OVERRIDE FINAL
 Is card configured for buffer transmission? More...
 
virtual void dataTxEnable (bool) OVERRIDE FINAL
 
virtual bool dataRTS () const OVERRIDE FINAL
 Is card ready to send a buffer? More...
 
virtual epicsUInt32 lenMax () const OVERRIDE FINAL
 
virtual void dataSend (epicsUInt32 len, const epicsUInt8 *buf) OVERRIDE FINAL
 Transmit a byte array. More...
 
- Public Member Functions inherited from dataBufTx
 dataBufTx (const std::string &n)
 
virtual ~dataBufTx ()=0
 
- Public Member Functions inherited from mrf::ObjectInst< dataBufTx >
virtual propertyBasegetPropertyBase (const char *pname, const std::type_info &ptype)
 
virtual void visitProperties (bool(*cb)(propertyBase *, void *), void *arg)
 
- Public Member Functions inherited from mrf::Object
const std::string & name () const
 
const Objectparent () const
 
child_iterator beginChild () const
 
child_iterator endChild () const
 
template<typename P >
mrf::auto_ptr< property< P > > getProperty (const char *pname)
 

Additional Inherited Members

- Public Types inherited from mrf::Object
typedef m_obj_children_t::const_iterator child_iterator
 
typedef std::map< std::string, std::string > create_args_t
 
typedef Object *(* create_factory_t) (const std::string &name, const std::string &klass, const create_args_t &args)
 
- Static Public Member Functions inherited from mrf::ObjectInst< dataBufTx >
static int initObject ()
 
- Static Public Member Functions inherited from mrf::Object
static ObjectgetObject (const std::string &name)
 
static ObjectgetCreateObject (const std::string &name, const std::string &klass, const create_args_t &args=create_args_t())
 
static void addFactory (const std::string &klass, create_factory_t fn)
 
static void visitObjects (bool(*)(Object *, void *), void *)
 
- Protected Member Functions inherited from mrf::ObjectInst< dataBufTx >
 ObjectInst (const std::string &n)
 
 ObjectInst (const std::string &n, A &a)
 
virtual ~ObjectInst ()
 
- Protected Member Functions inherited from mrf::Object
 Object (const std::string &n, const Object *par=0)
 
virtual ~Object ()=0
 

Detailed Description

With the MRM both the EVG and the EVR have the exact same Tx control register

Definition at line 19 of file mrmDataBufTx.h.

Constructor & Destructor Documentation

◆ mrmDataBufTx()

mrmDataBufTx::mrmDataBufTx ( const std::string &  n,
volatile epicsUInt8 *  bufcontrol,
volatile epicsUInt8 *  buffer 
)

Definition at line 32 of file mrmDataBufTx.cpp.

35  :dataBufTx(n)
36  ,dataCtrl(bufcontrol)
37  ,dataBuf(buffer)
38  ,dataGuard()
39 {
40 }
dataBufTx(const std::string &n)
Definition: databuf.h:39

◆ ~mrmDataBufTx()

mrmDataBufTx::~mrmDataBufTx ( )
virtual

Definition at line 42 of file mrmDataBufTx.cpp.

43 {
44 }

Member Function Documentation

◆ dataRTS()

bool mrmDataBufTx::dataRTS ( ) const
virtual

Is card ready to send a buffer?

Implements dataBufTx.

Definition at line 68 of file mrmDataBufTx.cpp.

69 {
70  epicsUInt32 reg=nat_ioread32(dataCtrl);
71 
72  if (!(reg&(DataTxCtrl_ena|DataTxCtrl_mode)))
73  throw std::runtime_error("Buffer Tx not enabled");
74  if (reg&DataTxCtrl_done)
75  return true;
76  else if (reg&DataTxCtrl_run)
77  return false;
78  else
79  throw std::runtime_error("Buffer Tx not running or done");
80 }
#define DataTxCtrl_done
INLINE epicsUInt32 nat_ioread32(volatile void *addr)
Definition: mrfIoOpsDef.h:48
#define DataTxCtrl_run
#define DataTxCtrl_mode
#define DataTxCtrl_ena

◆ dataSend()

void mrmDataBufTx::dataSend ( epicsUInt32  len,
const epicsUInt8 *  buf 
)
virtual

Transmit a byte array.

Parameters
lenNumber of bytes to send
buf[in]Pointer to byte array to be sent

Implements dataBufTx.

Definition at line 90 of file mrmDataBufTx.cpp.

93 {
94  STATIC_ASSERT(DataTxCtrl_len_max%4==0);
95 
96  if (len > DataTxCtrl_len_max)
97  throw std::out_of_range("Tx buffer is too long");
98 
99  // len must be a multiple of 4
100  len &= DataTxCtrl_len_mask;
101 
102  SCOPED_LOCK(dataGuard);
103 
104  // Zero length
105  // Seems to be required?
107 
108  // Write 4 byte words over VME
109  epicsUInt32 index;
110  for(index=0; index<len; index+=4) {
111  be_iowrite32(&dataBuf[index], *(epicsUInt32*)(&ubuf[index]) );
112  }
113 
115 
116  // Reading flushes output queue of VME bridge
117  // Actual sending is so fast that we can use busy wait here
118  // Measurements showed that we loop up to 17 times
119  while(!(nat_ioread32(dataCtrl)&DataTxCtrl_done)) {};
120 }
#define DataTxCtrl_trig
#define DataTxCtrl_len_max
#define DataTxCtrl_done
INLINE void nat_iowrite32(volatile void *addr, epicsUInt32 val)
Definition: mrfIoOpsDef.h:55
INLINE epicsUInt32 nat_ioread32(volatile void *addr)
Definition: mrfIoOpsDef.h:48
#define be_iowrite32(A, D)
Definition: mrfIoOpsDef.h:75
#define DataTxCtrl_len_mask
#define DataTxCtrl_mode
#define DataTxCtrl_ena

◆ dataTxEnable()

void mrmDataBufTx::dataTxEnable ( bool  v)
virtual

Implements dataBufTx.

Definition at line 54 of file mrmDataBufTx.cpp.

55 {
56  SCOPED_LOCK(dataGuard);
57 
58  epicsUInt32 reg=nat_ioread32(dataCtrl);
59  epicsUInt32 mask=DataTxCtrl_ena|DataTxCtrl_mode;
60  if(v)
61  reg |= mask;
62  else
63  reg &= ~mask;
64  nat_iowrite32(dataCtrl, reg);
65 }
INLINE void nat_iowrite32(volatile void *addr, epicsUInt32 val)
Definition: mrfIoOpsDef.h:55
INLINE epicsUInt32 nat_ioread32(volatile void *addr)
Definition: mrfIoOpsDef.h:48
#define DataTxCtrl_mode
#define DataTxCtrl_ena

◆ dataTxEnabled()

bool mrmDataBufTx::dataTxEnabled ( ) const
virtual

Is card configured for buffer transmission?

Implements dataBufTx.

Definition at line 47 of file mrmDataBufTx.cpp.

48 {
49  return (nat_ioread32(dataCtrl) &
51 }
INLINE epicsUInt32 nat_ioread32(volatile void *addr)
Definition: mrfIoOpsDef.h:48
#define DataTxCtrl_mode
#define DataTxCtrl_ena

◆ lenMax()

epicsUInt32 mrmDataBufTx::lenMax ( ) const
virtual

Implements dataBufTx.

Definition at line 84 of file mrmDataBufTx.cpp.

85 {
86  return DataTxCtrl_len_max;
87 }
#define DataTxCtrl_len_max

◆ lock()

virtual void mrmDataBufTx::lock ( ) const
inlinevirtual

Implements mrf::Object.

Definition at line 29 of file mrmDataBufTx.h.

29 {};

◆ unlock()

virtual void mrmDataBufTx::unlock ( ) const
inlinevirtual

Implements mrf::Object.

Definition at line 30 of file mrmDataBufTx.h.

30 {};

The documentation for this class was generated from the following files: