📄 s2l9.c
字号:
/*********************************************************************
* S2L9.c - (Section 2, Lesson 9) REMOTE ENABLING AND DISABLING OF
* A CHANNEL
* This is the RTDX Target Code for Section 2, Lesson 9
********************************************************************/
#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 globla output channel */
RTDX_CreateOutputChannel( ochan );
void main()
{
int data = VALUE_TO_SEND;
int status;
TARGET_INITIALIZE();
/*
* Notice that we do not call: RTDX_enableOutput(&ochan)
*/
do {
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll();
#endif
} while ( !RTDX_isOutputEnabled(&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
}
/*
* Notice that we do not call: RTDX_disableOutput(&ochan)
*/
do {
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll();
#endif
} while ( RTDX_isOutputEnabled(&ochan) );
puts( "Program Complete!\n" );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -