esone.c File Reference


Detailed Description

The ESONE CAMAC standard call file

Definition in file esone.c.

Go to the source code of this file.

Functions

INLINE void ccinit (void)
INLINE int fccinit (void)
INLINE void cdreg (int *ext, const int b, const int c, const int n, const int a)
INLINE void cssa (const int f, int ext, unsigned short *d, int *q)
INLINE void cfsa (const int f, const int ext, unsigned long *d, int *q)
INLINE void cccc (const int ext)
INLINE void cccz (const int ext)
INLINE void ccci (const int ext, int l)
INLINE void ctci (const int ext, int *l)
INLINE void cccd (const int ext, int l)
INLINE void ctcd (const int ext, int *l)
INLINE void cdlam (int *lam, const int b, const int c, const int n, const int a, const int inta[2])
INLINE void ctgl (const int ext, int *l)
INLINE void cclm (const int lam, int l)
INLINE void cclnk (const int lam, void(*isr)(void))
INLINE void cculk (const int lam)
INLINE void ccrgl (const int lam)
INLINE void cclc (const int lam)
INLINE void ctlm (const int lam, int *l)
INLINE void cfga (int f[], int exta[], int intc[], int qa[], int cb[])
INLINE void csga (int f[], int exta[], int intc[], int qa[], int cb[])
INLINE void cfmad (int f, int extb[], int intc[], int cb[])
INLINE void csmad (int f, int extb[], int intc[], int cb[])
INLINE void cfubc (const int f, int ext, int intc[], int cb[])
INLINE void csubc (const int f, int ext, int intc[], int cb[])
INLINE void cfubr (const int f, int ext, int intc[], int cb[])
INLINE void csubr (const int f, int ext, int intc[], int cb[])


Function Documentation

INLINE void cccc ( const int  ext  ) 

Control Crate Clear.

Generate Crate Clear function. Execute cam_crate_clear()

Parameters:
ext external address
Returns:
void

Definition at line 193 of file esone.c.

00194 {
00195    int b, c, n, a;
00196 
00197    came_ext(ext, &b, &c, &n, &a);
00198    cam_crate_clear(c);
00199 }

INLINE void cccd ( const int  ext,
int  l 
)

Control Crate D.

Enable or Disable Crate Demand.

Parameters:
ext external address
l action l=0 -> Clear D, l=1 -> Set D
Returns:
void

Definition at line 267 of file esone.c.

00268 {
00269    int b, c, n, a;
00270 
00271    came_ext(ext, &b, &c, &n, &a);
00272 
00273    if (l)
00274       cam_interrupt_enable(c);
00275    else
00276       cam_interrupt_disable(c);
00277 }

INLINE void ccci ( const int  ext,
int  l 
)

Control Crate I.

Set or Clear Dataway Inhibit, Execute cam_inhinit_set() /clear()

Parameters:
ext external address
l action l=0 -> Clear I, l=1 -> Set I
Returns:
void

Definition at line 228 of file esone.c.

00229 {
00230    int b, c, n, a;
00231 
00232    came_ext(ext, &b, &c, &n, &a);
00233    if (l)
00234       cam_inhibit_set(c);
00235    else
00236       cam_inhibit_clear(c);
00237 }

INLINE void cccz ( const int  ext  ) 

Control Crate Z.

Generate Dataway Initialize. Execute cam_crate_zinit()

Parameters:
ext external address
Returns:
void

Definition at line 210 of file esone.c.

00211 {
00212    int b, c, n, a;
00213 
00214    came_ext(ext, &b, &c, &n, &a);
00215    cam_crate_zinit(c);
00216 }

INLINE void ccinit ( void   ) 

CAMAC initialization

CAMAC initialization must be called before any other ESONE subroutine call.

Returns:
void

Definition at line 72 of file esone.c.

00073 {
00074    cam_init();
00075 }

INLINE void cclc ( const int  lam  ) 

Control Clear LAM.

Clear the LAM of the station pointer by the lam address.

Parameters:
lam external address
Returns:
void

Definition at line 428 of file esone.c.

00429 {
00430    int b, c, n, a;
00431 
00432    came_ext(lam, &b, &c, &n, &a);
00433    camc(c, n, 0, 10);
00434 }

INLINE void cclm ( const int  lam,
int  l 
)

Control Crate LAM.

Enable or Disable LAM. Execute F24 for disable, F26 for enable.

Parameters:
lam external address
l action l=0 -> disable LAM , l=1 -> enable LAM
Returns:
void

Definition at line 348 of file esone.c.

00349 {
00350    int b, c, n, a;
00351 
00352    came_ext(lam, &b, &c, &n, &a);
00353 
00354    if (l)
00355       camc(c, n, 0, 26);
00356    else
00357       camc(c, n, 0, 24);
00358 }

INLINE void cclnk ( const int  lam,
void(*)(void)  isr 
)

Link LAM to service procedure

Link a specific service routine to a LAM. Since this routine is executed asynchronously, care must be taken on re-entrancy.

Parameters:
lam external address
isr name of service procedure
Returns:
void

Definition at line 371 of file esone.c.

00372 {
00373    int b, c, n, a;
00374 
00375    came_ext(lam, &b, &c, &n, &a);
00376 
00377    cam_interrupt_attach(c, n, isr);
00378    cam_lam_enable(c, n);
00379    cam_lam_clear(c, n);
00380 }

INLINE void ccrgl ( const int  lam  ) 

Relink LAM

Re-enable LAM in the controller

Parameters:
lam external address
Returns:
void

Definition at line 408 of file esone.c.

00409 {
00410    int b, c, n, a;
00411 
00412    came_ext(lam, &b, &c, &n, &a);
00413 
00414    cam_lam_enable(c, n);
00415    cam_lam_clear(c, n);
00416    cam_interrupt_enable(c);
00417 }

INLINE void cculk ( const int  lam  ) 

Unlink LAM from service procedure

Performs complementary operation to cclnk.

Parameters:
lam external address
Returns:
void

Definition at line 391 of file esone.c.

00392 {
00393    int b, c, n, a;
00394 
00395    came_ext(lam, &b, &c, &n, &a);
00396    cam_interrupt_detach(c, n);
00397 }

INLINE void cdlam ( int *  lam,
const int  b,
const int  c,
const int  n,
const int  a,
const int  inta[2] 
)

Control Declare LAM.

Declare LAM, Identical to cdreg.

Parameters:
lam external LAM address
b branch number (0..7)
c crate number (0..)
n station number (0..30)
a sub-address (0..15)
inta implementation dependent
Returns:
void

Definition at line 311 of file esone.c.

00313 {
00314    /* inta[2] ignored */
00315    cdreg(lam, b, c, n, a);
00316 }

INLINE void cdreg ( int *  ext,
const int  b,
const int  c,
const int  n,
const int  a 
)

Control Declaration REGister.

Compose an external address from BCNA for later use. Accessing CAMAC through ext could be faster if the external address is memory mapped to the processor (hardware dependent). Some CAMAC controller do not have this option see Supported hardware.

Parameters:
ext external address
b branch number (0..7)
c crate number (0..)
n station number (0..30)
a sub-address (0..15)
Returns:
void

Definition at line 109 of file esone.c.

Referenced by cdlam().

00110 {
00111    came_cn(ext, b, c, n, a);
00112 }

INLINE void cfga ( int  f[],
int  exta[],
int  intc[],
int  qa[],
int  cb[] 
)

Control Full (24bit) word General Action.

Parameters:
f function code
exta[] external address array
intc[] data array
qa[] Q response array
cb[] control block array
cb[0] : number of function to perform
cb[1] : returned number of function performed
Returns:
void

Definition at line 467 of file esone.c.

00468 {
00469    int i;
00470 
00471    for (i = 0; i < cb[0]; i++)
00472       cfsa(f[i], exta[i], (unsigned long *) (&(intc[i])), &(qa[i]));
00473 
00474    cb[1] = cb[0];
00475 }

INLINE void cfmad ( int  f,
int  extb[],
int  intc[],
int  cb[] 
)

Control Full (24bit) Address Q scan.

Scan all sub-address while Q=1 from a0..a15 max from address extb[0] and store corresponding data in intc[]. If Q=0 while A<15 or A=15 then cross station boundary is applied (n-> n+1) and sub-address is reset (a=0). Perform action until either cb[0] action are performed or current external address exceeds extb[1].

implementation of cb[2] for LAM recognition is not implemented.

Parameters:
f function code
extb[] external address array
extb[0] : first valid external address
extb[1] : last valid external address
intc[] data array
cb[] control block array
cb[0] : number of function to perform
cb[1] : returned number of function performed
Returns:
void

Definition at line 521 of file esone.c.

00522 {
00523    int j, count;
00524    int x, q, b, c, n, a;
00525    unsigned long exts, extc, exte;
00526 
00527    exts = extb[0];
00528    exte = extb[1];
00529    count = cb[0];
00530    j = 0;
00531    came_ext(exts, &b, &c, &n, &a);
00532    do {
00533       cam24i_q(c, n, a, f, (unsigned long *) &intc[j], &x, &q);
00534       if (q == 0) {
00535          a = 0;                 /* set subaddress to zero */
00536          n++;                   /* select next slot */
00537          j++;
00538       } else {
00539          a++;                   /* increment address */
00540          ++cb[1];               /* increment tally count */
00541          ++intc;                /* next data array */
00542          --count;
00543       }
00544       came_cn((int *) &extc, b, c, n, a);
00545 
00546       if (extc > exte)
00547          count = 0;             /* force exit */
00548 
00549    } while (count);
00550 }

INLINE void cfsa ( const int  f,
const int  ext,
unsigned long *  d,
int *  q 
)

Control Full Operation.

24 bit operation on a given external CAMAC address.

The range of the f is hardware dependent. The number indicated below are for standard ANSI/IEEE Std (758-1979) Execute cam24i for f<8, cam24o for f>15, camc_q for (f>7 or f>23)

Parameters:
f function code (0..31)
ext external address
d data long word
q Q response
Returns:
void

Definition at line 165 of file esone.c.

Referenced by cfga(), cfubc(), and cfubr().

00166 {
00167    int b, c, n, a, x;
00168 
00169    if (f < 8) {
00170       /* read */
00171       came_ext(ext, &b, &c, &n, &a);
00172       cam24i_q(c, n, a, f, d, &x, q);
00173    } else if (f > 15) {
00174       /* write */
00175       came_ext(ext, &b, &c, &n, &a);
00176       cam24o_q(c, n, a, f, *d, &x, q);
00177    } else if ((f > 7) || (f > 23)) {
00178       /* command */
00179       came_ext(ext, &b, &c, &n, &a);
00180       camc_q(c, n, a, f, q);
00181    }
00182 }

INLINE void cfubc ( const int  f,
int  ext,
int  intc[],
int  cb[] 
)

Control Full (24bit) Block Repeat with Q-stop.

Execute function f on address ext with data intc[] while Q.

Parameters:
f function code
ext external address array
intc[] data array
cb[] control block array
cb[0] : number of function to perform
cb[1] : returned number of function performed
Returns:
void

Definition at line 618 of file esone.c.

00619 {
00620    int count, q;
00621 
00622    count = cb[0];
00623    do {
00624       cfsa(f, ext, (unsigned long *) intc, &q);
00625       if (q == 0)
00626          count = 0;             /* stop on no q */
00627       else {
00628          ++cb[1];               /* increment tally count */
00629          ++intc;                /* next data array */
00630          --count;
00631       }
00632    } while (count);
00633 }

INLINE void cfubr ( const int  f,
int  ext,
int  intc[],
int  cb[] 
)

Repeat Mode Block Transfer (24bit).

Execute function f on address ext with data intc[] if Q. If noQ keep current intc[] data. Repeat cb[0] times.

Parameters:
f function code
ext external address array
intc[] data array
cb[] control block array
cb[0] : number of function to perform
cb[1] : returned number of function performed
Returns:
void

Definition at line 681 of file esone.c.

00682 {
00683    int q, count;
00684 
00685    count = cb[0];
00686    do {
00687       do {
00688          cfsa(f, ext, (unsigned long *) intc, &q);
00689       } while (q == 0);
00690 
00691       ++cb[1];                  /* increment tally count */
00692       ++intc;                   /* next data array */
00693       --count;
00694    } while (count);
00695 }

INLINE void csga ( int  f[],
int  exta[],
int  intc[],
int  qa[],
int  cb[] 
)

Control (16bit) word General Action.

Parameters:
f function code
exta[] external address array
intc[] data array
qa[] Q response array
cb[] control block array
cb[0] : number of function to perform
cb[1] : returned number of function performed
Returns:
void

Definition at line 490 of file esone.c.

00491 {
00492    int i;
00493 
00494    for (i = 0; i < cb[0]; i++)
00495       cssa(f[i], exta[i], (unsigned short *) (&(intc[i])), &(qa[i]));
00496 
00497    cb[1] = cb[0];
00498 }

INLINE void csmad ( int  f,
int  extb[],
int  intc[],
int  cb[] 
)

Control (16bit) Address Q scan.

Scan all sub-address while Q=1 from a0..a15 max from address extb[0] and store corresponding data in intc[]. If Q=0 while A<15 or A=15 then cross station boundary is applied (n-> n+1) and sub-address is reset (a=0). Perform action until either cb[0] action are performed or current external address exceeds extb[1].

implementation of cb[2] for LAM recognition is not implemented.

Parameters:
f function code
extb[] external address array
extb[0] : first valid external address
extb[1] : last valid external address
intc[] data array
cb[] control block array
cb[0] : number of function to perform
cb[1] : returned number of function performed
Returns:
void

Definition at line 573 of file esone.c.

00574 {
00575    int j, count;
00576    int x, q, b, c, n, a;
00577    unsigned long exts, extc, exte;
00578 
00579    exts = extb[0];
00580    exte = extb[1];
00581    count = cb[0];
00582    j = 0;
00583    came_ext(exts, &b, &c, &n, &a);
00584    do {
00585       cam16i_q(c, n, a, f, (unsigned short *) &intc[j], &x, &q);
00586       if (q == 0) {
00587          a = 0;                 /* set subaddress to zero */
00588          n++;                   /* select next slot */
00589          j++;
00590       } else {
00591          a++;                   /* increment address */
00592          ++cb[1];               /* increment tally count */
00593          ++intc;                /* next data array */
00594          --count;
00595       }
00596       came_cn((int *) &extc, b, c, n, a);
00597 
00598       if (extc > exte)
00599          count = 0;             /* force exit */
00600 
00601    } while (count);
00602 }

INLINE void cssa ( const int  f,
int  ext,
unsigned short *  d,
int *  q 
)

Control Short Operation.

16 bit operation on a given external CAMAC address.

The range of the f is hardware dependent. The number indicated below are for standard ANSI/IEEE Std (758-1979) Execute cam16i for f<8, cam16o for f>15, camc_q for (f>7 or f>23)

Parameters:
f function code (0..31)
ext external address
d data word
q Q response
Returns:
void

Definition at line 130 of file esone.c.

Referenced by csga(), csubc(), and csubr().

00131 {
00132    int b, c, n, a, x;
00133 
00134    if (f < 8) {
00135       /* read */
00136       came_ext(ext, &b, &c, &n, &a);
00137       cam16i_q(c, n, a, f, d, &x, q);
00138    } else if (f > 15) {
00139       /* write */
00140       came_ext(ext, &b, &c, &n, &a);
00141       cam16o_q(c, n, a, f, *d, &x, q);
00142    } else if ((f > 7) || (f > 23)) {
00143       /* command */
00144       came_ext(ext, &b, &c, &n, &a);
00145       camc_q(c, n, a, f, q);
00146    }
00147 }

INLINE void csubc ( const int  f,
int  ext,
int  intc[],
int  cb[] 
)

Control (16bit) Block Repeat with Q-stop.

Execute function f on address ext with data intc[] while Q.

Parameters:
f function code
ext external address array
intc[] data array
cb[] control block array
cb[0] : number of function to perform
cb[1] : returned number of function performed
Returns:
void

Definition at line 649 of file esone.c.

00650 {
00651    int count, q;
00652 
00653    count = cb[0];
00654    do {
00655       cssa(f, ext, (unsigned short *) intc, &q);
00656       if (q == 0)
00657          count = 0;             /* stop on no q */
00658       else {
00659          ++cb[1];               /* increment tally count */
00660          ++intc;                /* next data array */
00661          --count;
00662       }
00663    } while (count);
00664 }

INLINE void csubr ( const int  f,
int  ext,
int  intc[],
int  cb[] 
)

Repeat Mode Block Transfer (16bit).

Execute function f on address ext with data intc[] if Q. If noQ keep current intc[] data. Repeat cb[0] times.

Parameters:
f function code
ext external address array
intc[] data array
cb[] control block array
cb[0] : number of function to perform
cb[1] : returned number of function performed
Returns:
void

Definition at line 712 of file esone.c.

00713 {
00714    int q, count;
00715 
00716    count = cb[0];
00717    do {
00718       do {
00719          cssa(f, ext, (unsigned short *) intc, &q);
00720       } while (q == 0);
00721 
00722       ++cb[1];                  /* increment tally count */
00723       ++intc;                   /* next data array */
00724       --count;
00725    } while (count);
00726 }

INLINE void ctcd ( const int  ext,
int *  l 
)

Control Test Crate D.

Test Crate Demand.

Parameters:
ext external address
l D cleared -> l=0, D set -> l=1
Returns:
void

Definition at line 289 of file esone.c.

00290 {
00291    int b, c, n, a;
00292 
00293    came_ext(ext, &b, &c, &n, &a);
00294    *l = cam_interrupt_test(c);
00295 }

INLINE void ctci ( const int  ext,
int *  l 
)

Test Crate I.

Test Crate Inhibit, Execute cam_inhibit_test()

Parameters:
ext external address
l action l=0 -> Clear I, l=1 -> Set I
Returns:
void

Definition at line 249 of file esone.c.

00250 {
00251    int b, c, n, a;
00252 
00253    came_ext(ext, &b, &c, &n, &a);
00254    *l = cam_inhibit_test(c);
00255 }

INLINE void ctgl ( const int  ext,
int *  l 
)

Control Test Demand Present.

Test the LAM register.

Parameters:
ext external LAM register address
l l !=0 if any LAM is set.
Returns:
void

Definition at line 328 of file esone.c.

00329 {
00330    int b, c, n, a;
00331    unsigned long lam;
00332 
00333    came_ext(ext, &b, &c, &n, &a);
00334    cam_lam_read(c, &lam);
00335    *l = (lam > 0);
00336 }

INLINE void ctlm ( const int  lam,
int *  l 
)

Test LAM.

Test the LAM of the station pointed by lam. Performs an F8

Parameters:
lam external address
l No LAM-> l=0, LAM present-> l=1
Returns:
void

Definition at line 446 of file esone.c.

00447 {
00448    int b, c, n, a;
00449 
00450    came_ext(lam, &b, &c, &n, &a);
00451    camc_q(c, n, a, 8, l);
00452 }

INLINE int fccinit ( void   ) 

CAMAC initialization with return status

fccinit can be called instead of ccinit to determine if the initialization was successful

Returns:
1 for success, 0 for failure

Definition at line 86 of file esone.c.

00087 {
00088    if (cam_init() == SUCCESS)
00089       return 1;
00090 
00091    return 0;
00092 }


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