📄 h2t.c
字号:
/********************************************************************* * FILENAME: $RCSfile: h2t.c,v $ * VERSION : $Revision: 1.1 $ * DATE : $Date: 2000/12/21 20:36:04 $ * Copyright (c) 1997-2000 Texas Instruments Incorporated * * Host-To-Target Test: *____________________________________________________________________ * - Reads 100 integers, one at a time, via RTDX_read(). * - Uses ONE input channel, and ONE output channel to report the * result. * * - Tests Data transmission from host to target at the User layer. * - This is the module to be run on the TARGET. * - This program is meant to be used with the RTDX Diagnostics * Control's Host-To-Target test option. ********************************************************************/#include <stdio.h> /* fprintf(), puts() */#include <stdlib.h> /* abort() */#include <rtdx.h> /* RTDX */#include "target.h" /* TARGET_INITIALIZE() */#define ITERATIONS 100typedef enum {FALSE,TRUE} BOOL;/* Declare and initialize an: * input channel called "ichan" * output channel called "results" */RTDX_CreateInputChannel(ichan);RTDX_CreateOutputChannel(results);void main( void ){ BOOL error = FALSE; /* Assume false until error occurs */ BOOL first_time = TRUE; /* Indicate first read */ int recvd=0; /* Data received */ int last_recvd=0; /* Last data received */ unsigned int i; /* Loop counter */ /* Target initialization for RTDX */ TARGET_INITIALIZE(); /* Enable the channels */ RTDX_enableInput(&ichan); RTDX_enableOutput(&results); for ( i = 0; i < ITERATIONS; i++ ) { /* Initialize data received to validate change */ recvd = 0; /* Request an integer from the host */ RTDX_read( &ichan, &recvd, sizeof(recvd) ); /* Set flag for first read */ if ( first_time ) first_time = FALSE; else { /* Validate sequential data */ if ( recvd != last_recvd + 1) { fprintf(stderr, "\nError: Unexpected Data!\n" \ "Received %i, Expected %i\n", recvd, last_recvd); error = TRUE; break; } } /* Display what was read in the stdout * window */ fprintf(stdout, "Value %i was read from the host\n", recvd); last_recvd = recvd; } /* Send test result to the host */ RTDX_write( &results, &error, sizeof(error) ); /* Wait for data transfer */ while ( RTDX_writing != NULL ) { #if RTDX_POLLING_IMPLEMENTATION /* Call Poll to do data transfer */ RTDX_Poll(); #endif } /* Disable the channels */ RTDX_disableInput(&ichan); RTDX_disableOutput(&results); puts("\nTest Completed "); if ( !error ) puts("Successfully!"); else puts("with Errors!");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -