亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? dscadscanint.c

?? PC/104擴展模塊DIAMOND-MM-16-AT驅動程序
?? C
字號:
//=============================================================================
// (c) Copyright 2005 Diamond Systems Corporation. Use of this source code
// is subject to the terms of Diamond Systems' Software License Agreement.
// Diamond Systems provides no warranty of proper performance if this
// source code is modified.
//
// File: DSCADScanInt.c	  v5.9
// Desc: Sample program that demonstrates how to perform an interrupt-based AD
//       scan
// Created by  KL
//=============================================================================

#include <stdio.h>

#ifdef _WIN32
#ifndef _WIN32_WCE
#include <conio.h>
#endif

#include <windows.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
// diamond driver includes
#include "dscud.h"
#endif


#ifdef _WIN32_WCE

#include <string.h>
#include <Winsock2.h>

static int kbhit()
{
	int i;
	int result=0;

	
	result |= GetAsyncKeyState(VK_RETURN);
	result |= GetAsyncKeyState(VK_SPACE);

	if (result != 0)
	{
		getchar();
		return 1;
	}

	//number keys, 0-9
	for (i=48; i<=57; i++)
		result |= GetAsyncKeyState(i);

	if (result != 0)
	{
		getchar();
		return 1;
	}

	//capital character keys, A-Z
	for (i=65; i<=90; i++)
		result |= GetAsyncKeyState(i);

	if (result != 0)
	{
		getchar();
		return 1;
	}

	//lower case keys, a-z
	for (i=97; i<=122; i++)
		result |= GetAsyncKeyState(i);

	if (result != 0)
	{
		getchar();
		return 1;
	}

	return result;
}

#endif


// DOS
#ifdef __BORLANDC__
#include <conio.h>
#include <dos.h>
#include <stdlib.h>
#include <math.h>
#include <mem.h>
// diamond driver includes
#include "../../../../current/dev/source/dscud.h"
#endif

// Linux and QNX
#if defined(linux) || defined(__QNXNTO__) || defined(_WRS_VXWORKS_5_X)
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
// diamond driver includes
#include "dscud.h"


#ifdef _WRS_VXWORKS_5_X
#include <selectLib.h>
#define main DMM16ATDSCADScanInt
#else
#include <sys/time.h>
#endif

static int kbhit()
{
	struct timeval timeout;
	fd_set rfds;

	timeout.tv_sec = 0;
	timeout.tv_usec = 0;

	FD_ZERO(&rfds);
	FD_SET(0, &rfds);

	if ( select(0+1, &rfds, NULL, NULL, &timeout) > 0 )
		return getchar();

	return 0;
}
#endif

// macros defined
#define SLEEP_TIME 1000

// var declarations
BYTE result;   // returned error code
DSCB dscb;     // handle used to refer to the board
DSCCB dsccb;   // structure containing board settings
DSCS dscs;     // structure containing interrupt-based sampling status information
DFLOAT voltage; // actual voltage
DSCAIOINT dscaioint;         // structure containing I/O interrupt settings
DSCADSETTINGS dscadsettings; // structure containing A/D conversion settings
ERRPARAMS errorParams;       // structure for returning error code and error string
int intBuff;     // temp variable of size int
long longBuff;   // temp variable of size long
float floatBuff; // temp variable of size float
int i;           // miscellaneous counter

//=============================================================================
// Name: main()
// Desc: Starting function that calls the driver functions used
//
//		 NOTE: By convention, you should capture the BYTE return value for each
//		 driver API call, and check the error code.
//
//     STEPS TO FOLLOW:
//
//	     I. Driver Initialization
//	    II. Board Initialization
//	   III. AD Settings Initialization
//		IV. I/O Interrupt Settings Initialization
//	     V. Sampling and Output
//	    VI. Cleanup
//
//=============================================================================

int main( void )
{
	//=========================================================================
	// I. DRIVER INITIALIZATION
	//
	//    Initializes the DSCUD library.
	//
	//    STEPS TO FOLLOW:
	//
	//	  1. initialize the driver, using the driver version for validation
	//=========================================================================

	if( dscInit( DSC_VERSION ) != DE_NONE )
	{
		dscGetLastError(&errorParams);
		fprintf( stderr, "dscInit error: %s %s\n", dscGetErrorString(errorParams.ErrCode), errorParams.errstring );
		return 0;
	}

	//=========================================================================
	// II. BOARD INITIALIZATION
	//
	//	   Initialize the DMM-16-AT board. This function passes the various
	//	   hardware parameters to the driver and resets the hardware.
	//
	//     STEPS TO FOLLOW:
	//
	//	   1. set the board type to DSC_DMM16AT for DMM-16-AT board
	//	   2. set the base address (must be between 0x220-0x3E0)
	//	   3. set the interrupt level (must be between 3-15)
	//	   4. intialize and register the board with the driver, after which
	//		  the struct, dscb, now holds the handle for the board
	//=========================================================================

	printf( "\nDMM16AT BOARD INITIALIZATION:\n" );

	printf("Enter the base address (default 0x300) : ");
	scanf( "%hx", &dsccb.base_address );

	printf("Enter the interrupt level (3-15) : ");
	scanf("%d", &intBuff);
	dsccb.int_level = (BYTE) intBuff;

	if(dscInitBoard(DSC_DMM16AT, &dsccb, &dscb)!= DE_NONE)
	{
		dscGetLastError(&errorParams);
		fprintf( stderr, "dscInitBoard error: %s %s\n", dscGetErrorString(errorParams.ErrCode), errorParams.errstring );
		return 0;
	}

	//=========================================================================
	// III. AD SETTINGS INITIALIZATION
	//
	//	    Initialize the structure containing the AD conversion settings and
	//		then pass it to the driver.
	//
	//      STEPS TO FOLLOW:
	//
	//		1. set the range (must be RANGE_5, RANGE_10)
	//		2. set the polarity (must be BIPOLAR or UNIPOLAR)
	//		3. set the gain (must be GAIN_1, GAIN_2, GAIN_4, or GAIN_8)
	//		4. set the load calibration settings flag
	//		5. set the current channel to be sampled (must be between 0-15)
	//		6. initialize the AD conversion with these settings
	//=========================================================================

	/* PRE-FILLED EXAMPLE
	dscadsettings.range = RANGE_10;
	dscadsettings.polarity = BIPOLAR;
	dscadsettings.gain = GAIN_1;
	dscadsettings.load_cal = (BYTE)TRUE;
	dscadsettings.current_channel = 0;
	*/

	printf( "\nAD SETTINGS INITIALIZATION\n" );

	memset(&dscadsettings, 0, sizeof(DSCADSETTINGS));

	printf( "Enter the range (0 for 5V range, 1 for 10V range): " );
	scanf("%d", &intBuff);
	dscadsettings.range = (BYTE) intBuff;

	printf( "Enter the polarity (0 for BIPOLAR, 1 for UNIPOLAR): " );
	scanf("%d", &intBuff);
	dscadsettings.polarity = (BYTE) intBuff;

	printf( "Enter the gain (0 for GAIN 1, 1 for GAIN 2, 2 for GAIN 4, 3 for GAIN 8): " );
	scanf("%d", &intBuff);
	dscadsettings.gain = (BYTE) intBuff;

	printf( "Enter the load calibration flag (0 for FALSE, 1 for TRUE): " );
	scanf("%d", &intBuff);
	dscadsettings.load_cal = (BYTE) intBuff;

	dscadsettings.current_channel = 0;

	if( ( result = dscADSetSettings( dscb, &dscadsettings ) ) != DE_NONE )
	{
		dscGetLastError(&errorParams);
		fprintf( stderr, "dscADSetSettings error: %s %s\n", dscGetErrorString(errorParams.ErrCode), errorParams.errstring );
		return 0;
	}

	//=========================================================================
	// IV. I/O INTERRUPT SETTINGS INITIALIZATION
	//
	//	   Initialize the structure containing the analog I/O interrupt
	//	   settings.
	//
	//	   NOTE: You must allocate space for the buffer holding the returned
	//		     sample values. Also, be generous in allocating storage.
	//			 Allocating insufficient memory to hold sample data will result
	//			 in improper behavior of the driver, such as hanging interrupt
	//			 operations or assertion errors.
	//
	//     STEPS TO FOLLOW:
	//
	//	   1. set the number of conversions (must be a multiple of the fifo
	//		  depth)
	//	   2. set the conversion rate (must be less than 100 kHz)
	//	   3. set the cycle flag
	//	   4. set the internal clock flag
	//	   5. set the low channel (must be between 0-15)
	//	   6. set the high channel (must be between 0-15)
	//	   7. set the external gate enable flag
	//	   8. set the internal clock gate flag
	//	   9. set the fifo enable flag
	//	   10. set the fifo depth (must be 256)
	//	   11. allocate memory for the sample values
	//=========================================================================

	/* PRE-FILLED EXAMPLE
	dscaioint.num_conversions = 1024;
	dscaioint.conversion_rate = 1000;
	dscaioint.cycle = (BYTE)FALSE;
	dscaioint.internal_clock = (BYTE)TRUE;
	dscaioint.low_channel = 0;
	dscaioint.high_channel = 3;
	dscaioint.external_gate_enable = (BYTE)FALSE;
	dscaioint.internal_clock_gate = (BYTE)FALSE;
	dscaioint.fifo_enab = (BYTE)TRUE;
	dscaioint.fifo_depth = 256;
	dscaioint.dump_threshold = 256;
	*/

	printf( "\nI/O INTERRUPT SETTINGS INITIALIZATION\n" );

	memset(&dscaioint, 0, sizeof(DSCAIOINT));

	printf( "Enter the number of conversions (must be a multiple of FIFO depth) : " );
	scanf("%ld", &longBuff);
	dscaioint.num_conversions = (DWORD) longBuff;

	printf( "Enter the conversion rate in Hz (must be less than 100000) : " );
	scanf("%f", &floatBuff);
	dscaioint.conversion_rate = (FLOAT) floatBuff;

	printf( "Enter the cycle flag (0 for FALSE, 1 for TRUE) : " );
	scanf("%d", &intBuff);
	dscaioint.cycle = (BOOL) intBuff;

	printf( "Enter the internal clock flag (0 for FALSE, 1 for TRUE) : " );
	scanf("%d", &intBuff);
	dscaioint.internal_clock  = (BOOL) intBuff;

	printf( "\nThe range of the lowest and highest channel must follow the formula of\n(1+highestChannel-lowestChannel) = multiple of numb conversions\n");
	printf( "Enter the lowest channel in the scan range (0-15) : " );
	scanf("%d", &intBuff);
	dscaioint.low_channel = (BYTE) intBuff;

	printf( "Enter the highest channel in the scan range (0-15) : " );
	scanf("%d", &intBuff);
	dscaioint.high_channel = (BYTE) intBuff;

	dscaioint.external_gate_enable = 0; // can enable it if need be

	dscaioint.internal_clock_gate = 0;   // can enable it if need be

	printf( "Enter the FIFO enable flag (0 for FALSE, 1 for TRUE) : " );
	scanf("%d", &intBuff);
	dscaioint.fifo_enab = (BOOL) intBuff;

	dscaioint.fifo_depth = 256;

	printf("Enter the dump threshold ( must be less or equal to num conversions ) : ");
	scanf("%ld", &longBuff);
	dscaioint.dump_threshold = longBuff;

	dscaioint.sample_values = (DSCSAMPLE*)malloc( sizeof(DSCSAMPLE) * dscaioint.num_conversions);

	getchar();

   	//=========================================================================
	// V. SCANNING AND OUTPUT
	//
	//    Perform the actual sampling and then output the results. To calculate
	//	  the actual input voltages, we must convert the sample code (which
	//	  must be cast to a short to get the correct code) and then plug it
	//	  into one of the formulas located in the manual for your board (under
	//	  "A/D Conversion Formulas"). For example, if you are using a bipolar
	//	  input range and 32-bit signed integers:
	//
	//	  Input voltage = (AD Code / 32768) x Full-Scale Voltage
	//
	//	  For interrupt-based scanning, we perform scan several channels per
	//	  interrupt.
	//
	//    STEPS TO FOLLOW:
	//
	//	  1. reset the number of transfers to 0
	//	  2. set the operation type to interrupt-based
	//	  3. wait for the board to signal that the operation has finished
	//    4. get the samples from the board
	//    5. convert the results to a signed short to obtain a readout from
	//       -32768 to +32767 which scales to a range from -10V to +10V and
	//	     output the sample codes and the actual voltages to console
	//    6. calculate the input voltages by converting the sample code and
	//		 output the results
	//	  7. repeat steps 1-6 until a key is pressed
	//=========================================================================

	printf( "\nSAMPLING AND OUTPUT\n" );

	do
	{
		if( ( result = dscADScanInt( dscb, &dscaioint ) ) != DE_NONE )
		{
			dscGetLastError(&errorParams);
			fprintf( stderr, "dscADScanInt error: %s %s\n", dscGetErrorString(errorParams.ErrCode), errorParams.errstring );
			free( dscaioint.sample_values ); // remember to deallocate malloc() memory
			return 0;
		}

		dscs.transfers = 0;
		dscs.overflows = 0;
		dscs.op_type = OP_TYPE_INT;
	
		do{
			dscSleep(SLEEP_TIME);
			dscGetStatus(dscb,&dscs);
			printf("Buffer Overflow %lu, A/D Int Trans in progress: %lu Total trans %lu\n", dscs.overflows, dscs.transfers, dscs.total_transfers);
		}while (dscs.op_type != OP_TYPE_NONE && !kbhit());

		
		// cancel interrupts manually for recycled mode or if interrupts are still running
		if( dscs.op_type != OP_TYPE_NONE)
		{
			if( (result = dscCancelOp(dscb)) != DE_NONE)
			{
				dscGetLastError(&errorParams);
				fprintf( stderr, "dscCancelOp error: %s %s\n", dscGetErrorString(errorParams.ErrCode), errorParams.errstring );
				free( dscaioint.sample_values ); // remember to deallocate malloc() memory
				return 0;
			}
		}

		printf( "\nSample readouts:" );

		for( i = 0; i < (dscaioint.high_channel-dscaioint.low_channel + 1); i++)
			printf( " %hd", dscaioint.sample_values[i] );

		printf( "\n\nActual voltages:" );

		for( i = 0; i < (dscaioint.high_channel-dscaioint.low_channel + 1); i++)
		{
			if( dscADCodeToVoltage(dscb, dscadsettings, dscaioint.sample_values[i], &voltage) != DE_NONE)
			{
				dscGetLastError(&errorParams);
				fprintf( stderr, "dscADCodeToVoltage error: %s %s\n", dscGetErrorString(errorParams.ErrCode), errorParams.errstring );
				free(dscaioint.sample_values);
				return 0;
			}

			printf(" %5.3lfV", voltage);
		}

		printf( "\n" );
		printf("Enter 'q' to exit, any key to continue\n");
	}
	while (getchar() != 'q' );
	
	//=========================================================================
	// VI. CLEANUP
	//
	//	   Cleanup any remnants left by the program and free the resources used
	//	   by the driver.
	//
	//     STEPS TO FOLLOW:
	//
	//	   1. free the memory allocated for sample values
	//	   2. free the driver resources
	//=========================================================================

	free( dscaioint.sample_values );

	dscFree();

	printf( "\nDSCADScanInt completed. \n" );

	return 0;
} // end main()


