コード例 #1
0
ファイル: main.c プロジェクト: NBT-Analytics/Biosig
int bsv_start(void)
{
	int		i;
	_AIN	ain;
	_DIO	dio;

	fd	= GT_OpenDevice( c_get_devnode() );
	if( !fd ) {
		GT_TranslateErrorCode(&errstr, 0);
		return -1;
	}

	/* Analog channels */
	for(i=0, chanactivcnt=0; i<MAXCHANNUM-DCHANNUM; i++) {
		if( c_is_active(i) ) {
			chanactivcnt++;
		}
	}
	/* Digital channels */
	if( c_is_active(8) || c_is_active(9) ) {
		chanactivcnt++;
	}
	dchanmask	= ((c_is_active(8))?1:0)+((c_is_active(9))?2:0);

	ain.ain1	= (c_is_active(0)) ? TRUE : FALSE;
	ain.ain2	= (c_is_active(1)) ? TRUE : FALSE;
	ain.ain3	= (c_is_active(2)) ? TRUE : FALSE;
	ain.ain4	= (c_is_active(3)) ? TRUE : FALSE;
	ain.ain5	= (c_is_active(4)) ? TRUE : FALSE;
	ain.ain6	= (c_is_active(5)) ? TRUE : FALSE;
	ain.ain7	= (c_is_active(6)) ? TRUE : FALSE;
	ain.ain8	= (c_is_active(7)) ? TRUE : FALSE;

	if( c_is_active(8) || c_is_active(9) ) {
		dio.scan		= TRUE;
	} else {
		dio.scan		= FALSE;
	}
	dio.dio1_direction	= (c_is_active(8)) ? TRUE : FALSE;
	dio.dio2_direction	= (c_is_active(9)) ? TRUE : FALSE;

	if( !GT_InitChannels(fd, ain, dio) ) {
		GT_TranslateErrorCode(&errstr, 0);
		GT_CloseDevice(fd);
		fd	= 0;
		return -1;
	}

	if( !GT_StartAcquistion(fd) ) {
		GT_TranslateErrorCode(&errstr, 0);
		GT_CloseDevice(fd);
		fd	= 0;
		return -1;
	}

	state	= 0;

	return 0;
}
コード例 #2
0
ファイル: Usbamp.cpp プロジェクト: NeuralProsthesisLab/unlock
bool USBamp::init(const int ain, const int dio) {
	// activate analog and digital channels
	_AIN aCh;
	_DIO dCh;
	aCh.ain1 = ain & 0x01;
	aCh.ain2 = (ain >> 1) & 0x01;
	aCh.ain3 = (ain >> 2) & 0x01;
	aCh.ain4 = (ain >> 3) & 0x01;
	aCh.ain5 = (ain >> 4) & 0x01;
	aCh.ain6 = (ain >> 5) & 0x01;
	aCh.ain7 = (ain >> 6) & 0x01;
	aCh.ain8 = (ain >> 7) & 0x01;
	dCh.dio1_enable = dio & 0x01;
	dCh.dio2_enable = (dio >> 1) & 0x01;
	dCh.dio3_enable = (dio >> 2) & 0x01;
	dCh.dio4_enable = (dio >> 3) & 0x01;
	dCh.dio5_enable = (dio >> 4) & 0x01;
	dCh.dio6_enable = (dio >> 5) & 0x01;
	dCh.dio7_enable = (dio >> 6) & 0x01;
	dCh.dio8_enable = (dio >> 7) & 0x01;

	return GT_InitChannels(this->devptr, aCh, dCh);
}