pflib v3.0.0-rc1-29-g3a901ac
Pretty Fine HGCROC Interaction Library
All Classes Namespaces Files Functions Variables Typedefs Pages
UIO.h
1#ifndef ZCU_UIO_H_INCLUDED
2#define ZCU_UIO_H_INCLUDED
8#include <unistd.h>
9#include <stdint.h>
10#include <string>
11
12namespace pflib {
13
14 class UIO {
15 public:
18 UIO(const std::string& dev, size_t size=4096);
19 ~UIO();
20
22 uint32_t read(size_t i) { return (i<size_)?(ptr_[i]):(0xDEADB33F); }
23
25 void write(size_t where, uint32_t what);
26
28 uint32_t readMasked(size_t where, uint32_t mask) { return (read(where)&mask)>>first_bit_set(mask); }
29
31 void writeMasked(size_t where, uint32_t mask, uint32_t val) { rmw(where,mask,(val<<first_bit_set(mask))&mask); }
32
34 void rmw(size_t where, uint32_t bits_to_modify, uint32_t newval);
35 private:
36 int first_bit_set(uint32_t mask) {
37 int i;
38 for (i=0; i<32; i++)
39 if ((mask & (1<<i))!=0) return i;
40 return 32;
41 }
42 size_t size_;
43 uint32_t* ptr_;
44 int handle_;
45 };
46}
47#endif
48
Definition UIO.h:14
void writeMasked(size_t where, uint32_t mask, uint32_t val)
write with a mask (including shifts)
Definition UIO.h:31
void write(size_t where, uint32_t what)
Write the given value to the UIO device register.
Definition UIO.cxx:33
UIO(const std::string &dev, size_t size=4096)
Open the UIO device given, mapping the amount of memory indicated.
Definition UIO.cxx:11
uint32_t readMasked(size_t where, uint32_t mask)
read with a mask (including shifts)
Definition UIO.h:28
void rmw(size_t where, uint32_t bits_to_modify, uint32_t newval)
Generate an RMW cycle (read, apply INVERSE OF MASK, apply OR)
Definition UIO.cxx:41
uint32_t read(size_t i)
Read the given word from the UIO device register space.
Definition UIO.h:22
This version of the fast control code interfaces with the CMS Fast control library which can be contr...
Definition Backend.cxx:3