📄 inp32.c
字号:
/*******************************************************************************
* Execute inport I/O instruction. *
* Syntax: Data = Inp32(Port) *
* *
* Input Parameters: *
* ================ *
* *
* Port ------> I/O port address (positive integer). *
* *
* Output Parameters: *
* ================= *
* *
* Data ------> Return value (positive integer). *
* *
* See also Out32(). *
* *
* Compile: mex -v inp32.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[])
{
double *data;
short port;
/* get the value(s) of the input variable(s) */
port = (short) mxGetScalar(prhs[0]);
/* set the value(s) of the output variable(s) */
plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL);
data = mxGetPr(plhs[0]);
/* call the respective subroutine(s) */
*data = (double) Inp32(port);
/* show debug information */
if (nrhs == 2)
{
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -