outport.c

来自「MATLAB扩展编程by 孙永康.ZIP.有需要的朋友请来下载.」· C语言 代码 · 共 27 行

C
27
字号
#include "mex.h"
#include "conio.h"

void mexFunction( int nlhs, mxArray *plhs[],
				  int nrhs, const mxArray*prhs[] )
{
	unsigned short port;
	unsigned char  ch;
	double   *ptr;

	if (nrhs != 2)
		mexErrMsgTxt("Need two parameters\n");

	if (!mxIsNumeric(prhs[0]))
		mexErrMsgTxt("Port should be numeric\n");

	if (!mxIsNumeric(prhs[1]))
		mexErrMsgTxt("Byte should be numeric\n");

	ptr     = mxGetPr(prhs[0]);
	port    = (unsigned short) (*ptr);

	ptr     = mxGetPr(prhs[1]);
	ch      = (unsigned char ) (*ptr);

	_outp(port, ch);
}

⌨️ 快捷键说明

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