示例#1
0
	bool SetClock(byte devid, int mhz) {
		byte cmd[6] = { 6, devid, (byte)min(250, max(1, mhz & ~1)), 0, 0, 0 };
		bool r = *Command(ConstBuf(cmd, sizeof cmd), 1).constData();
		*Miner.m_pTraceStream << "Setting " << Dev.Chips[devid]->Name << " CLK = " << mhz << " MHz " << endl;
		return r;	
	}
示例#2
0
	UInt32 GetUserId(byte devid) {
		byte cmd[2] = { 4, devid};
		return letoh(*(UInt32*)Command(ConstBuf(cmd, sizeof cmd), 4).constData());
	}
示例#3
0
	Temperature GetTemperature(byte devid) {
		byte cmd[2] = { 10, devid };
		return Temperature::FromCelsius(*Command(ConstBuf(cmd, sizeof cmd), 1).constData());
	}
示例#4
0
	int GetFpgaCount() {
		return *Command(ConstBuf("\x02", 1), 1).constData();
	}
示例#5
0
	String GetDevDescription() {
		return (const char*)Command(ConstBuf("\x01", 1), size_t(-1)).constData();
	}
示例#6
0
	void Sync() {
		byte cmdNoop[46] = { 0 };
		memset(cmdNoop+1, 0xFF, (sizeof cmdNoop)-1);
		Command(ConstBuf(cmdNoop, sizeof cmdNoop), 0);
	}
示例#7
0
		byte cmd[6] = { 6, devid, (byte)min(250, max(1, mhz & ~1)), 0, 0, 0 };
		bool r = *Command(ConstBuf(cmd, sizeof cmd), 1).constData();
		*Miner.m_pTraceStream << "Setting " << Dev.Chips[devid]->Name << " CLK = " << mhz << " MHz " << endl;
		return r;	
	}

	UInt32 GetUserId(byte devid) {
		byte cmd[2] = { 4, devid};
		return letoh(*(UInt32*)Command(ConstBuf(cmd, sizeof cmd), 4).constData());
	}

	static const byte DEVID_ALL = 4;

	void UploadBitstream(byte devid, const ConstBuf& bitstream) {
		byte cmd[6] = { 5, devid, byte(bitstream.Size), byte(bitstream.Size >> 8), byte(bitstream.Size >> 16), byte(bitstream.Size >> 24)};
		byte rc = *Command(ConstBuf(cmd, sizeof cmd), 1).constData();
		if (rc != 1) {
			Throw(E_FAIL);
		}
		for (int i=0; i<bitstream.Size && !m_bStop; i+=32) {
			int len = min(32, int(bitstream.Size-i));
			Write(ConstBuf(bitstream.P+i, len));
			StatusRead();
			if (!(i & 0xFFF))
				*Miner.m_pTraceStream << "Programming FPGA" << (devid==DEVID_ALL ? String("") : " "+Dev.Chips[devid]->Name) << ", please DONT'T EXIT until complete: " << i*100/bitstream.Size << "%                      \r" << flush;
		}
		if (m_bStop)
			Throw(E_EXT_ThreadInterrupted);
			
		StatusRead();