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

📄 t_wrtsa.c

📁 dsp6713开发板的许多例程.对入门特别有用
💻 C
字号:
/*************************************************************************
* FILENAME: $RCSfile: t_wrtsa.c,v $
* VERSION : $Revision: 1.2 $
* DATE    : $Date: 2000/11/03 19:17:28 $
* 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 Specific Initialization                                   */
    TARGET_INITIALIZE();
    
    /* Enable the output channel, "ochan"                               */
    RTDX_enableOutput(&ochan);
    
    printf("Sending %d Messages to Host of size %d...\n", 
        MAX_MESSAGES, MAX_ELEMENTS);
    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 Target-to-Host transfer to complete                 */
        while ( RTDX_writing != NULL ) {
#if RTDX_POLLING_IMPLEMENTATION
            /* If polling implementation of RTDX...                     */
            /* ...call RTDX_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 + -