Пример #1
0
// Write image info to slave register in user_module.sv
BOOL WriteInfo2(PCIE_HANDLE hPCIe, BITMAPINFOHEADER *info)
{

	printf("INFO: width = %d pixels; height = %d pixels\n", info->width, info->height);

	WORD tempw = info->width;
	WORD temph = info->height;

	DWORD addr = 0x04;
	//BYTE start = 0x04;
	PCIE_Write32( hPCIe, pcie_bars[0], addr, *((unsigned char *)&tempw + 1) ) ;  //01
	addr = addr+4;
    PCIE_Write32( hPCIe, pcie_bars[0], addr, *((unsigned char *)&tempw + 0)); //f4
	addr = addr+4;
	PCIE_Write32( hPCIe, pcie_bars[0], addr, *((unsigned char *)&temph + 1)); //01
	addr = addr+4;
	BOOL bPass = PCIE_Write32( hPCIe, pcie_bars[0], addr, *((unsigned char *)&temph + 0)); //4d

	if(!bPass)
	{
		printf("ERROR: unsuccessful image info writing.\n");
		return FALSE;
	}
	else
		printf("Image info written.\n");
	return TRUE;
}
Пример #2
0
void imagem(PCIE_HANDLE hPCIe, DWORD mascaraPCI, DWORD mascara, int score){
	PCIE_Write32(hPCIe, PCIE_BAR0, 0x00, mascaraPCI);
	tela = cv::imread(mascara == 7 ? "1.png" : (mascara == 11 ? "2.png" : (mascara == 13 ? "3.png" : mascara == 14 ? "4.png" : "0.png")));
	putText(tela, (score == -1 ? "FIM" : (score == -2 ? "UIN" : std::to_string(score))), cv::Point((tela.cols / 2) - 50, (tela.rows / 2) + 50), 0, 3, cv::Scalar(0, 0, 255));
	imshow("Genius Game", tela);
	cv::waitKey(500);
}
Пример #3
0
// Test whether PCIe is functional
void test32( PCIE_HANDLE hPCIe, DWORD addr )
{
	BOOL bPass;
	DWORD testVal = 0xf;
	DWORD readVal;

	WORD i = 0;
	for (i = 0; i < 16 ; i++ )
	{
		printf("Testing register %d at addr %x with value %x\n", i, addr, testVal);
		bPass = PCIE_Write32( hPCIe, pcie_bars[0], addr, testVal);
		if (!bPass)
		{
			printf("test FAILED: write did not return success\n");
			return;
		}
		bPass = PCIE_Read32( hPCIe, pcie_bars[0], addr, &readVal);
		if (!bPass)
		{
			printf("test FAILED: read did not return success\n");
			return;
		}
		if (testVal == readVal)
		{
			printf("Test PASSED: expected %x, received %x\n", testVal, readVal);
		}
		else
		{
			printf("Test FAILED: expected %x, received %x\n", testVal, readVal);
		}
		testVal = testVal + 1;
		addr = addr + 4;
	}
	return;
}
Пример #4
0
	DWORD Fpga::request(DWORD sensorId) {
		std::unique_lock<std::mutex>(this->lock);

		// Write request
		BOOL pass = PCIE_Write32(pcieHandle, PCIE_BAR0, 0x00, sensorId);
		if (!pass) { throw std::runtime_error("PCIE write failed"); }
		
		// Receive response
		DWORD input;
		pass = PCIE_Read32(pcieHandle, PCIE_BAR0, 0x20, &input);
		if (!pass) { throw std::runtime_error("PCIE write failed"); }

		return input;
	}
Пример #5
0
// Write STARTBYTE to slave register in user_module.sv
BOOL WriteStartByte(PCIE_HANDLE hPCIe)
{
	DWORD addr = 0x00000000;
	BYTE start = 0x53;

	BOOL bPass = PCIE_Write32( hPCIe, pcie_bars[0], addr, start);
	if(!bPass)
	{
		printf("ERROR: unsuccessful start byte writing.\n");
		return FALSE;
	}
	else
		printf("Start byte written.\n");
	return TRUE;
}
Пример #6
0
BOOL TEST_LED(PCIE_HANDLE hPCIe){
	BOOL bPass;
	int	Mask;
	
	printf("Please input led conrol mask:");
	scanf("%d", &Mask);

	bPass = PCIE_Write32(hPCIe, DEMO_PCIE_USER_BAR, DEMO_PCIE_IO_LED_ADDR,(DWORD)Mask);
	if (bPass)
		printf("Led control success, mask=%xh\r\n", Mask);
	else
		printf("Led conrol failed\r\n");

	
	return bPass;
}