#include #include #include #include #include #include #include #include "ti_dsp.h" #ifdef NEVIS #include "nevis_mb.h" #else #include "ROD.h" #define RODID 1 rod_t *pROD; /* defined in ROD.h and used here and in ti_vme_gva.c */ /* Default slot, geographical address, and VME mode */ static int slot=4, mode=2, gaddr=11; #endif /* ==== Terminal mode handling ==== */ #include static struct termio savetty; static void set_term_raw() { struct termio tty; ioctl(0, TCGETA, &tty); savetty = tty; tty.c_lflag &= ~ICANON; tty.c_lflag &= ~ECHO; tty.c_cc[VMIN] = 1; ioctl(0, TCSETAF, &tty); } static void reset_term() { ioctl(0, TCSETAF, &savetty); } main(int argc, char** argv) { /* The PU descriptor */ ti_dsp_t dsp; unsigned int ist; #ifdef NEVIS vme_rod_init(0x00900000); vme_rod_write(MB_RESET, 1); mb_evt_load(0.2); #else { crate_t *aCrate = ROD_CrateInit(1,0); assert (aCrate != NULL); pROD = aCrate->rod[0]; } ist = ROD_ModuleInit(pROD, gaddr, RODID); assert (ist == 0); /* Configure PUs (what is this for) */ ist = ROD_PModule(pROD); /* Configure mother board components */ ist = ROD_GeneralReset(pROD); ist = ROD_TtcConfig(pROD, mode); #endif #ifndef NEVIS if (argc > 1) slot = atoi(argv[1]); if (argc > 2) mode = atoi(argv[2]); if (argc > 3) gaddr = atoi(argv[3]); dsp.rodid = RODID; dsp.puid = slot; #endif dsp.nsamp = 5; dsp.ngain = 1; dsp.bootFile = "calib.x0"; dsp.calibrationFile = NULL; /* === Boot the TI processing unit */ ti_boot(&dsp, TI_AUTO); /* --- Put terminal in raw mode */ set_term_raw(); atexit(reset_term); while(1){ char c = getchar(); switch(c){ case '?': /* Read the number of events accumulated */ ti_syscall(&dsp, 0); break; case 'v': /* Read the accumulated data */ ti_syscall(&dsp, 1); break; case 'x': /* Clear the accumulators */ ti_interrupt(&dsp); break; case 'r': /* Reboot the DSP */ ti_boot(&dsp, TI_AUTO); break; case 'R': /* Reboot the DSP and the input FPGA */ ti_boot(&dsp, TI_REBOOT); break; #ifdef NEVIS case 't': /* Send trigger(s) */ mb_evt_send(1); break; #endif case 'q': /* Quit */ exit(0); break; default: continue; } usleep(25000); ist = ti_fpsstatus(&dsp); if (ist & TI_STATUS_SRDY){ ist = vme_dsp_read(&dsp, TI_SREAD); fprintf(stderr, "DSP serial data=0x%x\n", ist); } /* -- Dump the accumulated data to a binary file */ { typedef struct { int adc[64]; int rms[64]; } sample_t; sample_t data[5]; int nw, isamp, ich; nw = ti_hread(&dsp, data, sizeof(data)); printf("Read %d words\n", nw); if (nw == 0) continue; for(isamp=0; isamp