📄 t_rdsa.c
字号:
/*************************************************************************
* FILENAME: $RCSfile: t_rdsa.c,v $
* VERSION : $Revision: 1.2 $
* DATE : $Date: 2000/11/03 19:17:13 $
* Copyright (c) 1997-2000 Texas Instruments Incorporated
*
* Target Read (for SAFEARRAYS) Example:
*____________________________________________________________________
* - Read an array of 5 integers, 100 times, via RTDX_read().
* - Uses ONE input channel
*
* - This is the module to be run on the TARGET.
* - This program is meant to be used with the RTDX Excel project's
* VBA module h_wrtsa().
*************************************************************************/
#include <stdio.h> /* fprintf(), puts() */
#include <stdlib.h> /* abort() */
#include <rtdx.h> /* RTDX */
#include "target.h" /* TARGET_INITIALIZE() */
#define MAX_MESSAGES 100
#define MAX_ELEMENTS 5
/* Declare and initialize an input channel called "ichan" */
RTDX_CreateInputChannel(ichan);
#ifdef HSRTDX
// Silicon HSRTDX workaround...
// - User must define extra 32bit word AFTER all Host-to-target receive
// buffers.
#ifdef _TMS320C6X
#pragma DATA_ALIGN(recvd,4)
int recvd[MAX_ELEMENTS+1];
#define RCVD_SIZE (sizeof(recvd)-sizeof(recvd[0]))
#elif defined(__TMS320C55X__)
int recvd[MAX_ELEMENTS+3];
#pragma DATA_ALIGN(recvd,2)
#define RCVD_SIZE (sizeof(recvd)-(2*sizeof(recvd[0])))
#else
#error "Unknown how to use Dummy word for this target."
#endif
#else
int recvd[MAX_ELEMENTS];
#define RCVD_SIZE (sizeof(recvd))
#endif
void main()
{
unsigned int i;
/* Target Specific Initialization */
TARGET_INITIALIZE();
/* Enable the channel, "ichan" */
RTDX_enableInput(&ichan);
puts("Recieving data from the Host...");
for ( i = 0; i < MAX_MESSAGES; i++ ) {
if ( (RTDX_read( &ichan, recvd, RCVD_SIZE )) !=
RCVD_SIZE ) {
fprintf(stderr,
"\nError: RTDX_read() failed\n");
abort();
}
}
/* Disable the channel, "ichan" */
RTDX_disableInput(&ichan);
puts("\nProgram Completed!");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -