8#ifndef XRMIOCAPP_SRC_ACQ400_PERMIT_H_
9#define XRMIOCAPP_SRC_ACQ400_PERMIT_H_
11#include "acq400_asyn_common.h"
18#include <epicsGuard.h>
19#include <epicsMutex.h>
25#define MAX_ADDR (MAX_SITES+1)
28#define FIRST_AI_SITE 1
29#define FIRST_DI_SITE 5
31#define PS_PERMIT_TRG_STAT "PERMIT_TRG_STAT"
32#define PS_PERMIT_TRG_LIVE "PERMIT_TRG_LIVE"
33#define PS_PERMIT_ATD_MODE "PERMIT_ATD_MODE"
34#define PS_PERMIT_ATD_L1 "PERMIT_ATD_L1"
35#define PS_PERMIT_ATD_L2 "PERMIT_ATD_L2"
37#define PS_PERMIT_DI_CH_ACTIVE "PERMIT_DI_CH_ACTIVE"
38#define PS_PERMIT_DI_CH_VALUE "PERMIT_DI_CH_VALUE"
41#define PS_PERMIT_COMMIT "PERMIT_COMMIT"
42#define PS_PERMIT_LOCK "PERMIT_LOCK"
45 enum ATD_MODE { ATD_OFF, ATD_RISING, ATD_FALLING, ATD_INSIDE, ATD_OUTSIDE } atd_mode;
61#define MAP_LEN 0x10000
62#define DSP1_GLBASE 0x80000000
63#define DSP_TH_BASE 0xE000
64#define DSP_TH_SIZE 0x0300
66#define DSP_TH_ELEMENTS (DSP_TH_SIZE/sizeof(unsigned))
68#define L_CACHE_ELEMENTS (6*32)
77 static const unsigned MODID = 0x0000;
78 static const unsigned PCR = 0x0004;
79 static const unsigned PICR = 0x0018;
80 static const unsigned PTSITE = 0x0070;
82 static const unsigned PTLAT(
const int site) {
return 0x0100 + (site-1)*0x10; }
83 static const unsigned PTLIV(
const int site) {
return 0x0104 + (site-1)*0x10; }
86 unsigned* _get_regp(
unsigned reg);
87 unsigned get(
unsigned reg);
88 void set(
unsigned reg,
unsigned value);
89 void set_bits(
unsigned reg,
unsigned mask);
90 void clr_bits(
unsigned reg,
unsigned mask);
100 unsigned element_offset(
int site){
101 return (site-1)*0x080;
103 unsigned* th_base(
int site) {
104 return (
unsigned*)(fpga.map_base + DSP_TH_BASE + element_offset(site));
106 unsigned R_cache[DSP_TH_ELEMENTS];
107 unsigned R_cache_map[MAX_SITES];
114 void close_map(
struct FILEMAP& fm);
118 void load_site(
unsigned *dst,
unsigned** ppsrc,
int nu);
127 SITE_DEF sites[MAX_SITES+1];
129 epicsMutex L_CACHE_lock;
131 void enable(
bool en);
137 bool isActiveSite(
int site){
138 assert(site >=1 && site <= MAX_SITES);
139 return sites[site].site != 0;
143 R_cache[element_offset(site)+ch_off];
144 R_cache_map[site] |= 1<<ch_off;
148 unsigned get_permit_latch(
int site)
const;
149 unsigned get_permit_live(
int site)
const;
151 unsigned clear_permit_latch(
int site,
unsigned mask)
const;
153 bool defineSite(
int site,
bool is_ai,
int nelem);
159 epicsInt16* ai_th_pairs,
160 epicsInt32* di_pairs);
163 void _refresh_shadow_element(
unsigned offset,
unsigned lenw);
164 void refresh_shadow();
174 static std::map<int, acq400_Permit*> peers;
177 static void task_runner(
void *drvPvt);
178 virtual void shadow_task();
179 static void shadow_task_runner(
void *drvPvt);
181 int P_PERMIT_TRG_STAT;
182 int P_PERMIT_TRG_LIVE;
189 unsigned dirty_L_CACHE;
191 acq400_Permit(
const char *portName,
int site,
bool is_ai,
int nchan);
194 void check_if_fmt_event_trigger(
const FMT& fmt);
198 virtual void update_callbacks(
bool call_array_callbacks);
200 virtual void flush_L_CACHE(
void) = 0;
205 virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
206 virtual asynStatus writeUInt32Digital(asynUser *pasynUser, epicsUInt32 value, epicsUInt32 mask);
208 static void create_instance(
const char *portName,
int site,
bool is_ai,
int nchan);
defines SamplePrams, sample geometry definition struct.
define FMT receiver class
Definition acq400_Permit.h:71
void setElement(int site, int ch_off, unsigned element)
Definition acq400_Permit.h:141
void full_load(epicsInt16 *ai_th_pairs, epicsInt32 *di_pairs)
Definition acq400_Permit.cpp:141
void commit()
Definition acq400_Permit.cpp:115
unsigned status(int addr)
bool defineSite(int site, bool is_ai, int nelem)
Definition acq400_Permit.cpp:105
Definition acq400_FMT_rx.h:24
acq400_asynPortDriver(const char *portName, int maxAddr, int interfaceMask, int interruptMask, int asynFlags, int autoConnect, int priority, int stackSize)
Definition acq400_asynPortDriver.cpp:16
Definition acq400_Permit.h:44
unsigned char atd_hysteresis_pc
Definition acq400_Permit.h:48
float atd_v1
Definition acq400_Permit.h:46
float atd_v2
Definition acq400_Permit.h:47
unsigned dtd_active
Definition acq400_Permit.h:53
unsigned dtd_value
Definition acq400_Permit.h:54
Declarations for key XRM structures for internal and wire (external) use.
struct FMT_ROW FMT[FMT_ROWS]
FMT : FNAL Multicast Table.
Definition xrm_structs.h:57