Agilent Technologies E1442-90003 Switch User Manual


 
96 Register-Based Programming Appendix B
Programming Example
Beginning of Program /* This program resets the E1442A, closes channels and reads the*/
/* switchs relay control registers, opens channels and scans all 64*/
/* channels on the module. *
#include <sicl.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <dos.h>
/* function prototypes */
void reset_sw(char *base_addr);
void delay (unsigned milliseconds);
Program Main void main(void)
{
double ldexp(double i, int exp);
char *base_addr;
int j, k;
unsigned short chan_0_15_reg, chan_16_31_reg; /*First 32 chan */
unsigned short chan_32_47_reg, chan_48_63_reg; /* Sec 32 chan */
unsigned short id_reg, dt_reg; /* ID and device type */
unsigned short stat_reg; /* Status Register */
/* create and open a device session */
INST e1442a;
e1442a = iopen("vxi,120");
/* map the E1442A registers into user memory space */
base_addr = imap(e1442a, I_MAP_VXIDEV, 0, 1, NULL);
/* clear the user screen */
clrscr();
/* reset the E1442A */
reset_sw(base_addr);
Read ID and Device
Type Registers
/********** read the switchs ID and Device Type registers **********/
id_reg = iwpeek((unsigned short *)(base_addr + 0x00));
dt_reg = iwpeek((unsigned short *)(base_addr + 0x02));
printf("ID register = 0x%4X\nDevice Type register = 0x%4X\n",
id_reg, dt_reg);
Read Status Register /********** read the switchs Status Register *********/
stat_reg = iwpeek((unsigned short *)(base_addr + 0x04));
printf("Status register = 0x%4X\n", stat_reg);