⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spi_read_register.c

📁 MatLab图像传感器网络仿真平台WiSNAP
💻 C
字号:
/*******************************************************************************
 * Serial Peripheral Interface (4-wire SPI) register read.                     *
 * Syntax: Value = Spi_Read_Register(Port, Address)                            *
 *                                                                             *
 *    Input Parameters:                                                        *
 *    ================                                                         *
 *                                                                             *
 *       Port --------> Parallel port base address decimal (positive integer). *
 *       Address -----> Register address decimal (positive integer).           *
 *                                                                             *
 *    Output Parameters:                                                       *
 *    =================                                                        *
 *                                                                             *
 *       Value -------> Register value decimal (positive integer).             *
 *                                                                             *
 *    See also Spi_Write_Register().                                           *
 *                                                                             *
 * Compile: mex -v spi_read_register.c ms_spi.c inpout32.lib                   *
 * Version: 02-02-2005                                                         *
 *                                                                             *
 * (C) 2005 Stephan Hengstler, Stanford Wireless Sensor Networks Lab           *
 *******************************************************************************/


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

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

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

	/* set the value(s) of the output variable(s) */
	plhs[0] 		= mxCreateDoubleMatrix(1, 1, mxREAL);
   value  	   = mxGetPr(plhs[0]);
	
	/* call the respective subroutine(s) */
   *value     	= (double) spi_read_register(port, address);

   /* show debug information */
	if (nrhs == 3)
	{
		printf("Debug Information\n");
		printf("port      = %d\n", port);
		printf("address   = %d\n", address);
		printf("value     = %d\n", (short) *value);
	}

	/* clean exit */
	return;
}

⌨️ 快捷键说明

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