out32.c

来自「MatLab图像传感器网络仿真平台WiSNAP」· C语言 代码 · 共 55 行

C
55
字号
/*******************************************************************************
 * Execute outport I/O instruction.                                            *
 * Syntax: Out32(Port, Data)                                                   *
 *                                                                             *
 *    Input Parameters:                                                        *
 *    ================                                                         *
 *                                                                             *
 *       Port ------> I/O port address (positive integer).                     *
 *       Data ------> Port value (positive integer).                           *
 *                                                                             *
 *    Output Parameters:                                                       *
 *    =================                                                        *
 *                                                                             *
 *       NONE.                                                                 *
 *                                                                             *
 *    See also Inp32().                                                        *
 *                                                                             *
 * Compile: mex -v out32.c inpout32.lib                                        *
 * Version: 01-05-2005                                                         *
 *                                                                             *
 * (C) 2005 Stephan Hengstler, Stanford Wireless Sensor Networks Lab           *
 *******************************************************************************/


#include <stdio.h>
#include <windows.h>
#include "mex.h"

/* prototypes of inpout32.dll functions */
short _stdcall Inp32(short port);
void _stdcall  Out32(short port, short data);

void mexFunction(int nlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[])
{
	short	      data, port;

	/* get the value(s) of the input variable(s) */
	port   		= (short) mxGetScalar(prhs[0]);
	data   		= (short) mxGetScalar(prhs[1]);

	/* call the respective subroutine(s) */
	Out32(port, data);

   /* show debug information */
	if (nrhs == 3)
	{
		printf("Debug Information\n");
		printf("port   	= 0x%04x\n", (short) port);
		printf("data   	= 0x%02x\n", (short) data);
	}

	/* clean exit */
	return;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?