int16_rtdx.c

来自「matlab连接ccs的例子」· C语言 代码 · 共 44 行

C
44
字号
/* $Revision: 1.5 $ */
/* Copyright 2002 The MathWorks, Inc. */
/* RTDX tutorial target application: read from host and echo back */

#include <rtdx.h>						/* RTDX_Data_Read				*/
#include <stdio.h>						/* printf						*/
#include <target.h>						/* TARGET_INITIALIZE			*/

#define MAX 10   

short recvd[MAX];

RTDX_CreateInputChannel(ichan);			/* Channel to receive data from */   
RTDX_CreateOutputChannel(ochan);		/* Channel to use to write data */

void main( void )
{
	int i,j;  

	TARGET_INITIALIZE();				/* target specific RTDX init	*/
    
    while ( !RTDX_isInputEnabled(&ichan) ) 
      { RTDX_Poll(); }
	RTDX_read( &ichan, recvd, sizeof(recvd) );	
                  
    for (j=1; j<=20; j++) {
      for (i=0; i<MAX; i++) {
        recvd[i] +=1;
      }
      while ( !RTDX_isOutputEnabled(&ochan) ) 
        { RTDX_Poll();}            	
	  RTDX_write( &ochan, recvd, sizeof(recvd) );
  	  while ( RTDX_writing != NULL ) 
  	    { RTDX_Poll(); }    
	}
		
	while ( RTDX_isInputEnabled(&ichan) || RTDX_isOutputEnabled(&ochan) ) 
	  { RTDX_Poll(); }
    while (1) {}
}                



⌨️ 快捷键说明

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