34#ifndef NIDAS_DIAMOND_DMD_MMAT_H
35#define NIDAS_DIAMOND_DMD_MMAT_H
53#define MAX_DMMAT_BOARDS 4
54#define MAX_DMMAT_A2D_CHANNELS 32
55#define DMMAT_D2A_OUTPUTS_PER_BRD 4
56#define MAX_DMMAT_D2A_OUTPUTS (MAX_DMMAT_BOARDS * DMMAT_D2A_OUTPUTS_PER_BRD)
72#define DMM16AT_BOARD 0
73#define DMM32AT_BOARD 1
74#define DMM32XAT_BOARD 2
86#define DMM32DXAT_BOARD 3
94#define DMMAT_IOC_MAGIC 'd'
102#define DMMAT_A2D_GET_STATUS \
103 _IOR(DMMAT_IOC_MAGIC,0,struct DMMAT_A2D_Status)
104#define DMMAT_START _IO(DMMAT_IOC_MAGIC,1)
105#define DMMAT_STOP _IO(DMMAT_IOC_MAGIC,2)
106#define DMMAT_A2D_DO_AUTOCAL _IO(DMMAT_IOC_MAGIC,3)
109#define DMMAT_CNTR_START \
110 _IOW(DMMAT_IOC_MAGIC,4,struct DMMAT_CNTR_Config)
111#define DMMAT_CNTR_STOP _IO(DMMAT_IOC_MAGIC,5)
112#define DMMAT_CNTR_GET_STATUS \
113 _IOR(DMMAT_IOC_MAGIC,6,struct DMMAT_CNTR_Status)
121#define DMMAT_D2A_GET_NOUTPUTS \
122 _IO(DMMAT_IOC_MAGIC,7)
123#define DMMAT_D2A_GET_CONVERSION \
124 _IOR(DMMAT_IOC_MAGIC,8,struct DMMAT_D2A_Conversion)
125#define DMMAT_D2A_SET \
126 _IOW(DMMAT_IOC_MAGIC,9,struct DMMAT_D2A_Outputs)
127#define DMMAT_D2A_GET \
128 _IOR(DMMAT_IOC_MAGIC,10,struct DMMAT_D2A_Outputs)
129#define DMMAT_ADD_WAVEFORM \
130 _IOW(DMMAT_IOC_MAGIC, 11, struct D2A_Waveform)
131#define DMMAT_D2A_SET_CONFIG \
132 _IOW(DMMAT_IOC_MAGIC, 12, struct D2A_Config)
134#define DMMAT_IOC_MAXNR 12
139#define DMMAT_STATUS_A2D_BUSY 0x80
140#define DMMAT_STATUS_TIMER_INT 0x40
141#define DMMAT_STATUS_SINGLE_ENDED 0x20
142#define DMMAT_STATUS_A2D_INT 0x10
143#define DMMAT_STATUS_CHAN_MASK 0x0f
222class D2A_WaveformWrapper {
224 D2A_WaveformWrapper(
int channel,
int size): _waveform(0),
225 _csize(
sizeof(
struct D2A_Waveform) +
sizeof(_waveform->point[0]) * size)
228 _waveform->channel = channel;
229 _waveform->size = size;
232 ~D2A_WaveformWrapper() { ::free(_waveform); }
240 int c_size()
const {
return _csize; }
245 D2A_WaveformWrapper(
const D2A_WaveformWrapper&);
247 D2A_WaveformWrapper& operator=(
const D2A_WaveformWrapper&);
255#include <linux/version.h>
257#include <linux/cdev.h>
258#include <linux/device.h>
261#include <linux/workqueue.h>
263#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
264#define STRUCT_MUTEX struct mutex
266#define STRUCT_MUTEX struct semaphore
270#define DMMAT_IOPORT_WIDTH 16
285#define DMMAT_DEVICES_PER_BOARD 4
286#define DMMAT_DEVICES_A2D_MINOR 0
287#define DMMAT_DEVICES_CNTR_MINOR 1
288#define DMMAT_DEVICES_D2A_MINOR 2
289#define DMMAT_DEVICES_D2D_MINOR 3
292#define DMMAT_D2A_WAVEFORM_SIZE 1024
299#define DMMAT_CNTR_QUEUE_SIZE 16
302#define DMMAT_UNIPOLAR 0x04
303#define DMMAT_BIPOLAR 0x00
304#define DMMAT_RANGE_10V 0x08
305#define DMMAT_RANGE_5V 0x00
307#define DMMAT_GAIN_1 0x00
308#define DMMAT_GAIN_2 0x01
309#define DMMAT_GAIN_4 0x02
310#define DMMAT_GAIN_8 0x03
313#define DMMAT_CNTR1_INPUT_RATE 10000000
316#define DMMAT_8254_CNTR_0 0x00
317#define DMMAT_8254_CNTR_1 0x40
318#define DMMAT_8254_CNTR_2 0x80
319#define DMMAT_8254_RWCMD 0xc0
321#define DMMAT_8254_LATCH 0x00
322#define DMMAT_8254_RW_LS 0x10
323#define DMMAT_8254_RW_MS 0x20
324#define DMMAT_8254_RW_LS_MS 0x30
326#define DMMAT_8254_MODE_0 0x00
327#define DMMAT_8254_MODE_1 0x02
328#define DMMAT_8254_MODE_2 0x04
329#define DMMAT_8254_MODE_3 0x06
330#define DMMAT_8254_MODE_4 0x08
331#define DMMAT_8254_MODE_5 0x0a
369 unsigned long addr16;
381 unsigned long itr_status_reg;
384 unsigned long itr_ack_reg;
387 unsigned char itr_mask;
390 unsigned char ad_itr_mask;
393 unsigned char cntr_itr_mask;
396 unsigned char itr_ack_val;
399 unsigned char itr_ctrl_val;
401 struct counter12 clock12;
402 struct DMMAT_A2D* a2d;
403 struct DMMAT_CNTR* cntr;
404 struct DMMAT_D2A* d2a;
405 struct DMMAT_D2D* d2d;
411 int (*setClock1InputRate)(
struct DMMAT* brd,
int rate);
419 STRUCT_MUTEX irqreq_mutex;
429struct waveform_bh_data
455 enum a2dmode { A2D_NORMAL, A2D_WAVEFORM } mode;
458 char deviceName[2][32];
474 void (*start)(
struct DMMAT_A2D* a2d);
475 void (*stop)(
struct DMMAT_A2D* a2d);
476 int (*getFifoLevel)(
struct DMMAT_A2D* a2d);
484 int (*getA2DThreshold)(
struct DMMAT_A2D* a2d);
486 int (*getNumA2DChannels)(
struct DMMAT_A2D* a2d);
487 int (*selectA2DChannels)(
struct DMMAT_A2D* a2d);
488 int (*getConvRateSetting)(
struct DMMAT_A2D* a2d,
unsigned char* val);
489 int (*getGainSetting)(
struct DMMAT_A2D* a2d,
int gain,
int bipolar,
491 void (*resetFifo)(
struct DMMAT_A2D* a2d);
492 void (*waitForA2DSettle)(
struct DMMAT_A2D* a2d);
538 unsigned char gainConvSetting;
553 int maxFifoThreshold;
566 struct work_struct worker;
569 struct work_struct waveform_worker;
575 struct waveform_bh_data waveform_bh_data;
581 struct dsm_sample_circ_buf fifo_samples;
586 struct dsm_sample_circ_buf samples;
591 wait_queue_head_t read_queue;
596 struct sample_read_state read_state;
606 struct short_filter_info* filters;
616 int nwaveformChannels;
639 unsigned long lastWakeup;
641 struct screen_timetag_data ttdata;
646 unsigned int nLargeTimeAdj;
682 struct timer_list timer;
684 int (*start)(
struct DMMAT_CNTR* cntr);
686 void (*stop)(
struct DMMAT_CNTR* cntr);
688 unsigned int rolloverSum;
695 atomic_t shutdownTimer;
700 struct dsm_sample_circ_buf samples;
702 struct sample_read_state read_state;
704 wait_queue_head_t read_queue;
729 atomic_t waveform_running;
731 STRUCT_MUTEX waveform_mutex;
737 int (*addWaveform)(
struct DMMAT_D2A* d2a,
struct D2A_Waveform* waveform);
739 int (*loadWaveforms)(
struct DMMAT_D2A* d2a);
794 void (*start)(
struct DMMAT_D2D* d2d);
795 void (*stop)(
struct DMMAT_D2D* d2d);
int running
Definition ck_mesa.cc:61
static void stopWaveforms(struct DMMAT_D2A *d2a)
General function to stop the D2A waveform.
Definition dmd_mmat.c:2587
static int startWaveforms(struct DMMAT_D2A *d2a)
Definition dmd_mmat.c:2673
#define MAX_DMMAT_D2A_OUTPUTS
Definition dmd_mmat.h:56
#define MAX_DMMAT_A2D_CHANNELS
Definition dmd_mmat.h:54
#define DMMAT_D2A_OUTPUTS_PER_BRD
Definition dmd_mmat.h:55
dmmat_d2a_jumpers
Enumeration of supported jumper configurations for the D2A.
Definition dmd_mmat.h:150
@ DMMAT_D2A_UNI_10
Definition dmd_mmat.h:152
@ DMMAT_D2A_BI_5
Definition dmd_mmat.h:153
@ DMMAT_D2A_BI_2P5
Definition dmd_mmat.h:155
@ DMMAT_D2A_UNI_5
Definition dmd_mmat.h:151
@ DMMAT_D2A_BI_10
Definition dmd_mmat.h:154
static unsigned int ioport[MESA_4I34_MAX_NR_DEVS]
Definition mesa.c:72
static float rate
Definition sing.cc:53
static string device
Definition sing.cc:60
Structures used by D2A device to set up sending a repeated waveform.
Definition dmd_mmat.h:197
int waveformRate
D2A output rate in Hz: waveforms/sec.
Definition dmd_mmat.h:199
unsigned int fifoOverflows
Definition dmd_mmat.h:61
unsigned int fifoEmpty
Definition dmd_mmat.h:63
unsigned int fifoUnderflows
Definition dmd_mmat.h:62
unsigned int missedSamples
Definition dmd_mmat.h:60
Definition dmd_mmat.h:160
int msecPeriod
Definition dmd_mmat.h:161
Definition dmd_mmat.h:165
unsigned int irqsReceived
Definition dmd_mmat.h:167
unsigned int lostSamples
Definition dmd_mmat.h:166
Structure describing the linear relation of counts and D2A voltage.
Definition dmd_mmat.h:179
int vmax[MAX_DMMAT_D2A_OUTPUTS]
Definition dmd_mmat.h:181
int cmin[MAX_DMMAT_D2A_OUTPUTS]
Definition dmd_mmat.h:182
int cmax[MAX_DMMAT_D2A_OUTPUTS]
Definition dmd_mmat.h:183
int vmin[MAX_DMMAT_D2A_OUTPUTS]
Definition dmd_mmat.h:180
Definition dmd_mmat.h:187
int active[MAX_DMMAT_D2A_OUTPUTS]
Definition dmd_mmat.h:188
int nout
Definition dmd_mmat.h:190
int counts[MAX_DMMAT_D2A_OUTPUTS]
Definition dmd_mmat.h:189
Definition ncar_a2d_priv.h:166
dsm_sample_time_t timetag
Definition ncar_a2d_priv.h:167
short data[NUM_NCAR_A2D_CHANNELS]
Definition ncar_a2d_priv.h:170
dsm_sample_length_t length
Definition ncar_a2d_priv.h:168
unsigned int dsm_sample_length_t
length of data portion of sample.
Definition types.h:51
int dsm_sample_time_t
Depending on the module, either tenths of milliseconds, or milliseconds since 00:00 UTC today.
Definition types.h:48