Пример #1
0
// this version just replaces everything
void KovanModule::writeDigitals(const unsigned char &values, const unsigned char &pullups, const unsigned char &outputEnables)
{

	std::cout<<"Warning: writeDigitals has not been tested." << std::endl; // TODO

	Command c0 = createWriteCommand(DIG_OUT, values);
	Command c1 = createWriteCommand(DIG_OUT_ENABLE, outputEnables);
	Command c2 = createWriteCommand(DIG_PULLUPS, pullups);

	CommandVector commands;
	commands.push_back(c0);
	commands.push_back(c1);
	commands.push_back(c2);

	// annoying  that we have to do this
	Command r0;
	r0.type = StateCommandType;
	commands.push_back(r0);

	send(commands);
	State state;

	// shouldn't need this
	if(!recv(state)) {
		std::cout << "Error: didn't get state back!" << std::endl;
		return;
	}

	singleWrite(DIG_UPDATE_T, 1);
	singleWrite(DIG_UPDATE_T, 0);
	singleWrite(DIG_SAMPLE_T, 0); // FPGA captures new dig values
	singleWrite(DIG_SAMPLE_T, 1);
}
Пример #2
0
void KovanModule::setADCPullups(const unsigned char &pullups)
{
	singleWrite(AN_PULLUPS, pullups);
        singleWrite(DIG_UPDATE_T, 1);                                              
        singleWrite(DIG_UPDATE_T, 0);                              
        singleWrite(DIG_SAMPLE_T, 0); // FPGA captures new dig values     
        singleWrite(DIG_SAMPLE_T, 1);   
}
Пример #3
0
unsigned char KovanModule::readDigitals()
{

	std::cout<<"Warning: readDigitals has not been tested." << std::endl; // TODO

	State state;
	getState(state);

	unsigned char pinVals = 0;
	pinVals = (state.t[DIG_OUT] & state.t[DIG_OUT_ENABLE]);
	pinVals |= (state.t[DIG_IN] & ~state.t[DIG_OUT_ENABLE]);

	// TODO: putting these here until we know we don't need them
	singleWrite(DIG_UPDATE_T, 1);
	singleWrite(DIG_UPDATE_T, 0);
	singleWrite(DIG_SAMPLE_T, 0); // FPGA captures new dig values
	singleWrite(DIG_SAMPLE_T, 1);

	return pinVals;
}
Пример #4
0
	void DatabaseImpl::store(const boost::string_ref& key, partNum_t partNum, const boost::string_ref& value)
	{
		checkSimpleArgumentFor(key, partNum);
		SingleWrite singleWrite(key, partNum, value);
		doStore(singleWrite);
	}
Пример #5
0
/*
Write a value to specified channel using singlewrite method.
This will update both input register and EEPROM value
Channel : 0-3, Values : 0-4095
*/
uint8_t mcp4728::eepromWrite(uint8_t channel, uint16_t value)
{
  _values[channel] = value;
  _valuesEp[channel] = value;
  return singleWrite(channel);
}