?? s1l4.c
字號(hào):
/*********************************************************************
* S1L4.c - (Section 1, Lesson 4) RECEIVING AN INTEGER FROM THE HOST
* ASYNCHRONOUSLY
* This is the RTDX Target Code for Section 1, Lesson 4
*
* This example receives integer value 5 from the host
********************************************************************/
#include <rtdx.h> /* defines RTDX target API calls */
#include "target.h" /* defines TARGET_INITIALIZE() */
#include <stdio.h> /* C_I/O */
/* declare a global input channel */
RTDX_CreateInputChannel( ichan );
void main()
{
int data;
int status;
TARGET_INITIALIZE();
/* enable the input channel */
RTDX_enableInput( &ichan );
/*************************************************************
* Insert code from Step #2 here - to request an integer
************************************************************/
status = RTDX_readNB( &ichan, &data, sizeof(data) );
if ( status != RTDX_OK ) {
printf( "ERROR: RTDX_readNB failed!\n" );
exit( -1 );
}
status = 1;
while ( status ) {
/*************************************************************
* Insert code from Step #3 here - to loop until channel
* is no longer busy waiting
* to receive data
************************************************************/
status = RTDX_channelBusy( &ichan );
/*
* useful processing can be done here while waiting
* for data
*/
#if RTDX_POLLING_IMPLEMENTATION
/*
* if RTDX uses polling on this target, then be sure
* to call it regulary to transfer the data
*/
RTDX_Poll();
#endif
}
/*************************************************************
* Insert code from Step #4 here - to verify that we have
* received all the requested
* data
************************************************************/
status = RTDX_sizeofInput( &ichan );
if ( status != sizeof(data) )
printf( "ERROR: Did not receive all the data!\n" );
else
printf( "Value %d was received from the host\n", data );
/* disable the input channel */
RTDX_disableInput( &ichan );
printf( "Program Complete!\n" );
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -