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

📄 s2l6.c

📁 德州仪器公司的6000系列的程序示例,可以看看实现什么功能,如果需要可以继续上传,配套有电子版说明
💻 C
字号:
/*********************************************************************
 * 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -