s2l6.c

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

C
60
字号
/*********************************************************************
 * S2L6.c - (Section 2, Lesson 6) READING DATA FROM MULTIPLE CHANNELS
 *          This is the RTDX Target Code for Section 2, Lesson 6
 ********************************************************************/
 
#include <rtdx.h>       /* defines RTDX target API calls            */
#include "target.h"     /* defines TARGET_INITIALIZE()              */
#include <stdio.h>      /* C_I/O                                    */

#define NUMBER_OF_OCHANS 3

/* declare 3 global output channels: ochan1, ochan2, ochan3         */
RTDX_CreateOutputChannel( ochan1 );
RTDX_CreateOutputChannel( ochan2 );
RTDX_CreateOutputChannel( ochan3 );
  
void main()
{
        /* declare an array of output channel pointers              */
        RTDX_output_channel *pchans[NUMBER_OF_OCHANS];

        int i,j=1,status;

        /*
         * assign the array of channel pointers point to each
         * declared channel
         */
        pchans[0] = &ochan1;
        pchans[1] = &ochan2;
        pchans[2] = &ochan3;

        TARGET_INITIALIZE();
        /* enable all of the channels                               */
        for ( i = 0; i < (sizeof(pchans) / sizeof(pchans[0]-1) ); i++)
                RTDX_enableOutput( pchans[i] );

        for (i = (sizeof(pchans) / sizeof(pchans[0]-1) ) - 1; i >= 0; i--) {
                /* send an integer to the host via each channel     */
                status = RTDX_write( pchans[i], &j, sizeof(j) );
                j++;

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

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

	/* disable all of the channels                              */
        for (i = 0; i < (sizeof(pchans) / sizeof(pchans[0]-1) ); i++)
                RTDX_disableOutput( pchans[i] );

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

⌨️ 快捷键说明

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