s2l4.cpp

来自「TMS320c6000系列dsp软件模拟器在集成开发环境CCS中应用实例」· C++ 代码 · 共 67 行

CPP
67
字号
//####################################################################

// S2L4.cpp - (Section 2, Lesson 4) SENDING AN INTEGER TO THE TARGET

//            This is the RTDX Host Client for Section 2, Lesson 4

//

// This example sends integer value 5 to the target

//####################################################################



#import "..\..\..\..\..\cc\bin\rtdxint.dll"

#include <iostream.h>





#define VALUE_TO_SEND 5



using namespace RTDXINTLib;



int main()

{

        IRtdxExpPtr rtdx;               // holds pointer to IRtdxExp interface

        long status;                    // holds status of RTDX COM API calls

        HRESULT hr;                     // holds status of generic COM API calls

        long data=VALUE_TO_SEND;        // holds data to be sent to target

        long bufferstate;               // holds the state of the host's write buffer



        // initialize COM

        ::CoInitialize( NULL );



        // instantiate the RTDX COM Object

        hr = rtdx.CreateInstance( L"RTDX" );



        cout.setf( ios::showbase );



        if ( FAILED(hr) ) {

                cerr << hex << hr << " - Error: Instantiation failed! \n";

                return -1;

        }



        // open a channel (ichan) for writing

        status = rtdx->Open( "ichan", "W" );



        if ( status != Success ) {

                cerr << hex << status \

                     << " -  Error: Opening of channel \"ichan\" failed! \n";

                return -1;

        }



        // send a 32-bit integer to the target

        rtdx->WriteI4( data, &bufferstate );



        if ( status != Success ) {

                cerr << hex << status << " - Error: WriteI4 failed!\n";

                return -1;

        }



        cout << "Value " << data << " was sent to the target!\n";



        // close the channel

        status = rtdx->Close();



        // release the RTDX COM Object

        rtdx.Release();



        // unitialize COM

        ::CoUninitialize();



        return 0;

}

⌨️ 快捷键说明

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