#include #include #include #define VXINT #include "c:\nivxi\include\nivxi.h" /* SEQSI registers */ short *MEMORY_LOW_WORD, *MEMORY_HIGH_WORD; short *JUMP_ADDRESS_REG; short *INTERRUPT_ADDR_REG; short *CLOCK_CONTROL_REG; short *POLARITY_CONTROL_REG; short *DIRECT_REG; short *SIGNAL_CONTROL_REG; short *MEMORY_ADDRESS_COUNTER; short *MEMORY_DATA_REG; short *TRIGGER_CTR_REG; unsigned long _vmeWindow; main() { long word; int i, j; short a,b; uint16* Vxi_vme_get_baseAddrMap(uint32); void Vxi_vme_end (); /* The different SEQSI registers */ MEMORY_LOW_WORD = Vxi_vme_get_baseAddrMap(0x10000); printf("MEMORY_LOW_WORD = %lx \n",MEMORY_LOW_WORD); if(*MEMORY_LOW_WORD =0) return (0); /* memory not mapped */ MEMORY_HIGH_WORD = (short *)(MEMORY_LOW_WORD+0x1); JUMP_ADDRESS_REG = (short *)(MEMORY_LOW_WORD +0x2); INTERRUPT_ADDR_REG = (short*)(MEMORY_LOW_WORD +0x3); CLOCK_CONTROL_REG = (short *)(MEMORY_LOW_WORD +0x4); POLARITY_CONTROL_REG = (short *)(MEMORY_LOW_WORD +0x5); DIRECT_REG = (short *)(MEMORY_LOW_WORD +0x6); SIGNAL_CONTROL_REG = (short *)(MEMORY_LOW_WORD +0x7); MEMORY_ADDRESS_COUNTER = (short *)(MEMORY_LOW_WORD +0xb); MEMORY_DATA_REG = (short *)(MEMORY_LOW_WORD +0xc); TRIGGER_CTR_REG = (short *)(MEMORY_LOW_WORD +0xd); /* set up the registers before download the sequence */ /* this now serves as the 1st memory address to be downloaded */ *JUMP_ADDRESS_REG = 0x0; /* clock must be off for the download... */ *CLOCK_CONTROL_REG = 0x200; /* reset memory address counter before downloading the memory */ *MEMORY_ADDRESS_COUNTER = 0; *MEMORY_DATA_REG = 0; *DIRECT_REG = 0; *INTERRUPT_ADDR_REG = 0; /* Write 990 memory locations */ word = 0x08000000; /* clock enable high */ for (i=0; i<990; i++) { a = (short) ( word & 0xFFFF); b = (short) ((word>>16) & 0xFFFF); *MEMORY_LOW_WORD = a; *MEMORY_HIGH_WORD = b; } /* Write 10 memory locations */ word = 0x88000000; /* clock enable and jump back high */ for (j=0; j<10; j++) { a = (short) ( word & 0xFFFF); b = (short) ((word>>16) & 0xFFFF); *MEMORY_LOW_WORD = a; *MEMORY_HIGH_WORD = b; } *JUMP_ADDRESS_REG = 0; *MEMORY_ADDRESS_COUNTER = 0; *MEMORY_DATA_REG = 0; printf("\n words written = %i", (i+j)); /* set up the registers after download of the sequence */ *JUMP_ADDRESS_REG = (short ) (0x0); *INTERRUPT_ADDR_REG = (short ) (0x10); *POLARITY_CONTROL_REG = (short ) (0x0); *DIRECT_REG = (short ) (0x0); *SIGNAL_CONTROL_REG = (short ) (0x0); *MEMORY_ADDRESS_COUNTER = (short ) (0x0); *TRIGGER_CTR_REG = (short ) (0x0); *MEMORY_DATA_REG = (short ) (0x0); *CLOCK_CONTROL_REG = (short ) (0x1); /* that's all! */ Vxi_vme_end(); printf("\nVXI_VME library closed"); return(0); } // // vxi_vme stuff // // ============================================================== // get address map // ============================================================== uint16* Vxi_vme_get_baseAddrMap (uint32 address) { int16 ret; int32 timo = 0L; uint16* baseAddr; if(InitVXIlibrary() < 0) { printf("InitVXIlibrary failed, stop\n"); return(0); } baseAddr = (uint16 *) MapVXIAddress (2, address, timo, &_vmeWindow, &ret); printf("Address = %lx, base Addr = %lx \n", address, baseAddr); if ( baseAddr <= 0 ) { printf("No address map for seqsi\n"); return(0); } return baseAddr; } // ============================================================== // end // ============================================================== void Vxi_vme_end () { UnMapVXIAddress (_vmeWindow); CloseVXIlibrary (); }