#ifdef _WIN32_WCE
int WINAPI WinMain(	HINSTANCE hInstance,
					HINSTANCE hPrevInstance,
					LPTSTR    lpCmdLine,
					int       nCmdShow)
{
	printf("For users running cycled mode: to EXIT, hold down the 'q' key\n");
	printf("on the keyboard then press 'Enter' when 'q' letters appear on screen\n\n");
	main();

	return 0;
}

#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合久久久久综合99| 亚洲h精品动漫在线观看| 欧美日韩激情一区二区| 97精品电影院| 99国产麻豆精品| 色悠久久久久综合欧美99| 99视频有精品| 欧美探花视频资源| 91.com视频| 欧美国产精品专区| 亚洲国产综合人成综合网站| 五月综合激情婷婷六月色窝| 天天影视涩香欲综合网| 国产在线日韩欧美| 波多野结衣91| 欧美精品日韩一区| 久久久久久久久岛国免费| 一区二区三区不卡视频| 久久成人av少妇免费| av成人老司机| 日韩三级视频在线观看| 精品国产乱码久久久久久图片| 色婷婷一区二区三区四区| 日韩午夜av电影| 亚洲精品中文在线影院| 久久精品国产一区二区三| 色呦呦网站一区| 久久久精品影视| 秋霞电影网一区二区| 91蝌蚪porny| 中文字幕欧美区| 精品在线播放午夜| 91精品欧美久久久久久动漫| 亚洲丝袜制服诱惑| 成人免费精品视频| 国产日韩亚洲欧美综合| 美女视频黄a大片欧美| 欧美理论电影在线| 一区二区三区在线免费播放| 七七婷婷婷婷精品国产| 日韩欧美一级二级| 日本女人一区二区三区| 欧美美女网站色| 日韩精品免费专区| 91麻豆精品久久久久蜜臀| 亚洲码国产岛国毛片在线| av成人免费在线| 亚洲视频在线一区二区| 94色蜜桃网一区二区三区| 2024国产精品| 亚洲国产欧美在线人成| 2021国产精品久久精品| 欧美日韩在线电影| 亚洲美女区一区| av电影在线观看一区| 日韩理论在线观看| 91福利在线观看| 五月天一区二区| 69久久99精品久久久久婷婷| 麻豆91精品视频| 国产日韩成人精品| 色婷婷精品久久二区二区蜜臂av| 国产视频视频一区| 欧美一区二区三区的| 99久久久精品| 国产精品亚洲人在线观看| 午夜在线电影亚洲一区| 国产精品人妖ts系列视频| 欧美一级生活片| 91高清在线观看| 91在线你懂得| 国产 欧美在线| 国产毛片精品视频| 久久爱www久久做| 日本特黄久久久高潮| 中文字幕一区二区视频| 欧美国产成人精品| 久久先锋影音av鲁色资源网| 7777精品伊人久久久大香线蕉超级流畅| 国产激情精品久久久第一区二区| 日本不卡一二三| 男男视频亚洲欧美| 免费在线一区观看| 日韩和欧美的一区| 日韩国产欧美在线播放| 亚洲国产裸拍裸体视频在线观看乱了| 中文字幕日本不卡| 一区二区在线观看视频 | 日韩一级黄色大片| 欧美浪妇xxxx高跟鞋交| 91精品婷婷国产综合久久性色| 91欧美一区二区| 欧美精品乱码久久久久久| 日韩一区二区在线观看| 精品成人在线观看| 亚洲啪啪综合av一区二区三区| 亚洲视频香蕉人妖| 天天操天天干天天综合网| 蜜臀av一级做a爰片久久| 国产电影一区在线| 在线观看三级视频欧美| 久久亚洲捆绑美女| 一区二区三区美女| 激情六月婷婷综合| 欧美在线观看一区| 国产精品免费av| 另类的小说在线视频另类成人小视频在线 | 国产精品久久99| 美日韩一级片在线观看| 开心九九激情九九欧美日韩精美视频电影| 美女视频黄a大片欧美| 99久久精品一区二区| 久久久久99精品国产片| 午夜精品久久久久久不卡8050| 激情文学综合丁香| 欧美精品在线一区二区三区| 中文字幕在线一区免费| 美腿丝袜在线亚洲一区| 欧美专区在线观看一区| 亚洲人吸女人奶水| 成人网男人的天堂| 最好看的中文字幕久久| 粉嫩欧美一区二区三区高清影视 | 久久国产欧美日韩精品| 欧美日韩黄色一区二区| 亚洲色图制服丝袜| 处破女av一区二区| 中文一区二区完整视频在线观看| 免费在线观看精品| 欧美三级视频在线播放| 一区二区三区欧美在线观看| 在线播放91灌醉迷j高跟美女| 欧美情侣在线播放| 国产精品入口麻豆原神| 欧美aa在线视频| 99re6这里只有精品视频在线观看| 色婷婷综合久色| 日韩一区日韩二区| 国产高清亚洲一区| 日韩三级av在线播放| 国产精品一级二级三级| 亚洲一区二区在线视频| 日韩久久久精品| 91免费观看在线| 蜜臀av一区二区在线免费观看| 欧美激情一区二区三区蜜桃视频| 色噜噜狠狠成人网p站| 久久精品国产第一区二区三区| 日韩毛片高清在线播放| 欧美一二三在线| 在线观看一区二区精品视频| 蜜桃av一区二区三区电影| 国产精品水嫩水嫩| 日韩精品一区二区三区蜜臀| av在线综合网| 国产成人精品一区二区三区四区 | 色哟哟一区二区三区| 国产成人免费av在线| 蜜臀久久99精品久久久画质超高清 | 国产精品灌醉下药二区| 日韩一区二区三区在线观看| 色婷婷av一区二区三区软件| 成人禁用看黄a在线| 国产一区二区福利视频| 免费成人深夜小野草| 偷拍亚洲欧洲综合| 首页亚洲欧美制服丝腿| 亚洲激情自拍视频| 美国十次综合导航| 91黄色免费看| 亚洲一二三区不卡| 亚洲成人午夜影院| 久久精品国产在热久久| 亚洲精品国产精华液| 精品国产伦理网| 91蜜桃免费观看视频| 久久综合色鬼综合色| 一区二区三区在线视频观看| 久久精品国产亚洲a| 欧美精品在线观看一区二区| 国产精品午夜在线| 国产精品白丝jk黑袜喷水| 欧美日韩不卡在线| 亚洲动漫第一页| 在线免费观看视频一区| 国产精品系列在线| 国产成人av电影在线| 欧美不卡视频一区| 中文字幕一区二区日韩精品绯色| 久久精品国产久精国产| 日韩免费视频线观看| 日韩激情视频网站| 欧美猛男gaygay网站| 日韩不卡一区二区三区 | 久久精品国产澳门| 91精品国产一区二区三区香蕉| 怡红院av一区二区三区| 91国偷自产一区二区三区观看| 国产精品视频免费看| k8久久久一区二区三区|