Example #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;
}
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;
}
Example #3
0
/***	FInit
**
**	Parameters:
**		none
**
**	Return Value:
**		none
**
**	Errors:
**		none
**
**	Description:
**		Performs program initialization tasks
*/
bool FInit() {
	/* Open the device, find out how many DEMC ports there are and
	** then get their properties.*/
	// DMGR API Call: DmgrOpen
	if (!DmgrOpen(&hif, szDUT)) {
		printf("Unable to open device: %s\n", szDUT);
		return false;
	}	

	// DEMC API Call: DemcGetPortCount
	if (!DemcGetPortCount(hif, &cprt)) {
		printf("DemcGetPortCount failed\n");
		return false;
	}
	else {
		printf("  DEMC port count: %d\n", cprt);
	}

	/* For each port, get and report the port properties.
	*/
	for (iprt = 0; iprt < cprt; iprt++) {
		// DEMC API Call: DemcGetPortProperties
		DemcGetPortProperties(hif, iprt, &dprp);
		printf("  Port %d\n", iprt);
		printf("    Properties: %8.8X\n", dprp);
	}

	/* Enable the servo port
	*/
	iprt = 3;
	// DEMC API Call: DemcEnableEx
	if (DemcEnableEx(hif, iprt)) {
		printf("  DEMC port %d enabled\n", iprt);
	}
	else {
		printf("  Unabled to enable DEMC port %d\n", iprt);
		return false;
	}
	
	/* Report the channel min, center, max, and width values
	*/
	for (ichn = 0; ichn < ichnMax; ichn++) {
		// DEMC API Call: DemcServoGetMin
		DemcServoGetMin(hif, ichn, &tusMin);
		
		// DEMC API Call: DemcServoGetMax
		DemcServoGetMax(hif, ichn, &tusMax);

		// DEMC API Call: DemcServoGetCenter
		DemcServoGetCenter(hif, ichn, &tusCtr);

		// DEMC API Call: DemcServoGetWidth
		DemcServoGetWidth(hif, ichn, &tusWdt);

		printf("  Chan: %d, Min=%d, Max=%d, Center=%d, Width=%d\n",
					ichn, tusMin, tusMax, tusCtr, tusWdt);
		
		// DEMC API Call: DemcServoGetPos
		DemcServoGetPos(hif, ichn, &pos);

		// DEMC API Call: DemcServoGetVel
		DemcServoGetVel(hif, ichn, &vel);
		printf("           Pos=%d, Vel=%d\n", pos, vel);
	}
		
	/* Enable some of the servo channels.
	*/
	for (ichn = 0; ichn < ichnMax; ichn++) {
		// DEMC API Call: DemcServoChnEnable
		if (DemcServoChnEnable(hif, ichn)) {
			printf("  Servo Channel %d enabled\n", ichn);
		}
		else {
			printf("  Unable to enable servo channel %d\n", ichn);
			return false;
		}
	}
	
	// DEMC API Call: DemcServoSetWidth
	DemcServoSetWidth(hif, 0, 1000);

	return true;
}
Example #4
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;
}