Agilent Technologies E1465A Automobile Parts User Manual


 
Register-Based Programming 91Appendix B
Example: Reading
the Registers
(C/HP-UX)
This C/HP-UX programming example reads the Manufacturer ID Register,
Device Type Register and Status Register on the E1466A matrix module.
/***************************************************/
/****** readreg.c ******/
/**************************************************/
#include <sys/vxi.h> /*source file for controller VXI drivers*/
#include <fcntl.h>
#include <stdio.h>
#define logical_address 120 /*logical address of the matrix module*/
int fd;
typedef unsigned short word;
typedef struct dev_regs{ /*set up pointers*/
unsigned short id_reg;
unsigned short device_type;
unsigned short status_reg;
unsigned short bank0_channels;
} DEV_REGS;
main( )
{
/*open the controller VXI interface*/
fd=open("/dev/vxi/primary",O_RDWR);
if (fd){
perror("open");
exit(1);
}
/*retrieve the A16 pointers*/
dev=(struct dev_regs *)vxi_get_a16_addr(fd,logical_address);
/*sub to read the registers*/
read_reg(dev);
/*END of main program*/
}
/*SUB READ_REG*/
int read_reg(reg_ptr)
DEV_REGS *reg_ptr;
{
/*read the ID register*/
printf("\n ID Register = 0x%x\n",reg_ptr->id_reg);
/*read the Device Type register*/
printf("\n Device Type Register = 0x%x\n",reg_ptr->device_type);
/*read the Status register*/
printf("\n Status Register = 0x%x\n",reg_ptr->status_reg);
return;
}