📄 t_wrtsa.c
字号:
/********************************************************************* * FILENAME: $RCSfile: t_wrtsa.c,v $ * VERSION : $Revision: 1.8 $ * DATE : $Date: 2001/12/05 20:10:47 $ * Copyright (c) 1997-2000 Texas Instruments Incorporated * * Target Write (for SAFEARRAYS) Example: *____________________________________________________________________ * - Sends an array of 5 integers, 100 times, via RTDX_write(). * - Uses ONE output 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_rdsa(). ********************************************************************/#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 output channel called "ochan" */RTDX_CreateOutputChannel(ochan);void main(){ unsigned int x = 0, y = 0, last = 0; int message[MAX_ELEMENTS]; /* Target initialization for RTDX */ TARGET_INITIALIZE(); /* Enable the output channel, "ochan" */ RTDX_enableOutput(&ochan); for ( x = 0; x < MAX_MESSAGES; x++ ) { /* Build the array */ for ( y = last; y < (last + MAX_ELEMENTS); y++ ) { if ( y == 0 ) message[0] = 0; else message[y % MAX_ELEMENTS] = y; } last = y; /* Send the data to the host */ if (!RTDX_write( &ochan, message, sizeof(message) ) ) { fprintf(stderr, "\nError: RTDX_write() failed!\n"); abort(); } /* Wait for data transfer */ while ( RTDX_writing != NULL ) { #if RTDX_POLLING_IMPLEMENTATION /* Call Poll to do data transfer */ RTDX_Poll(); #endif } } /* Disable the output channel, "ochan" */ RTDX_disableOutput(&ochan); puts("\nProgram Completed!");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -