Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line | 
|---|---|---|---|
| 186 | f9daq | 1 | #include <ansi_c.h> | 
        
| 2 | //#include <stdlib.h> | 
        ||
| 3 | //#include <stdio.h> | 
        ||
| 4 | #include "CAENV814.h" | 
        ||
| 5 | #include "CAENV814_DEF.h" | 
        ||
| 6 | #include "wienvme_dll.h" | 
        ||
| 7 | |||
| 8 | static unsigned int ModuleAddress[10];  | 
        ||
| 9 | |||
| 10 | static unsigned short m_OutputMaskEcl;  | 
        ||
| 11 | static unsigned short m_OutputMaskLevel;  | 
        ||
| 12 | static unsigned short m_InputMaskLevel;  | 
        ||
| 13 | int V814_map (int ModuleNumber,  | 
        ||
| 14 | unsigned long ModuleOffset, int print)  | 
        ||
| 15 | { | 
        ||
| 16 | unsigned short vsr, mmt, fix;  | 
        ||
| 17 | |||
| 18 | ModuleAddress[ModuleNumber] = ModuleOffset;  | 
        ||
| 19 | VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV814_FIX, &fix);  | 
        ||
| 20 | VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV814_MMT, &mmt);  | 
        ||
| 21 | VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV814_VSR, &vsr);  | 
        ||
| 22 | if (print) {  | 
        ||
| 23 | printf("CAEN V814 fixed code = 0x%04x\n", fix);  | 
        ||
| 24 | printf("CAEN V814 manufacturer number = %i\n", MANUFACTURER(mmt));  | 
        ||
| 25 | printf("CAEN V814 module type = %i\n", MODULE_TYPE(mmt));  | 
        ||
| 26 | printf("CAEN V814 version = %i\n", VERSION(vsr));  | 
        ||
| 27 | printf("CAEN V814 serial no. = %i\n", SERIAL(vsr));  | 
        ||
| 28 |   } | 
        ||
| 29 | if ((fix != CAEN_FIX_CODE) || (mmt != CAENV814_MMT_VALUE)) return -1;  | 
        ||
| 30 | return 0;  | 
        ||
| 31 | } | 
        ||
| 32 | |||
| 33 | int V814_init (int ModuleNumber, unsigned int threshold, unsigned int width, unsigned int mask)  | 
        ||
| 34 | { | 
        ||
| 35 | int ch;  | 
        ||
| 36 | V814_SetWidth( ModuleNumber, width);  | 
        ||
| 37 | |||
| 38 | for ( ch=0;ch<16;ch++) V814_SetThreshold(ModuleNumber, ch, threshold);  | 
        ||
| 39 | V814_SetEnable( ModuleNumber, mask);  | 
        ||
| 40 | V814_SetMajority( ModuleNumber, 0);  | 
        ||
| 41 |   //printf("V814_init : value of threshold   =%d\n", threshold); | 
        ||
| 42 |   //printf("V814_init : value of output width=%d\n", width); | 
        ||
| 43 |   //printf("V814_init : channels enabled mask=%04x\n", mask); | 
        ||
| 44 | |||
| 45 | return 0;  | 
        ||
| 46 | } | 
        ||
| 47 | |||
| 48 | |||
| 49 | |||
| 50 | int V814_SetThreshold(int ModuleNumber, unsigned long channel, unsigned short threshold)  | 
        ||
| 51 | { | 
        ||
| 52 | VME_A24D16_W(ModuleAddress[ModuleNumber] + channel* 0x2,&threshold);  | 
        ||
| 53 | return 0;  | 
        ||
| 54 | } | 
        ||
| 55 | |||
| 56 | int V814_SetEnable(int ModuleNumber, unsigned short mask)  | 
        ||
| 57 | { | 
        ||
| 58 | VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV814_INH,&mask);  | 
        ||
| 59 | return 0;  | 
        ||
| 60 | } | 
        ||
| 61 | |||
| 62 | |||
| 63 | int V814_SetWidth(int ModuleNumber, unsigned short wdt)  | 
        ||
| 64 | { | 
        ||
| 65 | VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV814_WDT0,&wdt);  | 
        ||
| 66 | VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV814_WDT1,&wdt);  | 
        ||
| 67 | return 0;  | 
        ||
| 68 | } | 
        ||
| 69 | |||
| 70 | int V814_SetMajority(int ModuleNumber, unsigned short majlev)  | 
        ||
| 71 | { | 
        ||
| 72 | unsigned short maj=(int)((majlev*50.-25.)/4.);  | 
        ||
| 73 | VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV814_MAJ,&maj);  | 
        ||
| 74 | return 0;  | 
        ||
| 75 | } | 
        ||
| 76 | |||
| 77 | int V814_TestPulse(int ModuleNumber)  | 
        ||
| 78 | { | 
        ||
| 79 | unsigned short maj=0;  | 
        ||
| 80 | VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV814_TST,&maj);  | 
        ||
| 81 | return 0;  | 
        ||
| 82 | } | 
        ||
| 83 | |||
| 84 |