caenv488.c File Reference

Go to the source code of this file.

Defines

#define A24D16_V488   0xf0000000
#define INLINE
#define EXTERNAL   extern
#define VER_SER   0xFE
#define MAN_MOD   0xFC
#define FIXED_CODE   0xFA
#define HF_REG   0x1E
#define RESET_REG   0x1C
#define CTL_REG   0x1A
#define OUTB_REG   0x18
#define FF_REG   0x16
#define RR_REG   0x14
#define THRH_REG   0x12
#define THRL_REG   0x10
#define INT_REG   0x00
#define V488_CSTART   0x8000
#define V488_IE1   0x1
#define V488_IE2   0x2
#define V488_IE3   0x4
#define V488_IE4   0x8
#define V488_IE5   0x10
#define V488_IE6   0x20
#define V488_IE7   0x40
#define V488_IE8   0x80
#define V488_IE14   0xf
#define V488_IE58   0xf0
#define V488_IE18   0xff

Typedefs

typedef unsigned short int WORD
typedef unsigned long int DWORD

Functions

INLINE caenv488_HF_set (const DWORD base, const WORD mode)
INLINE caenv488_HF_get (const DWORD base, WORD *mode)
INLINE caenv488_reset (const DWORD base)
INLINE caenv488_CTL_write (const DWORD base, const WORD mode)
INLINE caenv488_CTL_read (const DWORD base, WORD *mode)
INLINE caenv488_RR_write (const DWORD base, const WORD mode)
INLINE caenv488_THRH_write (const DWORD base, const WORD mode)
INLINE caenv488_THRL_write (const DWORD base, const WORD mode)
INLINE caenv488_FF_set (const DWORD base)
INLINE caenv488_read (const DWORD base, WORD **data)
void caenv488 (void)
INLINE void caenv488_MIW (DWORD base)
INLINE void caenv488_status (DWORD base)
INLINE void caenv488_cstop_set (DWORD base)
INLINE void caenv488_cstart_set (DWORD base)
INLINE void caenv488_all_enable (DWORD base)
INLINE void caenv488_all_disable (DWORD base)
INLINE void caenv488_std_init (DWORD base)
void caenv488_outb_read (DWORD base)


Define Documentation

#define A24D16_V488   0xf0000000

Definition at line 24 of file caenv488.c.

Referenced by caenv488_CTL_read(), caenv488_CTL_write(), caenv488_FF_set(), caenv488_HF_get(), caenv488_HF_set(), caenv488_MIW(), caenv488_outb_read(), caenv488_read(), caenv488_reset(), caenv488_RR_write(), caenv488_status(), caenv488_THRH_write(), and caenv488_THRL_write().

#define CTL_REG   0x1A

Definition at line 54 of file caenv488.c.

Referenced by caenv488_CTL_read(), caenv488_CTL_write(), caenv488_MIW(), and caenv488_status().

#define EXTERNAL   extern

Definition at line 34 of file caenv488.c.

#define FF_REG   0x16

Definition at line 56 of file caenv488.c.

Referenced by caenv488_FF_set().

#define FIXED_CODE   0xFA

Definition at line 51 of file caenv488.c.

Referenced by caenv488_MIW().

#define HF_REG   0x1E

Definition at line 52 of file caenv488.c.

Referenced by caenv488_HF_get(), and caenv488_HF_set().

#define INLINE

Definition at line 31 of file caenv488.c.

#define INT_REG   0x00

Definition at line 60 of file caenv488.c.

#define MAN_MOD   0xFC

Definition at line 50 of file caenv488.c.

Referenced by caenv488_MIW().

#define OUTB_REG   0x18

Definition at line 55 of file caenv488.c.

Referenced by caenv488_outb_read(), and caenv488_read().

#define RESET_REG   0x1C

Definition at line 53 of file caenv488.c.

Referenced by caenv488_reset().

#define RR_REG   0x14

Definition at line 57 of file caenv488.c.

Referenced by caenv488_MIW(), caenv488_RR_write(), and caenv488_status().

#define THRH_REG   0x12

Definition at line 58 of file caenv488.c.

Referenced by caenv488_THRH_write().

#define THRL_REG   0x10

Definition at line 59 of file caenv488.c.

Referenced by caenv488_THRL_write().

#define V488_CSTART   0x8000

Definition at line 61 of file caenv488.c.

Referenced by caenv488_cstart_set().

#define V488_IE1   0x1

Definition at line 62 of file caenv488.c.

#define V488_IE14   0xf

Definition at line 70 of file caenv488.c.

#define V488_IE18   0xff

Definition at line 72 of file caenv488.c.

Referenced by caenv488_all_enable().

#define V488_IE2   0x2

Definition at line 63 of file caenv488.c.

#define V488_IE3   0x4

Definition at line 64 of file caenv488.c.

#define V488_IE4   0x8

Definition at line 65 of file caenv488.c.

#define V488_IE5   0x10

Definition at line 66 of file caenv488.c.

#define V488_IE58   0xf0

Definition at line 71 of file caenv488.c.

#define V488_IE6   0x20

Definition at line 67 of file caenv488.c.

#define V488_IE7   0x40

Definition at line 68 of file caenv488.c.

#define V488_IE8   0x80

Definition at line 69 of file caenv488.c.

#define VER_SER   0xFE

Definition at line 49 of file caenv488.c.

Referenced by caenv488_MIW().


Typedef Documentation

typedef unsigned long int DWORD

Definition at line 44 of file caenv488.c.

typedef unsigned short int WORD

Definition at line 39 of file caenv488.c.


Function Documentation

void caenv488 ( void   ) 

Definition at line 175 of file caenv488.c.

00176 {
00177    printf("\n CAEN V488 8ch. TDC Tool Box\n");
00178    printf("Inline : caenv488_HF_set(DWORD vmeBase);\n");
00179    printf("Inline : caenv488_HF_get(DWORD vmeBase, INT * mode);\n");
00180    printf("Inline : caenv488_reset(DWORD vmeBase);\n");
00181    printf("Inline : caenv488_CTL_write(DWORD vmeBase, WORD mode);\n");
00182    printf("Inline : caenv488_CTL_read(DWORD vmeBase, WORD * mode);\n");
00183    printf("Inline : caenv488_RR_write(DWORD vmeBase, WORD mode);\n");
00184    printf("Inline : caenv488_THRH_write(DWORD vmeBase, WORD value);\n");
00185    printf("Inline : caenv488_FF_set(DWORD vmeBase, WORD value);\n");
00186    printf("Inline : caenv488_read(DWORD vmeBase, WORD ** data);\n");
00187    printf("Test   : caenv488_MIW(DWORDS base)\n");
00188    printf("Test   : caenv488_status(DWORD base)\n");
00189    printf("Test   : caenv488_cstop_set(DWORDS base)\n");
00190    printf("Test   : caenv488_cstart_set(DWORDS base)\n");
00191    printf("Test   : caenv488_all_enable(DWORDS base)\n");
00192    printf("Test   : caenv488_all_disable(DWORDS base)\n");
00193    printf("Test   : caenv488_std_init(DWORDS base)\n");
00194    printf("Test   : caenv488_outb_read(DWORDS base)\n");
00195 }

INLINE void caenv488_all_disable ( DWORD  base  ) 

Definition at line 287 of file caenv488.c.

00288 {
00289    caenv488_CTL_write(base, 0x0);
00290 }

INLINE void caenv488_all_enable ( DWORD  base  ) 

Definition at line 282 of file caenv488.c.

Referenced by caenv488_std_init().

00283 {
00284    caenv488_CTL_write(base, V488_IE18);
00285 }

INLINE void caenv488_cstart_set ( DWORD  base  ) 

Definition at line 277 of file caenv488.c.

00278 {
00279    caenv488_CTL_write(base, V488_CSTART);
00280 }

INLINE void caenv488_cstop_set ( DWORD  base  ) 

Definition at line 268 of file caenv488.c.

00269 {
00270    WORD ctl;
00271 
00272    caenv488_CTL_read(base, &ctl);
00273    ctl &= 0x70ff;
00274    caenv488_CTL_write(base, ctl);
00275 }

INLINE caenv488_CTL_read ( const DWORD  base,
WORD mode 
)

Definition at line 113 of file caenv488.c.

Referenced by caenv488_cstop_set().

00114 {
00115    volatile WORD *spec_adr;
00116 
00117    spec_adr = (WORD *) (A24D16_V488 | base | CTL_REG);
00118    *mode = *spec_adr;
00119 }

INLINE caenv488_CTL_write ( const DWORD  base,
const WORD  mode 
)

Definition at line 102 of file caenv488.c.

Referenced by caenv488_all_disable(), caenv488_all_enable(), caenv488_cstart_set(), and caenv488_cstop_set().

00103 {
00104    volatile WORD *spec_adr;
00105    volatile WORD ctl;
00106 
00107    spec_adr = (WORD *) (A24D16_V488 | base | CTL_REG);
00108    ctl = *spec_adr;
00109    ctl |= mode & 0x80ff;
00110    *spec_adr = ctl & 0x80ff;
00111 }

INLINE caenv488_FF_set ( const DWORD  base  ) 

Definition at line 145 of file caenv488.c.

00146 {
00147    volatile WORD *spec_adr;
00148 
00149    spec_adr = (WORD *) (A24D16_V488 | base | FF_REG);
00150    *spec_adr = 0x0;
00151 }

INLINE caenv488_HF_get ( const DWORD  base,
WORD mode 
)

Definition at line 85 of file caenv488.c.

00086 {
00087    volatile WORD *spec_adr;
00088 
00089    spec_adr = (WORD *) (A24D16_V488 | base | HF_REG);
00090    *mode = *spec_adr;
00091    *mode = (*mode >> 12) & 0x1;
00092 }

INLINE caenv488_HF_set ( const DWORD  base,
const WORD  mode 
)

Definition at line 74 of file caenv488.c.

00075 {
00076    volatile WORD *spec_adr;
00077 
00078    spec_adr = (WORD *) (A24D16_V488 | base | HF_REG);
00079    if (mode)
00080       *spec_adr = 0x1 << 12;
00081    else
00082       *spec_adr = 0x0;
00083 }

INLINE void caenv488_MIW ( DWORD  base  ) 

Definition at line 197 of file caenv488.c.

00198 {
00199    volatile WORD *spec_adr;
00200    volatile WORD data;
00201 
00202    /* module */
00203    spec_adr = (WORD *) (A24D16_V488 | base | VER_SER);
00204    data = *spec_adr;
00205    printf("Version  : 0x%x - Serial#   : 0x%x\n", (data >> 12) & 0xf, data & 0xfff);
00206    spec_adr = (WORD *) (A24D16_V488 | base | MAN_MOD);
00207    data = *spec_adr;
00208    printf("Manuf.#  : 0x%x - Mod. type#: 0x%x\n", (data >> 10) & 0x3f, data & 0x3ff);
00209    spec_adr = (WORD *) (A24D16_V488 | base | FIXED_CODE);
00210    data = *spec_adr;
00211    printf("FA code  : 0x%x - F5 code  : 0x%x\n", (data >> 8) & 0xff, data & 0xff);
00212 
00213    /* RR */
00214    spec_adr = (WORD *) (A24D16_V488 | base | RR_REG);
00215    data = *spec_adr;
00216    if (data & 0x1000)
00217       printf("Mode FIFO full      - ");
00218    else
00219       printf("Mode FIFO half full - ");
00220 
00221    /* CTL */
00222    spec_adr = (WORD *) (A24D16_V488 | base | CTL_REG);
00223    data = *spec_adr;
00224    printf("Ch.enable: 0x%x \n", data & 0xff);
00225    if (data & 0x8000)
00226       printf("Common Start  - ");
00227    else
00228       printf("Common Stop   - ");
00229 
00230    if (data & 0x4000)
00231       printf("FIFO empty\n");
00232    else if (data & 0x2000)
00233       printf("FIFO Full\n");
00234    else if (data & 0x1000)
00235       printf("FIFO half full\n");
00236 }

void caenv488_outb_read ( DWORD  base  ) 

Definition at line 301 of file caenv488.c.

00302 {
00303    volatile WORD *spec_adr;
00304    volatile WORD data, header = 0;
00305 
00306    /* CTL */
00307    spec_adr = (WORD *) (A24D16_V488 | base | OUTB_REG);
00308    data = *spec_adr;
00309    for (;;) {
00310       if (data & 0x8000) {
00311          header = 1;
00312          printf("OutB header: 0x%x - ", data);
00313          printf("OutB multi : %d - event# : %d\n", ((data >> 12) & 0x7) + 1,
00314                 data & 0xfff);
00315          if (((data >> 12) & 0x7) == 0)
00316             break;
00317       } else {
00318          if (header) {
00319             header = 0;
00320             printf("OutB data  : 0x%x - ", data);
00321             printf("OutB chan. : %d - data# : %d\n", (data >> 12) & 0x7, data & 0xfff);
00322             if (((data >> 12) & 0x7) == 0)
00323                break;
00324          } else {
00325             printf("OutB data  : 0x%x - No header\n", data);
00326             break;
00327          }
00328       }
00329    }
00330 }

INLINE caenv488_read ( const DWORD  base,
WORD **  data 
)

Definition at line 153 of file caenv488.c.

00154 {
00155    volatile WORD *spec_adr;
00156    int header, mult;
00157 
00158    spec_adr = (WORD *) (A24D16_V488 | base | OUTB_REG);
00159    header = *spec_adr;
00160    if (header & 0x8000) {
00161       if ((header & 0xfff) != 1)
00162          logMsg("Event counter in V488 base:0x%x = %d", base, (header & 0xfff), 0, 0, 0,
00163                 0);
00164       else {
00165          mult = (header >> 12) & 0x7;
00166          while (mult > 0) {
00167             *((*data)++) = *spec_adr;
00168          }
00169       }
00170    } else
00171       logMsg("Event out of sequence in V488 base 0x%x", base, 0, 0, 0, 0, 0);
00172 }

INLINE caenv488_reset ( const DWORD  base  ) 

Definition at line 94 of file caenv488.c.

Referenced by caenv488_std_init().

00095 {
00096    volatile WORD *spec_adr;
00097 
00098    spec_adr = (WORD *) (A24D16_V488 | base | RESET_REG);
00099    *spec_adr = 0x0;
00100 }

INLINE caenv488_RR_write ( const DWORD  base,
const WORD  mode 
)

Definition at line 121 of file caenv488.c.

Referenced by caenv488_std_init().

00122 {
00123    volatile WORD *spec_adr;
00124 
00125    spec_adr = (WORD *) (A24D16_V488 | base | RR_REG);
00126    *spec_adr = mode & 0x11ff;
00127 }

INLINE void caenv488_status ( DWORD  base  ) 

Definition at line 238 of file caenv488.c.

00239 {
00240    volatile WORD *spec_adr;
00241    volatile WORD data;
00242 
00243    /* CTL */
00244    spec_adr = (WORD *) (A24D16_V488 | base | CTL_REG);
00245    data = *spec_adr;
00246    printf("CTL status: 0x%x - Ch.enable: 0x%x \n", data, data & 0xff);
00247    if (data & 0x8000)
00248       printf("Common Start       - ");
00249    else
00250       printf("Common Stop        - ");
00251 
00252    if (!(data & 0x4000))
00253       printf("FIFO empty\n");
00254    else if (!(data & 0x2000))
00255       printf("FIFO Full\n");
00256    else if (!(data & 0x1000))
00257       printf("FIFO half full\n");
00258 
00259    /* RR */
00260    spec_adr = (WORD *) (A24D16_V488 | base | RR_REG);
00261    data = *spec_adr;
00262    if (data & 0x1000)
00263       printf("Mode FIFO full     \n");
00264    else
00265       printf("Mode FIFO half full\n");
00266 }

INLINE void caenv488_std_init ( DWORD  base  ) 

Definition at line 292 of file caenv488.c.

00293 {
00294    caenv488_reset(base);
00295    caenv488_THRH_write(base, 0xc7);
00296    caenv488_THRL_write(base, 0x00);
00297    caenv488_RR_write(base, 0xe0);
00298    caenv488_all_enable(base);
00299 }

INLINE caenv488_THRH_write ( const DWORD  base,
const WORD  mode 
)

Definition at line 129 of file caenv488.c.

Referenced by caenv488_std_init().

00130 {
00131    volatile WORD *spec_adr;
00132 
00133    spec_adr = (WORD *) (A24D16_V488 | base | THRH_REG);
00134    *spec_adr = mode & 0xff;
00135 }

INLINE caenv488_THRL_write ( const DWORD  base,
const WORD  mode 
)

Definition at line 137 of file caenv488.c.

Referenced by caenv488_std_init().

00138 {
00139    volatile WORD *spec_adr;
00140 
00141    spec_adr = (WORD *) (A24D16_V488 | base | THRL_REG);
00142    *spec_adr = mode & 0xff;
00143 }


Midas DOC Version 3.0.0 ---- PSI Stefan Ritt ----
Contributions: Pierre-Andre Amaudruz - Sergio Ballestrero - Suzannah Daviel - Doxygen - Peter Green - Qing Gu - Greg Hackman - Gertjan Hofman - Paul Knowles - Exaos Lee - Rudi Meier - Glenn Moloney - Dave Morris - John M O'Donnell - Konstantin Olchanski - Renee Poutissou - Tamsen Schurman - Andreas Suter - Jan M.Wouters - Piotr Adam Zolnierczuk