AlcapDAQ  1
Functions
v1290.c File Reference
#include <stdio.h>
#include <string.h>
#include "bt617.h"
#include "v1290.h"

Go to the source code of this file.

Functions

uint16_t v1290_Read16 (MVME_INTERFACE *mvme, uint32_t base, int offset)
 
uint32_t v1290_Read32 (MVME_INTERFACE *mvme, uint32_t base, int offset)
 
void v1290_Write16 (MVME_INTERFACE *mvme, uint32_t base, int offset, uint16_t value)
 
int v1290_DataRead (MVME_INTERFACE *mvme, uint32_t base, uint32_t *pdest, int nentry)
 
int v1290_MicroWrite (MVME_INTERFACE *mvme, uint32_t base, uint16_t data)
 
int v1290_MicroRead (MVME_INTERFACE *mvme, const uint32_t base)
 
uint16_t v1290_ReadMicro (MVME_INTERFACE *mvme, const uint32_t base, uint16_t opcode)
 
void v1290_WriteMicro (MVME_INTERFACE *mvme, uint32_t base, uint16_t opcode, uint16_t data)
 
void v1290_TriggerMatchingSet (MVME_INTERFACE *mvme, uint32_t base)
 
void v1290_ContinuousSet (MVME_INTERFACE *mvme, uint32_t base)
 
int v1290_AcqModeRead (MVME_INTERFACE *mvme, uint32_t base)
 
int v1290_TriggerConfRead (MVME_INTERFACE *mvme, uint32_t base, uint16_t *conf)
 
void v1290_SetWindowWidth (MVME_INTERFACE *mvme, uint32_t base, uint16_t width)
 
void v1290_SetWindowOffset (MVME_INTERFACE *mvme, uint32_t base, int16_t offset)
 
void v1290_SetExtraMargin (MVME_INTERFACE *mvme, uint32_t base, uint16_t margin)
 
void v1290_SetRejectMargin (MVME_INTERFACE *mvme, uint32_t base, uint16_t margin)
 
void v1290_EnableTriggerSubtraction (MVME_INTERFACE *mvme, uint32_t base, bool en)
 
void v1290_SetEdgeDetection (MVME_INTERFACE *mvme, uint32_t base, uint16_t edge)
 
void v1290_SetEdgeResolution (MVME_INTERFACE *mvme, uint32_t base, uint16_t res)
 
uint16_t v1290_ReadEdgeResolution (MVME_INTERFACE *mvme, uint32_t base)
 
uint16_t v1290_ReadEdgeDetection (MVME_INTERFACE *mvme, uint32_t base)
 
void v1290_SetDeadtime (MVME_INTERFACE *mvme, uint32_t base, uint16_t deadtime)
 
uint16_t v1290_ReadDeadtime (MVME_INTERFACE *mvme, uint32_t base)
 
void v1290_EnableHeader (MVME_INTERFACE *mvme, uint32_t base, bool en)
 
bool v1290_HeaderIsEnabled (MVME_INTERFACE *mvme, uint32_t base)
 
void v1290_SetMaxHits (MVME_INTERFACE *mvme, uint32_t base, uint16_t max)
 
uint16_t v1290_ReadMaxHits (MVME_INTERFACE *mvme, uint32_t base)
 
void v1290_EnableTDCErrorMark (MVME_INTERFACE *mvme, uint32_t base, bool en)
 
void v1290_EnableBypassTDC (MVME_INTERFACE *mvme, uint32_t base, bool en)
 
void v1290_SetFIFOSize (MVME_INTERFACE *mvme, uint32_t base, uint16_t size)
 
uint16_t v1290_ReadFIFOSize (MVME_INTERFACE *mvme, uint32_t base)
 
void v1290_EnableChannel (MVME_INTERFACE *mvme, uint32_t base, uint16_t chn, bool en)
 
void v1290_EnableAllChannels (MVME_INTERFACE *mvme, uint32_t base)
 
void v1290_DisableAllChannels (MVME_INTERFACE *mvme, uint32_t base)
 
void v1290_WriteEnablePattern (MVME_INTERFACE *mvme, uint32_t base, uint16_t pattern)
 
uint16_t v1290_ReadEnablePattern (MVME_INTERFACE *mvme, uint32_t base)
 
void v1290_ReadControlRegister (MVME_INTERFACE *mvme, uint32_t base)
 
void v1290_EnableBusError (MVME_INTERFACE *mvme, uint32_t base, bool en)
 
void v1290_EnableEmptyEvent (MVME_INTERFACE *mvme, uint32_t base, bool en)
 
void v1290_EnableEventFIFO (MVME_INTERFACE *mvme, uint32_t base, bool en)
 
void v1290_ReadStatusRegister (MVME_INTERFACE *mvme, uint32_t base)
 
bool v1290_IsDataReady (MVME_INTERFACE *mvme, uint32_t base)
 
bool v1290_IsAlmostFull (MVME_INTERFACE *mvme, uint32_t base)
 
bool v1290_IsFull (MVME_INTERFACE *mvme, uint32_t base)
 
void v1290_ModuleReset (MVME_INTERFACE *mvme, uint32_t base)
 
void v1290_SoftClear (MVME_INTERFACE *mvme, uint32_t base)
 
void v1290_EventReset (MVME_INTERFACE *mvme, uint32_t base)
 
void v1290_SoftTrigger (MVME_INTERFACE *mvme, uint32_t base)
 
uint32_t v1290_ReadEventCounter (MVME_INTERFACE *mvme, uint32_t base)
 
uint16_t v1290_ReadEventStored (MVME_INTERFACE *mvme, uint32_t base)
 
void v1290_SetAlmostFullLevel (MVME_INTERFACE *mvme, uint32_t base, uint16_t level)
 
uint16_t v1290_ReadAlmostFullLevel (MVME_INTERFACE *mvme, uint32_t base, uint16_t level)
 
void v1290_FWRev (MVME_INTERFACE *mvme, uint32_t base)
 
void v1290_ReadEventFIFO (MVME_INTERFACE *mvme, uint32_t base, uint16_t *dest)
 
uint16_t v1290_ReadEventFIFOStatus (MVME_INTERFACE *mvme, uint32_t base)
 

Function Documentation

int v1290_AcqModeRead ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 148 of file v1290.c.

References MVME_DMODE_D16, mvme_get_dmode(), mvme_set_dmode(), printf(), v1290_MicroRead(), v1290_MicroWrite(), V1290_READ_ACQ_MOD_OPCODE, and value.

149 {
150  int cmode, value;
151  mvme_get_dmode(mvme, &cmode);
153  value = v1290_MicroWrite(mvme, base, V1290_READ_ACQ_MOD_OPCODE);
154  value = v1290_MicroRead(mvme, base);
155  printf("AcqMode (0 - cont., 1 - trigger matching): %X\n",value&0x1);
156  mvme_set_dmode(mvme, cmode);
157  return (value & 0x1);
158 }
void v1290_ContinuousSet ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 139 of file v1290.c.

References MVME_DMODE_D16, mvme_get_dmode(), mvme_set_dmode(), V1290_CONT_STORE_OPCODE, v1290_MicroWrite(), and value.

140 {
141  int cmode, value;
142  mvme_get_dmode(mvme, &cmode);
144  value = v1290_MicroWrite(mvme, base, V1290_CONT_STORE_OPCODE);
145  mvme_set_dmode(mvme, cmode);
146 }
int v1290_DataRead ( MVME_INTERFACE mvme,
uint32_t  base,
uint32_t *  pdest,
int  nentry 
)

Definition at line 47 of file v1290.c.

References MVME_BLT_BLT32, MVME_BLT_NONE, mvme_read(), mvme_set_am(), mvme_set_blt(), mvme_set_dmode(), status, V1290_AM, and V1290_BUFF_DW.

48 {
49  int status;
50  mvme_set_am(mvme, V1290_AM);
53  status = mvme_read(mvme, pdest, base, sizeof(uint32_t) * nentry);
55  return nentry;
56  /*
57  for (i=0 ; i<nentry ; i++) {
58  if (!v1190_DataReady(mvme, base))
59  break;
60  pdest[i] = mvme_read_value(mvme, base);
61  }
62  mvme_set_dmode(mvme, cmode);
63  return i;
64  */
65 }
void v1290_DisableAllChannels ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 344 of file v1290.c.

References MVME_DMODE_D16, mvme_get_dmode(), mvme_set_dmode(), printf(), V1290_DIS_ALL_CH_OPCODE, v1290_MicroWrite(), and value.

345 {
346  int cmode, value;
347  mvme_get_dmode(mvme, &cmode);
349  value = v1290_MicroWrite(mvme, base, V1290_DIS_ALL_CH_OPCODE);
350  printf("value: %d\n", value);
351  mvme_set_dmode(mvme, cmode);
352 }
void v1290_EnableAllChannels ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 335 of file v1290.c.

References MVME_DMODE_D16, mvme_get_dmode(), mvme_set_dmode(), V1290_EN_ALL_CH_OPCODE, v1290_MicroWrite(), and value.

336 {
337  int cmode, value;
338  mvme_get_dmode(mvme, &cmode);
340  value = v1290_MicroWrite(mvme, base, V1290_EN_ALL_CH_OPCODE);
341  mvme_set_dmode(mvme, cmode);
342 }
void v1290_EnableBusError ( MVME_INTERFACE mvme,
uint32_t  base,
bool  en 
)

Definition at line 376 of file v1290.c.

References V1290_CONTROL, v1290_Read16(), and v1290_Write16().

377 {
378  uint16_t reg = v1290_Read16(mvme, base, V1290_CONTROL);
379  if (en)
380  v1290_Write16(mvme, base, V1290_CONTROL, reg + 0x1);
381  else
382  v1290_Write16(mvme, base, V1290_CONTROL, reg & 0xfffe);
383 }
void v1290_EnableBypassTDC ( MVME_INTERFACE mvme,
uint32_t  base,
bool  en 
)

Definition at line 294 of file v1290.c.

References MVME_DMODE_D16, mvme_get_dmode(), mvme_set_dmode(), V1290_DIS_ERROR_BYPASS_OPCODE, V1290_EN_ERROR_BYPASS_OPCODE, v1290_MicroWrite(), and value.

295 {
296  int cmode, value;
297  mvme_get_dmode(mvme, &cmode);
299  uint32_t opcode;
300  if (en)
302  else
304 
305  value = v1290_MicroWrite(mvme, base, opcode);
306  mvme_set_dmode(mvme, cmode);
307 }
void v1290_EnableChannel ( MVME_INTERFACE mvme,
uint32_t  base,
uint16_t  chn,
bool  en 
)

Definition at line 319 of file v1290.c.

References MVME_DMODE_D16, mvme_get_dmode(), mvme_set_dmode(), V1290_DIS_CHANNEL_OPCODE, V1290_EN_CHANNEL_OPCODE, v1290_MicroWrite(), and value.

320 {
321  int cmode, value;
322  mvme_get_dmode(mvme, &cmode);
324  uint32_t opcode;
325  if (en)
326  opcode = V1290_EN_CHANNEL_OPCODE;
327  else
328  opcode = V1290_DIS_CHANNEL_OPCODE;
329 
330  en += chn;
331  value = v1290_MicroWrite(mvme, base, opcode);
332  mvme_set_dmode(mvme, cmode);
333 }
void v1290_EnableEmptyEvent ( MVME_INTERFACE mvme,
uint32_t  base,
bool  en 
)

Definition at line 385 of file v1290.c.

References V1290_CONTROL, v1290_Read16(), and v1290_Write16().

386 {
387  uint16_t reg = v1290_Read16(mvme, base, V1290_CONTROL);
388  if (en)
389  v1290_Write16(mvme, base, V1290_CONTROL, reg + (0x1<<3));
390  else
391  v1290_Write16(mvme, base, V1290_CONTROL, reg & (0xfff7));
392 }
void v1290_EnableEventFIFO ( MVME_INTERFACE mvme,
uint32_t  base,
bool  en 
)

Definition at line 394 of file v1290.c.

References V1290_CONTROL, v1290_Read16(), and v1290_Write16().

395 {
396  uint16_t reg = v1290_Read16(mvme, base, V1290_CONTROL);
397  if (en)
398  v1290_Write16(mvme, base, V1290_CONTROL, reg + 0x100);
399  else
400  v1290_Write16(mvme, base, V1290_CONTROL, reg & 0xfeff);
401 }
void v1290_EnableHeader ( MVME_INTERFACE mvme,
uint32_t  base,
bool  en 
)

Definition at line 249 of file v1290.c.

References MVME_DMODE_D16, mvme_get_dmode(), mvme_set_dmode(), V1290_DIS_HEAD_TRAILER_OPCODE, V1290_EN_HEAD_TRAILER_OPCODE, v1290_MicroWrite(), and value.

250 {
251  int cmode, value;
252  mvme_get_dmode(mvme, &cmode);
254  uint32_t opcode;
255  if (en)
257  else
259 
260  value = v1290_MicroWrite(mvme, base, opcode);
261  mvme_set_dmode(mvme, cmode);
262 }
void v1290_EnableTDCErrorMark ( MVME_INTERFACE mvme,
uint32_t  base,
bool  en 
)

Definition at line 279 of file v1290.c.

References MVME_DMODE_D16, mvme_get_dmode(), mvme_set_dmode(), V1290_DIS_ERROR_MARK_OPCODE, V1290_EN_ERROR_MARK_OPCODE, v1290_MicroWrite(), and value.

280 {
281  int cmode, value;
282  mvme_get_dmode(mvme, &cmode);
284  uint32_t opcode;
285  if (en)
287  else
289 
290  value = v1290_MicroWrite(mvme, base, opcode);
291  mvme_set_dmode(mvme, cmode);
292 }
void v1290_EnableTriggerSubtraction ( MVME_INTERFACE mvme,
uint32_t  base,
bool  en 
)

Definition at line 202 of file v1290.c.

References MVME_DMODE_D16, mvme_get_dmode(), mvme_set_dmode(), V1290_DIS_SUB_TRG_OPCODE, V1290_EN_SUB_TRG_OPCODE, v1290_MicroWrite(), and value.

203 {
204  int cmode, value;
205  mvme_get_dmode(mvme, &cmode);
207  uint32_t opcode;
208  if (en)
209  opcode = V1290_EN_SUB_TRG_OPCODE;
210  else
211  opcode = V1290_DIS_SUB_TRG_OPCODE;
212 
213  value = v1290_MicroWrite(mvme, base, opcode);
214  mvme_set_dmode(mvme, cmode);
215 }
void v1290_EventReset ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 453 of file v1290.c.

References V1290_SW_EVENT_RESET, and v1290_Write16().

454 {
455  v1290_Write16(mvme,base, V1290_SW_EVENT_RESET,0x1);
456 }
void v1290_FWRev ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 485 of file v1290.c.

References showbits(), V1290_FW_REV, and v1290_Read16().

486 {
487  unsigned short int reg = v1290_Read16(mvme,base, V1290_FW_REV);
488  showbits(reg);
489 }
bool v1290_HeaderIsEnabled ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 264 of file v1290.c.

References V1290_READ_HEAD_TRAILER_OPCODE, and v1290_ReadMicro().

265 {
266  return (v1290_ReadMicro(mvme, base, V1290_READ_HEAD_TRAILER_OPCODE) & 0x1);
267 }
bool v1290_IsAlmostFull ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 431 of file v1290.c.

References v1290_Read16(), and V1290_STATUS.

432 {
433  uint16_t reg = v1290_Read16(mvme, base, V1290_STATUS);
434  return (reg & (0x1<<1))>>1;
435 }
bool v1290_IsDataReady ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 425 of file v1290.c.

References v1290_Read16(), and V1290_STATUS.

426 {
427  uint16_t reg = v1290_Read16(mvme, base, V1290_STATUS);
428  return ((reg & (0x1)));
429 }
bool v1290_IsFull ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 437 of file v1290.c.

References v1290_Read16(), and V1290_STATUS.

438 {
439  uint16_t reg = v1290_Read16(mvme, base, V1290_STATUS);
440  return (reg & (0x1<<2))>>2;
441 }
int v1290_MicroRead ( MVME_INTERFACE mvme,
const uint32_t  base 
)

Definition at line 87 of file v1290.c.

References i, mvme_read_value(), mvme_set_am(), mvme_set_dmode(), V1290_AM, V1290_MICRO, V1290_MICRO_HND, V1290_MICRO_RD_OK, and V1290_REG_DW.

Referenced by v1290_AcqModeRead(), v1290_ReadMicro(), and v1290_TriggerConfRead().

88 {
89  int i;
90  int reg=-1;
91  mvme_set_am(mvme, V1290_AM);
93 
94  for (i=100; i>0; i--) {
95  uint16_t microHS = mvme_read_value(mvme, base+V1290_MICRO_HND);
96  if (microHS & V1290_MICRO_RD_OK) {
97  reg = mvme_read_value(mvme, base+V1290_MICRO);
98 // printf("i:%d microHS:%d %x\n", i, microHS, reg);
99  return (reg);
100  }
101  usleep(1);
102  };
103  return -1;
104 }
int v1290_MicroWrite ( MVME_INTERFACE mvme,
uint32_t  base,
uint16_t  data 
)

Definition at line 68 of file v1290.c.

References i, mvme_read_value(), mvme_set_am(), mvme_set_dmode(), mvme_write_value(), printf(), V1290_AM, V1290_MICRO, V1290_MICRO_HND, V1290_MICRO_WR_OK, and V1290_REG_DW.

Referenced by v1290_AcqModeRead(), v1290_ContinuousSet(), v1290_DisableAllChannels(), v1290_EnableAllChannels(), v1290_EnableBypassTDC(), v1290_EnableChannel(), v1290_EnableHeader(), v1290_EnableTDCErrorMark(), v1290_EnableTriggerSubtraction(), v1290_ReadMicro(), v1290_TriggerConfRead(), v1290_TriggerMatchingSet(), and v1290_WriteMicro().

69 {
70  int i;
71 
72  mvme_set_am(mvme, V1290_AM);
74  for (i=0; i<1000; i++)
75  {
76  uint16_t microHS = mvme_read_value(mvme, base+V1290_MICRO_HND);
77  if (microHS & V1290_MICRO_WR_OK) {
78  mvme_write_value(mvme, base+V1290_MICRO, data);
79  return 1;
80  }
81  usleep(1);
82  }
83  printf("v1290_MicroWrite: Micro not ready for writing!\n");
84  return -1;
85 }
void v1290_ModuleReset ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 443 of file v1290.c.

References V1290_MOD_RESET, and v1290_Write16().

444 {
445  v1290_Write16(mvme,base, V1290_MOD_RESET,0x1);
446 }
uint16_t v1290_Read16 ( MVME_INTERFACE mvme,
uint32_t  base,
int  offset 
)
uint32_t v1290_Read32 ( MVME_INTERFACE mvme,
uint32_t  base,
int  offset 
)

Definition at line 24 of file v1290.c.

References mvme_get_dmode(), mvme_read_value(), mvme_set_am(), mvme_set_dmode(), V1290_AM, and V1290_BUFF_DW.

Referenced by v1290_ReadEventCounter(), and v1290_ReadEventFIFO().

25 {
26  int cmode;
27  mvme_get_dmode(mvme, &cmode);
28  mvme_set_am(mvme, V1290_AM);
30  uint32_t data = mvme_read_value(mvme, base+offset);
31 
32  mvme_set_dmode(mvme, cmode);
33  return data;
34 }
uint16_t v1290_ReadAlmostFullLevel ( MVME_INTERFACE mvme,
uint32_t  base,
uint16_t  level 
)

Definition at line 479 of file v1290.c.

References V1290_ALMOST_FULL_LVL, and v1290_Read16().

481 {
482  return v1290_Read16(mvme, base, V1290_ALMOST_FULL_LVL);
483 }
void v1290_ReadControlRegister ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 365 of file v1290.c.

References printf(), V1290_CONTROL, and v1290_Read16().

366 {
367  uint16_t reg = v1290_Read16(mvme, base, V1290_CONTROL);
368  printf("Control register: 0x%X\n", V1290_CONTROL);
369  printf(" - Bus error enable: %d\n", reg & 0x1);
370  printf(" - Empty event enable: %d\n", (reg & (0x1<<3))>>3);
371  printf(" - Compensation enable: %d\n", (reg & (0x1<<5))>>5);
372  printf(" - Event FIFO enable: %d\n", (reg & (0x1<<8))>>8);
373  /*showbits(reg);*/
374 }
uint16_t v1290_ReadDeadtime ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 243 of file v1290.c.

References V1290_READ_DEAD_TIME_OPCODE, and v1290_ReadMicro().

244 {
245  return v1290_ReadMicro(mvme, base, V1290_READ_DEAD_TIME_OPCODE);
246 }
uint16_t v1290_ReadEdgeDetection ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 233 of file v1290.c.

References V1290_READ_DEAD_TIME_OPCODE, and v1290_ReadMicro().

234 {
235  return v1290_ReadMicro(mvme, base, V1290_READ_DEAD_TIME_OPCODE);
236 }
uint16_t v1290_ReadEdgeResolution ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 228 of file v1290.c.

References V1290_READ_RES_OPCODE, and v1290_ReadMicro().

229 {
230  return v1290_ReadMicro(mvme, base, V1290_READ_RES_OPCODE);
231 }
uint16_t v1290_ReadEnablePattern ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 359 of file v1290.c.

References V1290_READ_EN_PATTERN_OPCODE, and v1290_ReadMicro().

360 {
361  return (v1290_ReadMicro(mvme,base,V1290_READ_EN_PATTERN_OPCODE));
362 }
uint32_t v1290_ReadEventCounter ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 463 of file v1290.c.

References V1290_EVENT_COUNTER, and v1290_Read32().

464 {
465  return v1290_Read32(mvme, base, V1290_EVENT_COUNTER);
466 }
void v1290_ReadEventFIFO ( MVME_INTERFACE mvme,
uint32_t  base,
uint16_t *  dest 
)

Definition at line 491 of file v1290.c.

References showbits(), V1290_EVENT_FIFO, and v1290_Read32().

492 {
493  uint32_t reg = v1290_Read32(mvme, base, V1290_EVENT_FIFO);
494  showbits(reg);
495  dest[0] = reg&0xffff0000;
496  dest[1] = reg&0xffff;
497 }
uint16_t v1290_ReadEventFIFOStatus ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 499 of file v1290.c.

References V1290_EVENT_FIFO_STATUS, and v1290_Read16().

500 {
501  return (v1290_Read16(mvme, base, V1290_EVENT_FIFO_STATUS)&0x3);
502 }
uint16_t v1290_ReadEventStored ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 468 of file v1290.c.

References V1290_EVENT_STORED, and v1290_Read16().

469 {
470  return v1290_Read16(mvme, base, V1290_EVENT_STORED);
471 }
uint16_t v1290_ReadFIFOSize ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 314 of file v1290.c.

References V1290_READ_FIFO_SIZE_OPCODE, and v1290_ReadMicro().

315 {
316  return (v1290_ReadMicro(mvme, base, V1290_READ_FIFO_SIZE_OPCODE) &0x7);
317 }
uint16_t v1290_ReadMaxHits ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 274 of file v1290.c.

References V1290_READ_EVENT_SIZE_OPCODE, and v1290_ReadMicro().

275 {
276  return (v1290_ReadMicro(mvme, base, V1290_READ_EVENT_SIZE_OPCODE) &0xf);
277 }
uint16_t v1290_ReadMicro ( MVME_INTERFACE mvme,
const uint32_t  base,
uint16_t  opcode 
)

Definition at line 106 of file v1290.c.

References MVME_DMODE_D16, mvme_get_dmode(), mvme_set_dmode(), v1290_MicroRead(), v1290_MicroWrite(), and value.

Referenced by v1290_HeaderIsEnabled(), v1290_ReadDeadtime(), v1290_ReadEdgeDetection(), v1290_ReadEdgeResolution(), v1290_ReadEnablePattern(), v1290_ReadFIFOSize(), and v1290_ReadMaxHits().

108 {
109  int cmode, value;
110  mvme_get_dmode(mvme, &cmode);
112  value = v1290_MicroWrite(mvme, base, opcode);
113  value = v1290_MicroRead(mvme, base);
114  mvme_set_dmode(mvme, cmode);
115  return (uint16_t) value;
116 }
void v1290_ReadStatusRegister ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 403 of file v1290.c.

References printf(), v1290_Read16(), and V1290_STATUS.

404 {
405  uint16_t reg = v1290_Read16(mvme, base, V1290_STATUS);
406  printf("Status register: 0x%X\n", V1290_STATUS);
407  printf(" - Data ready: %d\n", reg & 0x1);
408  printf(" - Almost full: %d\n", (reg & (0x1<<1))>>1);
409  printf(" - Full: %d\n", (reg & (0x1<<2))>>2);
410  printf(" - Trigger match: %d\n", (reg & (0x1<<3))>>3);
411  printf(" - Header enable: %d\n", (reg & (0x1<<4))>>4);
412  printf(" - Term on: %d\n", (reg & (0x1<<5))>>5);
413  printf(" - Error TDC0: %d\n", (reg & (0x1<<6))>>6);
414  printf(" - Error TDC1: %d\n", (reg & (0x1<<7))>>7);
415  printf(" - Error TDC2: %d\n", (reg & (0x1<<8))>>8);
416  printf(" - Error TDC3: %d\n", (reg & (0x1<<9))>>9);
417  printf(" - Bus error: %d\n", (reg & (0x1<<10))>>10);
418  printf(" - Purged: %d\n", (reg & (0x1<<11))>>11);
419  printf(" - Res 0: %d\n", (reg & (0x1<<12))>>12);
420  printf(" - Res 1: %d\n", (reg & (0x1<<13))>>13);
421  printf(" - Pair: %d\n", (reg & (0x1<<14))>>14);
422  printf(" - Trigger lost: %d\n", (reg & (0x1<<15))>>15);
423 }
void v1290_SetAlmostFullLevel ( MVME_INTERFACE mvme,
uint32_t  base,
uint16_t  level 
)

Definition at line 473 of file v1290.c.

References V1290_ALMOST_FULL_LVL, and v1290_Write16().

475 {
476  v1290_Write16(mvme, base, V1290_ALMOST_FULL_LVL, level);
477 }
void v1290_SetDeadtime ( MVME_INTERFACE mvme,
uint32_t  base,
uint16_t  deadtime 
)

Definition at line 238 of file v1290.c.

References V1290_SET_DEAD_TIME_OPCODE, and v1290_WriteMicro().

239 {
240  v1290_WriteMicro(mvme, base, V1290_SET_DEAD_TIME_OPCODE, deadtime);
241 }
void v1290_SetEdgeDetection ( MVME_INTERFACE mvme,
uint32_t  base,
uint16_t  edge 
)

Definition at line 218 of file v1290.c.

References V1290_SET_DETECTION_OPCODE, and v1290_WriteMicro().

219 {
220  v1290_WriteMicro(mvme, base, V1290_SET_DETECTION_OPCODE, edge);
221 }
void v1290_SetEdgeResolution ( MVME_INTERFACE mvme,
uint32_t  base,
uint16_t  res 
)

Definition at line 223 of file v1290.c.

References V1290_SET_TR_LEAD_LSB_OPCODE, and v1290_WriteMicro().

224 {
226 }
void v1290_SetExtraMargin ( MVME_INTERFACE mvme,
uint32_t  base,
uint16_t  margin 
)

Definition at line 192 of file v1290.c.

References V1290_SET_SW_MARGIN_OPCODE, and v1290_WriteMicro().

193 {
194  v1290_WriteMicro(mvme, base, V1290_SET_SW_MARGIN_OPCODE, margin);
195 }
void v1290_SetFIFOSize ( MVME_INTERFACE mvme,
uint32_t  base,
uint16_t  size 
)

Definition at line 309 of file v1290.c.

