Exemple #1
0
uint8_t
peek(int reg) 
{
	HIF deviceHandle;
	int status;
	char deviceName[32] = "Cr2s2";
	uint8_t data;
	
	status = DmgrOpen(&deviceHandle, deviceName);
	if (!status) {
		printf("Problem opening device, code %d\n", DmgrGetLastError());
		return 0;
	}

	status = DeppEnable(deviceHandle);
	if (!status) {
		printf("Problem enabling port 0, code %d\n", DmgrGetLastError());
		return 0;
	}
	
	DeppGetReg(deviceHandle, reg, &data, fFalse);

	status = DeppDisable(deviceHandle);
	if (!status) {
		printf("Problem disabling DEPP, code %d\n", DmgrGetLastError());
		return 0;
	}
	DmgrClose(deviceHandle);

	return data;
}
Exemple #2
0
void ErrorExit() {
	if (hif != hifInvalid) {

		// DEMC API Call: DemcDisable
		DemcDisable(hif);

		// DMGR API Call: DmgrClose
		DmgrClose(hif);
	}	

	exit(1);
}
Exemple #3
0
/***	ErrorExit
**
**	Parameters:
**		none
**
**	Return Value:
**		none
**
**	Errors:
**		none
**
**	Description:
**		Disables Dstm, closes the device, and exits the program
*/
void ErrorExit() {
	if(hif != hifInvalid) {

		// DSTM API Call: DstmDisable
		DstmDisable(hif);

		// DMGR API Call: DmgrClose
		DmgrClose(hif);
	}
	
	exit(1);
}
Exemple #4
0
/***	DoTerminate
**
**	Parameters:
**		none
**
**	Return Value:
**		none
**
**	Errors:
**		none
**
**	Description:
**		Successful program cleanup tasks
*/
void DoTerminate() {

	// DEMC API Call: DemcDisable
	DemcDisable(hif);
	
	// DMGR API Call: DmgrClose
	if (!DmgrClose(hif)) {
		hif = hifInvalid;
		printf("DmgrClose failed\n");
	}
	
	return;
}
int main(int cszArg, char * rgszArg[]) {
	fprintf(stderr,"Opening\n");

	if(!DmgrOpen(&hif, "Basys2")) {  
		printf("DmgrOpen failed (check the device name you provided)\n");
		return 0;
	}
	fprintf(stderr,"Enabling\n");

	if(!DeppEnable(hif)) {
		printf("DeppEnable failed\n");
		return 0;
	}
	fprintf(stderr,"Outputting\n");
	DoPutRegRepeat();

	if( hif != hifInvalid ) {
		DeppDisable(hif);
		DmgrClose(hif);
	}
	return 0;
}
Exemple #6
0
/***	main
**
**	Parameters:
**		none
**
**	Return Value:
**		none
**
**	Errors:
**		none
**
**	Description:
**		DstmDemo main
*/
int main(void) {
	int ibTx;

	// DMGR API Call: DmgrOpen
	if(!DmgrOpen(&hif, szDvc)) {
		printf("Error: Could not open device %s\n", szDvc);
		ErrorExit();
	}

	// DSTM API Call: DstmEnable
	if(!DstmEnable(hif)) {
		printf("Error: DstmEnable failed\n");
		ErrorExit();
	}
	

	/* Tranfer data into FPGA block ram using Dstm */
	// DSTM API Call: DstmIO
	if(!DstmIO(hif, rgbOut, cbTx, NULL, 0, fFalse)) {
		printf("Error: DstmIO failed\n");
		ErrorExit();
	}

	/* Retrieve data from FPGA block ram using Dstm */
	// DSTM API Call: DstmIO
	if(!DstmIO(hif, NULL, 0, rgbIn, cbTx, fFalse)) {
		printf("Error: DstmIO failed\n");
		ErrorExit();
	}


	// Verify that recieved data matches transmitted data
	for(ibTx=0; ibTx<cbTx; ibTx++) {
		if(rgbIn[ibTx] != rgbOut[ibTx]) {
			fFail = fTrue;  // Set fFail if data mismatched
		}
	}

	// Print results of test
	if(fFail) {
		printf("Error: Recieved data did not match transmitted data\n");
		for(ibTx=0; ibTx<cbTx; ibTx++) {
			printf("rgbOut[%d]: %d      rgbIn[%d]: %d\n", ibTx, rgbOut[ibTx], ibTx, rgbIn[ibTx]);
		}
	}
	else {
		printf("Success: Recieved data matched transmitted data\n");
	}
	
	// DSTM API Call: DstmDisable
	if(!DstmDisable(hif)) {
		printf("Error: DstmDisable failed\n");
		ErrorExit();
	}
	
	// DMGR API Call: DmgrClose
	if(!DmgrClose(hif)) {
		printf("Error: DmgrClose failed\n");
		ErrorExit();
	}

	return 0;
}