Register-Based Programming 91
Appendix 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;
}
Содержание E1465A
Страница 2: ......
Страница 6: ...6 ...
Страница 10: ...10 Notes ...
Страница 12: ...12 Getting Started Chapter 1 Figure 1 1 E1465A 16x16 Relay Matrix Module TERMINAL MODULE MATRIX MODULE A B C D ...
Страница 13: ...Getting Started 13 Chapter 1 Figure 1 2 E1466A 4x64 Relay Matrix Module TERMINAL MODULE MATRIX MODULE A B C D ...
Страница 14: ...14 Getting Started Chapter 1 Figure 1 3 E1467A 8x32 Relay Matrix Module TERMINAL MODULE MATRIX MODULE A B C D ...
Страница 18: ...18 Getting Started Chapter 1 Notes ...
Страница 80: ...80 Matrix Modules Command Reference Chapter 4 Notes ...
Страница 98: ...98 Register Based Programming Appendix B Notes ...