AlcapDAQ  1
Macros | Functions | Variables
vmic_ttl.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/io.h>
#include "midas.h"
#include "crate.h"
#include "diag.h"
#include "odb_wrapper.h"
#include "vme.h"

Go to the source code of this file.

Macros

#define VMIC_PORT12   0x12
 
#define VMIC_PORT34   0x10
 
#define VMIC_PORT56   0x16
 
#define VMIC_PORT78   0x14
 
#define VMIC_CSRU   0x20
 
#define VMIC_CSRL   0x21
 
#define VMIC_OUTPUT_1   0x00004000
 
#define VMIC_OUTPUT_2   0x00000800
 
#define VMIC_OUTPUT_3   0x00000100
 
#define VMIC_OUTPUT_4   0x00000030
 
#define VMIC_OUTPUT_5   0x00000004
 
#define VMIC_OUTPUT_6   0x00800000
 
#define VMIC_OUTPUT_7   0x00100000
 
#define VMIC_OUTPUT_8   0x00020000
 
#define VMIC_OUTPUT_EW1   VMIC_OUTPUT_1
 
#define VMIC_OUTPUT_EW2   VMIC_OUTPUT_2
 
#define VMIC_OUTPUT_LATCH_RESET   VMIC_OUTPUT_3
 
#define VMIC_OUTPUT_CAENandCOMP   VMIC_OUTPUT_4
 
#define VMIC_OUTPUT_CRATE4   VMIC_OUTPUT_5
 
#define VMIC_OUTPUT_SOFTSTOP   VMIC_OUTPUT_6
 
#define VMIC_OUTPUT_CLOCK_RESET   VMIC_OUTPUT_7
 
#define VMIC_OUTPUT_START1   (VMIC_OUTPUT_1 | VMIC_OUTPUT_4)
 
#define VMIC_OUTPUT_START2   (VMIC_OUTPUT_2 | VMIC_OUTPUT_4)
 
#define VMIC_INPUT_END_EVENT   62
 

Functions

INT vmic_ttl_init ()
 
INT vmic_ttl_start_block ()
 
INT vmic_ttl_stop_block ()
 
INT vmic_ttl_poll_live ()
 
INT cycle_ram ()
 
void vmic_set (DWORD new_value)
 
void vmic_turn_on (DWORD new_channels)
 
INT vmic_read_input (int channel)
 

Variables

struct readout_module vmic_ttl_module
 
static WORD vmic_vme_base
 
static struct vme_handlevmic_handle
 
static WORD vmic_current_low
 
static WORD vmic_current_high
 
static BOOL vmic_enabled
 

Macro Definition Documentation

#define VMIC_CSRL   0x21

Definition at line 40 of file vmic_ttl.cpp.

#define VMIC_CSRU   0x20

Definition at line 39 of file vmic_ttl.cpp.

#define VMIC_INPUT_END_EVENT   62

Definition at line 70 of file vmic_ttl.cpp.

#define VMIC_OUTPUT_1   0x00004000

Definition at line 45 of file vmic_ttl.cpp.

#define VMIC_OUTPUT_2   0x00000800

Definition at line 46 of file vmic_ttl.cpp.

#define VMIC_OUTPUT_3   0x00000100

Definition at line 47 of file vmic_ttl.cpp.

#define VMIC_OUTPUT_4   0x00000030

Definition at line 48 of file vmic_ttl.cpp.

#define VMIC_OUTPUT_5   0x00000004

Definition at line 49 of file vmic_ttl.cpp.

#define VMIC_OUTPUT_6   0x00800000

Definition at line 50 of file vmic_ttl.cpp.

#define VMIC_OUTPUT_7   0x00100000

Definition at line 51 of file vmic_ttl.cpp.

#define VMIC_OUTPUT_8   0x00020000

Definition at line 52 of file vmic_ttl.cpp.

#define VMIC_OUTPUT_CAENandCOMP   VMIC_OUTPUT_4

Definition at line 60 of file vmic_ttl.cpp.

#define VMIC_OUTPUT_CLOCK_RESET   VMIC_OUTPUT_7

Definition at line 63 of file vmic_ttl.cpp.

#define VMIC_OUTPUT_CRATE4   VMIC_OUTPUT_5

Definition at line 61 of file vmic_ttl.cpp.

#define VMIC_OUTPUT_EW1   VMIC_OUTPUT_1

Definition at line 57 of file vmic_ttl.cpp.

#define VMIC_OUTPUT_EW2   VMIC_OUTPUT_2

Definition at line 58 of file vmic_ttl.cpp.

