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

Go to the source code of this file.

Macros

#define PARALLEL_PORT0   0x1150
 
#define PARALLEL_PORT1   0x1151
 

Functions

INT setPP (char, int)
 
INT parport_init ()
 
INT parport_start_block ()
 
INT parport_poll_live ()
 
INT parport_poll_dead ()
 

Variables

bool block_sig
 
static unsigned int block_nr
 
struct readout_module parport_module
 

Macro Definition Documentation

#define PARALLEL_PORT0   0x1150

Definition at line 7 of file parport_module.cpp.

Referenced by parport_init(), and setPP().

#define PARALLEL_PORT1   0x1151

Definition at line 8 of file parport_module.cpp.

Referenced by parport_poll_live().

Function Documentation

INT parport_init ( )

Definition at line 64 of file parport_module.cpp.

References block_nr, PARALLEL_PORT0, printf(), and SUCCESS.

65 {
66 
67  printf("Opening parallel port %x\t\n", PARALLEL_PORT0);
68  if (ioperm(PARALLEL_PORT0,3,1))
69  {
70  perror("PArallel POrt opening error\n");
71  return 1;
72  }
73  /*
74  int status = iopl( 3 );
75 
76  if (status < 0) {
77  diag_print(0, "Unable to get permission to access I/O ports\n");
78  }
79 
80  // turn off output
81  outb(0x1d, 0x3f2);
82  */
83 
84  block_nr = 0;
85 
86 #if 0
87  gettimeofday(&t_0,NULL);
88 #endif
89 
90  printf("Dummy master crate init\n");
91  return SUCCESS;
92 }
INT parport_poll_dead ( )

Definition at line 159 of file parport_module.cpp.

160 {
161  //printf("Send to start block\n");
162  //return FE_NEED_START;
163  return 0;
164 }
INT parport_poll_live ( )

Definition at line 130 of file parport_module.cpp.

References FE_END_BLOCK, PARALLEL_PORT1, printf(), and SUCCESS.

131 {
132 #if 0
133  struct timespec timer_now;
134  clock_gettime(CLOCK_REALTIME, &timer_now);
135  unsigned int time_elapse = (timer_now.tv_sec - timer_start.tv_sec) * 1000000000 +
136  (timer_now.tv_nsec - timer_start.tv_nsec);
137  printf("time elapse: %ld\n", time_elapse);
138  if (time_elapse > 2*1000*1000)
139  {
140  printf("end of block\n");
141  return FE_END_BLOCK;
142  }
143 #endif
144 
145  unsigned char p = inb(PARALLEL_PORT1);
146 
147 
148  if ( !(p & 0x40) )
149  {
150  printf("p=%i, 0x%x\n",p, p);
151  printf("end of block\n");
152  return FE_END_BLOCK;
153  }
154 
155 
156  return SUCCESS;
157 }
INT parport_start_block ( )

Definition at line 98 of file parport_module.cpp.

References block_nr, block_sig, printf(), setPP(), and SUCCESS.

99 {
100 
101  block_sig = true;
102 #if 0
103  clock_gettime(CLOCK_REALTIME,&timer_start);
104 #endif
105  block_nr++;
106  printf("parport_start_block %i\n",block_nr);
107  //setPP(255, 1);
108 
109  // Send reset
110  setPP(1<<1, 1);
111  setPP(0, 1);
112 
113  // start new segment
114  setPP(1, 1);
115  setPP(0, 1);
116  return SUCCESS;
117 }
INT setPP ( char  v,
int  usec 
)

Definition at line 54 of file parport_module.cpp.

References PARALLEL_PORT0.

Referenced by parport_start_block().

54  {
55 
56  outb(v,PARALLEL_PORT0);
57  //outb(v,PARALLEL_PORT1);
58 
59  return 0;
60 
61 }

Variable Documentation

unsigned int block_nr
static

Definition at line 33 of file parport_module.cpp.

Referenced by parport_init(), and parport_start_block().

bool block_sig

Definition at line 28 of file parport_module.cpp.

Referenced by parport_start_block().

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

Definition at line 35 of file parport_module.cpp.