s2l2.c

来自「德州仪器公司的6000系列的程序示例,可以看看实现什么功能,如果需要可以继续上传」· C语言 代码 · 共 45 行

C
45
字号
/*********************************************************************
 * S2L2.c - (Section 2, Lesson 2) READING AN INTEGER FROM THE TARGET
 *          This is the RTDX Target Code for Section 2, Lesson 2
 ********************************************************************/
 
#include <rtdx.h>       /* defines RTDX target API calls            */
#include "target.h"     /* defines TARGET_INITIALIZE()              */
#include <stdio.h>      /* C_I/O                                    */

/* This is the value we are going to send to the host               */
#define VALUE_TO_SEND 5

/* declare a global output channel                                  */
RTDX_CreateOutputChannel( ochan );
 
void main()
{
        int data = VALUE_TO_SEND;
        int status;

        TARGET_INITIALIZE();

        /* enable output channel                                    */
        RTDX_enableOutput( &ochan );

        /* send an integer to the host                              */
        status = RTDX_write( &ochan, &data, sizeof(data) );

        if ( status == 0 ) {
                puts( "ERROR: RTDX_write failed!\n" );
                exit( -1 );
        }

        while ( RTDX_writing != NULL ) {
#if RTDX_POLLING_IMPLEMENTATION
                RTDX_Poll();
#endif
        }

        /* disable the output channel                               */
        RTDX_disableOutput( &ochan );

        puts( "Program Complete!\n" );
}

⌨️ 快捷键说明

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