References V1290_SET_FIFO_SIZE_OPCODE, and v1290_WriteMicro().

310 {
312 }
void v1290_SetMaxHits ( MVME_INTERFACE mvme,
uint32_t  base,
uint16_t  max 
)

Definition at line 269 of file v1290.c.

References V1290_SET_EVENT_SIZE_OPCODE, and v1290_WriteMicro().

270 {
272 }
void v1290_SetRejectMargin ( MVME_INTERFACE mvme,
uint32_t  base,
uint16_t  margin 
)

Definition at line 197 of file v1290.c.

References V1290_SET_REJ_MARGIN_OPCODE, and v1290_WriteMicro().

198 {
199  v1290_WriteMicro(mvme, base, V1290_SET_REJ_MARGIN_OPCODE, margin);
200 }
void v1290_SetWindowOffset ( MVME_INTERFACE mvme,
uint32_t  base,
int16_t  offset 
)

Definition at line 182 of file v1290.c.

References V1290_SET_WIN_OFFSET_OPCODE, and v1290_WriteMicro().

183 {
184  uint16_t tmp = abs(offset/25);
185  if (offset>0)
186  tmp += 0xf000;
187  else
188  tmp += 0xf800;
190 }
void v1290_SetWindowWidth ( MVME_INTERFACE mvme,
uint32_t  base,
uint16_t  width 
)

Definition at line 177 of file v1290.c.

References V1290_SET_WIN_WIDTH_OPCODE, and v1290_WriteMicro().

178 {
180 }
void v1290_SoftClear ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 448 of file v1290.c.

References V1290_SW_CLEAR, and v1290_Write16().

449 {
450  v1290_Write16(mvme,base , V1290_SW_CLEAR,0x1);
451 }
void v1290_SoftTrigger ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 458 of file v1290.c.

References V1290_SW_TRIGGER, and v1290_Write16().

459 {
460  v1290_Write16(mvme, base, V1290_SW_TRIGGER, 0x1);
461 }
int v1290_TriggerConfRead ( MVME_INTERFACE mvme,
uint32_t  base,
uint16_t *  conf 
)

Definition at line 160 of file v1290.c.

References i, MVME_DMODE_D16, mvme_get_dmode(), mvme_set_dmode(), printf(), v1290_MicroRead(), v1290_MicroWrite(), V1290_READ_TRG_CONF_OPCODE, and value.

161 {
162  int cmode, value;
163  mvme_get_dmode(mvme, &cmode);
165  value = v1290_MicroWrite(mvme, base, V1290_READ_TRG_CONF_OPCODE);
166  for (int i = 0; i < 5; ++i)
167  {
168  value = v1290_MicroRead(mvme, base);
169  printf("%x\n", (uint16_t)value);
170  *conf++ = (uint16_t)value;
171  }
172 
173  mvme_set_dmode(mvme, cmode);
174  return 0;
175 }
void v1290_TriggerMatchingSet ( MVME_INTERFACE mvme,
uint32_t  base 
)

Definition at line 130 of file v1290.c.

References MVME_DMODE_D16, mvme_get_dmode(), mvme_set_dmode(), v1290_MicroWrite(), V1290_TRG_MATCH_OPCODE, and value.

131 {
132  int cmode, value;
133  mvme_get_dmode(mvme, &cmode);
135  value = v1290_MicroWrite(mvme, base, V1290_TRG_MATCH_OPCODE);
136  mvme_set_dmode(mvme, cmode);
137 }
void v1290_Write16 ( MVME_INTERFACE mvme,
uint32_t  base,
int  offset,
uint16_t  value 
)
void v1290_WriteEnablePattern ( MVME_INTERFACE mvme,
uint32_t  base,
uint16_t  pattern 
)

Definition at line 354 of file v1290.c.

References V1290_WRITE_EN_PATTERN_OPCODE, and v1290_WriteMicro().

355 {
356  v1290_WriteMicro(mvme, base, V1290_WRITE_EN_PATTERN_OPCODE, pattern);
357 }
void v1290_WriteMicro ( MVME_INTERFACE mvme,
uint32_t  base,
uint16_t  opcode,
uint16_t  data 
)