示例#1
0
void __cdecl mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
    double *port;
    int mrows, ncols;
    double *val;
    
/* Check for proper number of arguments. */
    if (nrhs != 1) {
        mexErrMsgTxt("One input argument required.");
    } else if (nlhs != 1) {
        mexErrMsgTxt("One output argument required.");
    }
    
/* The input must be noncomplex scalar double.*/
    mrows = mxGetM(prhs[0]);
    ncols = mxGetN(prhs[0]);
    if (!mxIsDouble(prhs[0]) || mxIsComplex(prhs[0]) || !(mrows == 1 && ncols == 1)) {
        mexErrMsgTxt("Input must be noncomplex scalar double.");
    }
    
/* Assign pointers to the input. */
    port = mxGetData(prhs[0]);
    plhs[0] = mxCreateScalarDouble(0);
    val = mxGetPr(plhs[0]);
    
    OpenPortTalk();
    *val = inportb(*port);
    ClosePortTalk();    
}
示例#2
0
PORTOBJ::PORTOBJ(int num) : BASE_CL()
{
	outports = 0;
	inports = 9;
	strcpy(in_ports[0].in_name,"trigger");
	strcpy(in_ports[1].in_name,"D0");
	strcpy(in_ports[2].in_name,"D1");
	strcpy(in_ports[3].in_name,"D2");
	strcpy(in_ports[4].in_name,"D3");
	strcpy(in_ports[5].in_name,"D4");
	strcpy(in_ports[6].in_name,"D5");
	strcpy(in_ports[7].in_name,"D6");
	strcpy(in_ports[8].in_name,"D7");

	triggermode=0;
	old_trigger=trigger=INVALID_VALUE;
	val0=0;val1=255;
	portval=0;

	portaddress=0x378;
	OpenPortTalk();
	
}
示例#3
0
SDR1000::SDR1000(char* name, BOOLEAN rfe, BOOLEAN pa, BOOLEAN usb, uint16 lpt_addr)
{
	this->name = name;
	this->rfe = rfe;
	this->pa = pa;
	this->usb = usb;
	this->lpt_addr = lpt_addr;

	if(usb)
	{
		sdr1kusb = new Sdr1kUsb();
		int ret_val = sdr1kusb->Open(rfe, pa, -1);
		if(ret_val != 0) 
			usb = FALSE;
	}
	else
	{
		if(init_count == 0) OpenPortTalk();
		init_count++;
	}
	
	pio_ic01 = new PIOReg("pio_ic01", this, PIO_IC01, 0xA0);
	pio_ic03 = new PIOReg("pio_ic03", this, PIO_IC03, 0x80);
	if(rfe)
	{
		rfe_ic07 = new RFEReg("rfe_ic07", this, RFE_IC07, 0x40);
		rfe_ic09 = new RFEReg("rfe_ic09", this, RFE_IC09);
		rfe_ic10 = new RFEReg("rfe_ic10", this, RFE_IC10);
		rfe_ic11 = new RFEReg("rfe_ic11", this, RFE_IC11);
	}
	dds = new AD9854("dds", this);
	freq_cal_offset = 0.0;
	clock_ref_freq = 10.0;
	spur_reduction_enabled = false;
	spur_reduction_mask = 0xFFFF00000000llu;
	StandBy();
}
示例#4
0
void __cdecl mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
	double *port, *value;
	int mrows, ncols, arg;

	/* Check for proper number of arguments. */
	if (nrhs != 2) {
		mexErrMsgTxt("Two input arguments required.");
	}
	else if (nlhs > 0) {
		mexErrMsgTxt("Too many output arguments.");
	}

	/* The input must be noncomplex scalar double.*/
	for (arg = 0; arg < 2; arg++) {
		mrows = mxGetM(prhs[arg]);
		ncols = mxGetN(prhs[arg]);
		if (!mxIsDouble(prhs[arg]) || mxIsComplex(prhs[arg]) || !(mrows == 1 && ncols == 1)) {
			mexErrMsgTxt("Input must be noncomplex scalar double.");
		}
	}

	/* Assign pointers to each input and output. */
	port = mxGetData(prhs[0]);
	value = mxGetData(prhs[1]);

	OpenPortTalk();
	outportb(*port, *value);
	ClosePortTalk();

	/* This is where the new code begins    */


	//Dynamically load the DLL at runtime (not linked at compile time)
	HINSTANCE hInpOutDll;
	hInpOutDll = LoadLibrary("InpOutx64.DLL");	//The 32bit DLL. If we are building x64 C++ 
	//applicaiton then use InpOutx64.dll
	if (hInpOutDll != NULL)
	{
		gfpOut32 = (lpOut32)GetProcAddress(hInpOutDll, "Out32");
		gfpInp32 = (lpInp32)GetProcAddress(hInpOutDll, "Inp32");
		gfpIsInpOutDriverOpen = (lpIsInpOutDriverOpen)GetProcAddress(hInpOutDll, "IsInpOutDriverOpen");
		gfpIsXP64Bit = (lpIsXP64Bit)GetProcAddress(hInpOutDll, "IsXP64Bit");

		if (gfpIsInpOutDriverOpen())
		{
			//Make some noise through the PC Speaker - hey it can do more that a single beep using InpOut32
			Beep(2000);
			Sleep(200);
			Beep(1000);
			Sleep(300);
			Beep(2000);
			Sleep(250);
			StopBeep();

			if (!strcmp(argv[1], "read"))
			{
				short iPort = atoi(argv[2]);
				WORD wData = gfpInp32(iPort);	//Read the port
				printf("Data read from address %s is %d \n\n\n\n", argv[2], wData);
			}
			else if (!strcmp(argv[1], "write"))
			{
				if (argc < 4)
				{
					printf("Error in arguments supplied");
					printf("\n***** Usage *****\n\nInpoutTest read <ADDRESS> \nor \nInpoutTest write <ADDRESS> <DATA>\n\n\n\n\n");
				}
				else
				{
					short iPort = atoi(argv[2]);
					WORD wData = atoi(argv[3]);
					gfpOut32(iPort, wData);
					printf("data written to %s\n\n\n", argv[2]);
				}
			}
		}
		else
		{
			printf("Unable to open InpOut32 Driver!\n");
		}

		//All done
		FreeLibrary(hInpOutDll);
		return 0;
	}
	else
	{
		printf("Unable to load InpOut32 DLL!\n");
		return -1;
	}
}