Example #1
0
static void send_file_to_fpga(std::string &file_name, gpio &error, gpio &done)
{
	std::ifstream bitstream;

	std::cout << "File name - " << file_name.c_str() << std::endl;

	bitstream.open(file_name.c_str(), std::ios::binary);
	if (!bitstream.is_open())
		std::cout << "File " << file_name << " not opened succesfully." << std::endl;

	spidev spi("/dev/spidev1.0");
	char buf[BUF_SIZE];
	char rbuf[BUF_SIZE];

	do {
		bitstream.read(buf, BUF_SIZE);
		spi.send(buf, rbuf, bitstream.gcount());

		if (error.get_value())
			std::cout << "INIT_B went high, error occured." << std::endl;

		if (!done.get_value())
			std::cout << "Configuration complete." << std::endl;

	} while (bitstream.gcount() == BUF_SIZE);
}
Example #2
0
static void send_file_to_fpga(const std::string &file_name, gpio &error, gpio &done)
{
	std::ifstream bitstream;

	bitstream.open(file_name.c_str(), std::ios::binary);
	if (!bitstream.is_open()) throw uhd::os_error(
		"Could not open the file: " + file_name
	);

	spidev spi("/dev/spidev1.0");
	char buf[BUF_SIZE];
	char rbuf[BUF_SIZE];

	do {
		bitstream.read(buf, BUF_SIZE);
		spi.send(buf, rbuf, bitstream.gcount());

		if (error.get_value())
			throw uhd::os_error("INIT_B went high, error occured.");

		if (!done.get_value())
			UHD_MSG(status) << "Configuration complete." << std::endl;

	} while (bitstream.gcount() == BUF_SIZE);
}
Example #3
0
static void prepare_fpga_for_configuration(gpio &prog, gpio &init)
{

	prog.set_value(true);
	prog.set_value(false);
	prog.set_value(true);

#if 0
	bool ready_to_program(false);
	unsigned int count(0);
	do {
		ready_to_program = init.get_value();
		count++;

		sleep(1);
	} while (count < 10 && !ready_to_program);

	if (count == 10) {
		std::cout << "FPGA not ready for programming." << std::endl;
		exit(-1);
	}
#endif
}