Exemple #1
0
int I2c::update()
{
	// try to recover from out of sync condition between slave (us) and master
	// happens when cable is unplugged/plugged
	if ((m_i2c->CONSET&I2C_I2CONSET_AA)==0)
		startSlave();

	return 0;
}
QT_USE_NAMESPACE

Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
    , transactionCount(0)
    , serialPortLabel(new QLabel(tr("Serial port:")))
    , serialPortComboBox(new QComboBox())
    , waitRequestLabel(new QLabel(tr("Wait request, msec:")))
    , waitRequestSpinBox(new QSpinBox())
    , responseLabel(new QLabel(tr("Response:")))
    , responseLineEdit(new QLineEdit(tr("Hello, I'm Slave.")))
    , trafficLabel(new QLabel(tr("No traffic.")))
    , statusLabel(new QLabel(tr("Status: Not running.")))
    , runButton(new QPushButton(tr("Start")))
{
    waitRequestSpinBox->setRange(0, 10000);
    waitRequestSpinBox->setValue(20);

    foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
        serialPortComboBox->addItem(info.portName());

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(serialPortLabel, 0, 0);
    mainLayout->addWidget(serialPortComboBox, 0, 1);
    mainLayout->addWidget(waitRequestLabel, 1, 0);
    mainLayout->addWidget(waitRequestSpinBox, 1, 1);
    mainLayout->addWidget(runButton, 0, 2, 2, 1);
    mainLayout->addWidget(responseLabel, 2, 0);
    mainLayout->addWidget(responseLineEdit, 2, 1, 1, 3);
    mainLayout->addWidget(trafficLabel, 3, 0, 1, 4);
    mainLayout->addWidget(statusLabel, 4, 0, 1, 5);
    setLayout(mainLayout);

    setWindowTitle(tr("Slave"));
    serialPortComboBox->setFocus();

    timer.setSingleShot(true);

    connect(runButton, SIGNAL(clicked()),
            this, SLOT(startSlave()));
    connect(&serial, SIGNAL(readyRead()),
            this, SLOT(readRequest()));
    connect(&timer, SIGNAL(timeout()),
            this, SLOT(processTimeout()));

    connect(serialPortComboBox, SIGNAL(currentIndexChanged(QString)),
            this, SLOT(activateRunButton()));
    connect(waitRequestSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(activateRunButton()));
    connect(responseLineEdit, SIGNAL(textChanged(QString)),
            this, SLOT(activateRunButton()));
}
Exemple #3
0
int I2c::open()
{
	// make all pins on the I/O connector high impedance so we can just daisy chain the whole connector together
	scu_pinmux(0x1, 3, (MD_PLN | MD_EZI | MD_ZI | MD_EHS), FUNC0); 
	scu_pinmux(0x2, 1, (MD_PLN | MD_EZI | MD_ZI | MD_EHS), FUNC4); 	         
	scu_pinmux(0x2, 1, (MD_PLN | MD_EZI | MD_ZI | MD_EHS), FUNC4); 	         
	scu_pinmux(0x1, 4, (MD_PLN | MD_EZI | MD_ZI | MD_EHS), FUNC0); 	         
	scu_pinmux(0x2, 0, (MD_PLN | MD_EZI | MD_ZI | MD_EHS), FUNC4); 	         
	// turn off driver for SS signal so we can wire-or them together
	LPC_SGPIO->GPIO_OENREG = 0;

 	m_pad0 = false;

	NVIC_EnableIRQ(I2C0_IRQn);
	startSlave(); 


	return 0;
}
XMLRPCErrorValueCalculator::XMLRPCErrorValueCalculator(ModelInterface* model, ExperimentInterface* experiment, FixedParameters params) 
	: ErrorValueCalculator(NULL), FixedParamObject(params) 
{
	FixedParameters fitFixedParams(fixedParams["ErrorValueCalculatorParameters"],fixedParams.getGlobals());
	FixedParameters paramHosts(fixedParams["XMLRPCServers"],fixedParams.getGlobals());

	if (fixedParams["ErrorValueCalculatorType"] == "Matrix") {
		localErrorValue = new MatrixErrorValueCalculator(model,experiment,fitFixedParams);
	}
#ifdef WITH_MOEA
	else if (fixedParams["ErrorValueCalculatorType"] == "MOEA")
		localErrorValue = new MOEAErrorValueCalculator(model,experiment,fitFixedParams);
#endif
	else throw std::runtime_error("No matching error value calculator type");
	
	if (rank != 0) startSlave();
	
	if (rank == 0) {                                
		if (toInt(fixedParams["enableFileExport"]) > 0) {
			this->enableFileExport(fixedParams["exportFile"]);
		}
	}
}