Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 99 | f9daq | 1 | #include <stdlib.h> |
| 2 | #include <stdio.h> |
||
| 3 | #include "CAENV262.h" |
||
| 4 | #include "CAENV262_DEF.h" |
||
| 5 | #include "vme.h" |
||
| 6 | |||
| 7 | |||
| 8 | static unsigned int ModuleAddress[10]; |
||
| 9 | static unsigned short m_OutputMaskEcl; |
||
| 10 | static unsigned short m_OutputMaskLevel; |
||
| 11 | static unsigned short m_InputMaskLevel; |
||
| 12 | int _VI_FUNC V262_Map (int ModuleNumber, |
||
| 13 | unsigned long ModuleOffset, int dprint) |
||
| 14 | { |
||
| 15 | unsigned short vsr, mmt, fix; |
||
| 16 | printf("CAEN V262 offset = 0x%08x print=%d\n", ModuleOffset, dprint); |
||
| 17 | ModuleAddress[ModuleNumber] = ModuleOffset; |
||
| 18 | VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV262_FIX, &fix); |
||
| 19 | VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV262_MMT, &mmt); |
||
| 20 | VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV262_VSR, &vsr); |
||
| 21 | //if (dprint !=0) { |
||
| 22 | printf("CAEN V262 offset = 0x%08x\n", ModuleOffset); |
||
| 23 | printf("CAEN V262 fixed code = 0x%04x\n", fix); |
||
| 24 | printf("CAEN V262 manufacturer number = %i\n", MANUFACTURER(mmt)); |
||
| 25 | printf("CAEN V262 module type = %i\n", MODULE_TYPE(mmt)); |
||
| 26 | printf("CAEN V262 version = %i\n", VERSION(vsr)); |
||
| 27 | printf("CAEN V262 serial no. = %i\n", SERIAL(vsr)); |
||
| 28 | //} |
||
| 29 | if ((fix != CAEN_FIX_CODE) || (mmt != CAENV262_MMT_VALUE)) return -1; |
||
| 30 | return 0; |
||
| 31 | } |
||
| 32 | |||
| 33 | int _VI_FUNC V262_Init (int ModuleNumber) |
||
| 34 | { |
||
| 35 | m_OutputMaskEcl=0; |
||
| 36 | m_OutputMaskLevel=0; |
||
| 37 | |||
| 38 | V262_MaskOut(ModuleNumber,CAENV262_NIMOUT,m_OutputMaskLevel); |
||
| 39 | V262_MaskOut(ModuleNumber,CAENV262_ECLOUT,m_OutputMaskEcl); |
||
| 40 | |||
| 41 | |||
| 42 | m_InputMaskLevel = V262_MaskIn(ModuleNumber); |
||
| 43 | |||
| 44 | printf("V262_init : value of NIM inputs=%02x\n",m_InputMaskLevel); |
||
| 45 | |||
| 46 | return 0; |
||
| 47 | } |
||
| 48 | |||
| 49 | |||
| 50 | int _VI_FUNC V262_MaskOut(int ModuleNumber, unsigned long shft, unsigned short mask) |
||
| 51 | { |
||
| 52 | VME_A24D16_W(ModuleAddress[ModuleNumber] + shft,mask); |
||
| 53 | return 0; |
||
| 54 | } |
||
| 55 | |||
| 56 | |||
| 57 | |||
| 58 | unsigned short _VI_FUNC V262_MaskIn(int ModuleNumber) |
||
| 59 | { |
||
| 60 | unsigned long mask=0; |
||
| 61 | VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV262_NIMIN,&mask); |
||
| 62 | //printf("V262_MaskIn %04x\n", mask); |
||
| 63 | return mask; |
||
| 64 | } |
||
| 65 | |||
| 66 | |||
| 67 | int _VI_FUNC V262_LevelInput(int ModuleNumber, int input) |
||
| 68 | { |
||
| 69 | if((input < 0) || (input > 3)) return 0; |
||
| 70 | return (V262_MaskIn(ModuleNumber) & (1<<input)); |
||
| 71 | } |
||
| 72 | |||
| 73 | int _VI_FUNC V262_PulseOutput(int ModuleNumber, int output) |
||
| 74 | { |
||
| 75 | if((output < 0) || (output > 3)) return -1; |
||
| 76 | return V262_MaskOut(ModuleNumber,CAENV262_SHPOUT, 1 << output); |
||
| 77 | } |
||
| 78 | |||
| 79 | |||
| 80 | int _VI_FUNC V262_LevelOutput(int ModuleNumber, int output, int level) |
||
| 81 | { |
||
| 82 | if((output < 0) || (output > 3)) return -1; |
||
| 83 | if (level) m_OutputMaskLevel |= (1 << output); |
||
| 84 | else m_OutputMaskLevel &= ~(1 << output); |
||
| 85 | return V262_MaskOut(ModuleNumber,CAENV262_NIMOUT, m_OutputMaskLevel ); |
||
| 86 | } |
||
| 87 | |||
| 88 | int _VI_FUNC V262_EclOutput(int ModuleNumber, int output, int level) |
||
| 89 | { |
||
| 90 | if((output < 0) || (output > 16)) return -1; |
||
| 91 | if (level) m_OutputMaskEcl |= (1 << output); |
||
| 92 | else m_OutputMaskEcl &= ~(1 << output); |
||
| 93 | return V262_MaskOut(ModuleNumber,CAENV262_ECLOUT, m_OutputMaskEcl ); |
||
| 94 | } |
||
| 95 | |||
| 96 |