ROCK L0 library - rockhard


This module implements the fisical access to the ROCK and is the only one part of the library that do this.

The ROCK is presented as a list of registers, with the possibility of the block read of a page and the block read of a FIFO.

Directly should only be used in test applications.


Index


ROCK hardware id

The access to the ROCK is implemented via channels. Each channel have its own ROCK hardware id. In this way one application can access many different rocks simply using different ids.

The definition of the ROCK hardware id type:

This is a primitive type so the access to the internal stucture should not be done.

All the routines present in rockhard have a parameter of this type.


Query ROCK presence

A typical application do not know which ROCKs are currenty present. This routine helps to find them out.
rockh_ispresent()
Syntax:
#define rockh_ispresent(/*int*/ chain, /*int*/ crate);
Parameters:
IN: chain
VIC chain
IN: crate
position in the VIC chain
Returns:
0 if the ROCK is not present, 1 else
Note:
Internaly uses the GeoVme package.

Initialization routines

As stated before, the access to the ROCK is implemented via a ROCK hardware id. To obtain such an id you have to open a channel to the ROCK using rockh_open. This id will than be used for all the accesses to the ROCK.
Each id should identify a different ROCK.

When you finish using the ROCK, please call rockh_close to close the channel associated to the id.

Follows the descriptions of the functions:

rockh_open()
Associates a ROCK hardware id to a ROCK.
Must be called before any access to the ROCK.

Syntax:
int rockh_open(int chain, int crate, ROCKH_id * rock_id);
Parameters:
IN: chain
VIC chain
IN: crate
position in the VIC chain
OUT: rock_id
pointer to a new ROCK hardware id
Returns:
ROCKH_ERROR_OK in case of success
Note:
Internaly uses the GeoVme package.
rockh_open_raw()
Associates a ROCK hardware id to a ROCK.
Must be called before any access to the ROCK.

Syntax:
int rockh_open_raw(unsigned int vme_addr, int vme_size, int vme_am, int offs, ROCKH_id * rock_id);
Parameters:
IN: vme_addr, vme_size, vme_am
see the VmeMapAddress documentation
IN: offs
rock offset
OUT: rock_id
pointer to a new ROCK hardware id
Returns:
ROCKH_ERROR_OK in case of success
Note:
Directly should be used only for test.
rockh_close()
Disposes the ROCK hardware id.
Should be called after the last ROCK access.

Syntax:
int rockh_close(ROCKH_id rock_id);
Parameters:
IN: rock_id
ROCK hardware id
Returns:
ROCKH_ERROR_OK in case of success

Register read

At this level the ROCK is presented as a list of registers. Use the register read routines to read from this registers.

The general form of a register read routine is:
Syntax:
#define rockh_read_<register>(/*ROCKH_id */ rock_id)
Parameters:
IN: rock_id
ROCK hardware id
Returns:
value read from the register
Note:
Not all the registers can be read-out at any time. See the ROCK documentation for details.

The routines are implemented as macros.

Follows the list of the register read routines:

Register write

The ROCK is made of registers. Use the register write routines to write to this registers.

The general form of a register write routine is:
Syntax:
#define rockh_write_<register>(/*ROCKH_id */ rock_id, value, test)
Parameters:
IN: rock_id
ROCK hardware id
IN: value
value to be written in the register
IN: test
should be 0 or 1
if 1, reread the register and compare the values
Returns:
ROCKH_ERROR_OK in case of success
ROCKH_ERROR_TEST if test failed
Note:
Not all the registers can be written at any time and not all the bits of a register can be written in. See the ROCK documentation for details.

If a register write cannot be tested, the test parameter is ignored.

The routines are implemented as macros.

Follows the list of the register read routines:

Block read of a page

Sometimes it is usefull to read a page of the ROCK registers with only one command.
The rockpage routines do it for you.

The general form of a readpage routine is:
Syntax:
#define rockh_readpage_<page>(/*ROCKH_id */ rock_id, /* ROCKH_<PAGE>_regs */ regs)
Parameters:
IN: rock_id
ROCK hardware id
OUT: regs
list of values read form the registers of the page
Returns:
ROCKH_ERROR_OK in case of success
Note:
The routines are implemented as macros.
Follows the list of readpage specific types and the list of readpage routines:

Block read of a FIFO

FIFOs normaly contain big amount of data. So it is not efficient to read-out value by value. A block transfer is normally a better choice.

The general form of a readfifo routine is:
Syntax:
#define rockh_readfifo_<fifo>(/*ROCKH_id */ rock_id, /* unsigned it */ count, /* unsigned int * */ buffer)
Parameters:
IN: rock_id
ROCK hardware id
IN: count
nr. of elements to read
OUT: count
nr. of elements actualy read
OUT: buffer
array filled with raw data read
must be allocated by the caller
Returns:
ROCKH_ERROR_OK in case of success
Note:
The routines are implemented as macros.
Follows the list of readfifo routines:

Examples

Follows 3 simple examples:
A real program: If you want something more complex, see the L1 module rock source code:

List of types and routines

Types:
Routines:
Top of the page. Rock library.
Send comments to: Igor Sfiligoi

Created:7.2.1997
Last modified:10.4.1997