#define VMIC_OUTPUT_LATCH_RESET   VMIC_OUTPUT_3

Definition at line 59 of file vmic_ttl.cpp.

#define VMIC_OUTPUT_SOFTSTOP   VMIC_OUTPUT_6

Definition at line 62 of file vmic_ttl.cpp.

#define VMIC_OUTPUT_START1   (VMIC_OUTPUT_1 | VMIC_OUTPUT_4)

Definition at line 64 of file vmic_ttl.cpp.

#define VMIC_OUTPUT_START2   (VMIC_OUTPUT_2 | VMIC_OUTPUT_4)

Definition at line 65 of file vmic_ttl.cpp.

#define VMIC_PORT12   0x12

Definition at line 35 of file vmic_ttl.cpp.

Referenced by vmic_read_input(), and vmic_set().

#define VMIC_PORT34   0x10

Definition at line 36 of file vmic_ttl.cpp.

Referenced by vmic_read_input(), and vmic_set().

#define VMIC_PORT56   0x16

Definition at line 37 of file vmic_ttl.cpp.

Referenced by vmic_read_input().

#define VMIC_PORT78   0x14

Definition at line 38 of file vmic_ttl.cpp.

Referenced by vmic_read_input().

Function Documentation

INT cycle_ram ( )

Definition at line 202 of file rpc_master.cpp.

References event_number.

Referenced by rpc_master_poll_dead(), rpc_master_read(), and vmic_ttl_start_block().

203 {
204  return ((event_number + 1) % 2) + 1;
205 }
INT vmic_read_input ( int  channel)

Definition at line 113 of file vmic_ttl.cpp.

References channel, status, vme_read_d16(), VMIC_PORT12, VMIC_PORT34, VMIC_PORT56, VMIC_PORT78, and vmic_vme_base.

114 {
115  short status, mask;
116 
117  int reg;
118 
119  // decide which port and bit we're reading
120  if ((channel >= 0) && (channel < 16)) {
121  reg = VMIC_PORT56;
122  mask = (1 << channel);
123  } else if ((channel >= 16) && (channel < 32)) {
124  reg = VMIC_PORT78;
125  mask = (1 << (channel-16));
126  } else if ((channel >= 32) && (channel < 48)) {
127  reg = VMIC_PORT12;
128  mask = (1 << (channel-32));
129  } else if ((channel >= 48) && (channel < 64)) {
130  reg = VMIC_PORT34;
131  mask = (1 << (channel-48));
132  }
133 
134  status = vme_read_d16(vmic_handle, vmic_vme_base | reg);
135 
136  if ((status & mask)==0) {
137  return 0;
138  } else {
139  return 1;
140  }
141 }
void vmic_set ( DWORD  new_value)

Definition at line 87 of file vmic_ttl.cpp.

References vme_write_d16(), vmic_current_high, vmic_current_low, VMIC_PORT12, VMIC_PORT34, and vmic_vme_base.

88 {
89  WORD low = new_value & 0xffff;
90  WORD high = (new_value >> 16) & 0xffff;
91 
92  if(low != vmic_current_low) {
94  vmic_current_low = low;
95  }
96 
97  if(high != vmic_current_high) {
99  vmic_current_high = high;
100  }
101 }
INT vmic_ttl_init ( )
INT vmic_ttl_poll_live ( )
INT vmic_ttl_start_block ( )
INT vmic_ttl_stop_block ( )
void vmic_turn_on ( DWORD  new_channels)

Definition at line 106 of file vmic_ttl.cpp.

References vmic_current_high, vmic_current_low, and vmic_set().

107 {
108  WORD low = vmic_current_low | (new_channels & 0xffff);
109  WORD high = vmic_current_high | ((new_channels >> 16) & 0xffff);
110  vmic_set((high << 16) | low);
111 }

Variable Documentation

WORD vmic_current_high
static

Definition at line 78 of file vmic_ttl.cpp.

Referenced by vmic_set(), and vmic_turn_on().

WORD vmic_current_low
static

Definition at line 77 of file vmic_ttl.cpp.

Referenced by vmic_set(), and vmic_turn_on().

BOOL vmic_enabled
static

Definition at line 80 of file vmic_ttl.cpp.

struct vme_handle* vmic_handle
static

Definition at line 76 of file vmic_ttl.cpp.

struct readout_module vmic_ttl_module
Initial value:
= {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
}

Definition at line 19 of file vmic_ttl.cpp.

WORD vmic_vme_base
static

Definition at line 75 of file vmic_ttl.cpp.

Referenced by vmic_read_input(), and vmic_set().