void loop() 
{
  if (checkRFID())
  {
    Serial.end();
    lcd.clear();
    switch (restaurantCode)
    {
    case 0:
      break;   //shouldn't get here...
    case 1:
      {
        lcd.clear();
        lcd.print("~Chipotle Menu");
      }
    default:
      break;
    }
    delay(1000);
    char select = priceSelect();
    lcd.clear();
    lcd.print("Selected: ");
    switch (select)
    {
    case 0:
      {
        lcd.print("$1-5");
        break;
      }
    case 1:
      {
        lcd.print("$5-10");
        break;
      }
    case 2:
      {
        lcd.print("$10-15");
        break;
      }
    case 3:
      {
        lcd.print("$15+up");
        break;
      }
    default:
      break; //shouldnt get here;
    }
    delay(1000);
    lcd.clear();
    lcd.print("at Chipotle");
    delay(2000);
    moneyPacketAdd(select);
    restPacketAdd(restaurantCode);
    sendPacket();
    lcd.clear();
    lcd.print("Request sent!");
    getPacket();
    parseInPacket();
    lcd.clear();
    int mealSelection = mealSelect();
    if (mealSelection == 100)
    {
      lcd.clear();
      lcd.print("Com Errors!");
      delay(5000);
      hardReset();
    }
    addPacketFood(mealSelection);
    sendPacket();
    lcd.clear();
    lcd.print("Order sent!");
    delay(3000);
    lcd.clear();
    lcd.print("-RFID Menu Scan-");
    digitalWrite(RFID_ENABLE, LOW);
    Serial.begin(2400);
    Serial.flush();
  }
  delay(500);
}
Exemple #2
0
void Engine::push(char c) {
    if (!checkState())
        return;
    if (state == sStart) {
        executeInstructionOnStack("Copy"); // No tr
        if (!checkState()) {
            setError("Failed to copy some data"); // No tr
            return;
        }
        dStack.top()->clear();
        if (!dStack.top()->push(c, false)) {
            delete dStack.pop();
            return;
        }
        dStack.top()->clear();
        changeState(sAppend);
    } else {
        if (!Qtopia::mousePreferred() && !iStack.isEmpty() && *iStack.top() == "EvaluateLine") // No tr
            hardReset();
        changeResetState(drSoft);
        if (!dStack.top()->push(c, false)) {
            return;
        }
    }

    dStack.top()->push(c);
    emit(stackChanged());
}
Exemple #3
0
void DomainHandler::setHostname(const QString& hostname) {
    
    if (hostname != _hostname) {
        // re-set the domain info so that auth information is reloaded
        hardReset();
        
        int colonIndex = hostname.indexOf(':');
        
        if (colonIndex > 0) {
            // the user has included a custom DS port with the hostname
            
            // the new hostname is everything up to the colon
            _hostname = hostname.left(colonIndex);
            
            // grab the port by reading the string after the colon
            _sockAddr.setPort(atoi(hostname.mid(colonIndex + 1, hostname.size()).toLocal8Bit().constData()));
            
            qDebug() << "Updated hostname to" << _hostname << "and port to" << _sockAddr.getPort();
            
        } else {
            // no port included with the hostname, simply set the member variable and reset the domain server port to default
            _hostname = hostname;
            _sockAddr.setPort(DEFAULT_DOMAIN_SERVER_PORT);
        }
        
        // re-set the sock addr to null and fire off a lookup of the IP address for this domain-server's hostname
        qDebug("Looking up DS hostname %s.", _hostname.toLocal8Bit().constData());
        QHostInfo::lookupHost(_hostname, this, SLOT(completedHostnameLookup(const QHostInfo&)));
        
        UserActivityLogger::getInstance().changedDomain(_hostname);
        emit hostnameChanged(_hostname);
    }
CError CSystemStateMachine::onCounterCADisconnected()
{
   LOG4CPLUS_TRACE(sLogger, __PRETTY_FUNCTION__);

   hardReset(true);
   
   return CError(CError::NO_ERROR, "SystemStateMachine");
}
Exemple #5
0
void DomainHandler::setSockAddr(const HifiSockAddr& sockAddr, const QString& hostname) {
    if (_sockAddr != sockAddr) {
        // we should reset on a sockAddr change
        hardReset();
        // change the sockAddr
        _sockAddr = sockAddr;
    }
    
    // some callers may pass a hostname, this is not to be used for lookup but for DTLS certificate verification
    _hostname = hostname;
}
Exemple #6
0
/**
 * @brief DXSetupMotor::DXSetupMotor
 * Constructor for Motor Calibration Instance; Only 1 motor should be connected at a time;
 * Resets the motor to factory setting + specifications indicated on setting_constants.h (ID, baud rate, SRL and delay time)
 * @param newID Desired new ID (unique) for the motor
 * @param devicePort Designated port for interface (dev/ttyUSB*, where * is the port number)
 * @param dxlBaudRate Baud Rate to be set, according to Dynamixel's table for baud rate data
 */
DXSetupMotor::DXSetupMotor(int newID, int devicePort, int dxlBaudRate):DXSystem(devicePort, dxlBaudRate)
{
    if (isInitialized())
    {
        if (numMotors > 1)
            handleError("Please connect only 1 motor for setup", true);

    }
    if (numMotors == 1)
        hardReset(newID);
}
Exemple #7
0
/**
 * PHY constructor.
 *
 * Stores E1000 instance internally. Triggers PHY hard reset.
 *
 * @param   iNICInstance   Number of network controller instance this PHY is
 *                         attached to.
 * @param   u16EPid        Extended PHY Id.
 */
void Phy::init(PPHY pPhy, int iNICInstance, uint16_t u16EPid)
{
    pPhy->iInstance = iNICInstance;
    /* Make sure the link is down */
    REG(PSTATUS)  = 0;
    /* The PHY identifier composed of bits 3 through 18 of the OUI */
    /* (Organizationally Unique Identifier). OUI is 0x05043.       */
    REG(PID)      = 0x0141;
    /* Extended PHY identifier */
    REG(EPID)     = u16EPid;
    hardReset(pPhy);
}
PowerGui::PowerGui(MainWidgetFrame *parent) : QWidget(parent)
{
	this->parent = parent;

	QVBoxLayout *vlayout = new QVBoxLayout;

	QPushButton *bbio_mode = new QPushButton("Reset BBIO Mode");
	bbio_mode->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	QPushButton *hard_reset = new QPushButton("Hardware Reset - Bus Pirate");
	hard_reset->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	QPushButton *userterm_reset = new QPushButton("User Terminal Reset");
	userterm_reset->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	QPushButton *enter_bbio = new QPushButton("Enter BBIO Mode");
	enter_bbio->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

	QPushButton *hiz_mode =  new QPushButton("Enable Hi-Z Power");
	hiz_mode->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	QPushButton *normal_mode = new QPushButton("Enable Normal (3.3v) Power");
	normal_mode->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	QPushButton *open_collector = new QPushButton("Enable Open Collector (5v) Power");
	open_collector->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

	QPushButton *short_test = new QPushButton("Short Self-Test");
	short_test->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	QPushButton *long_test = new QPushButton("Long Self-Test");
	long_test->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	QPushButton *fetch_buffer = new QPushButton("Fetch Buffer Contents");
	fetch_buffer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	
	connect(hiz_mode, SIGNAL(clicked()), this, SLOT(hiz_power_enable()));

	connect(bbio_mode, SIGNAL(clicked()), this, SLOT(resetBBIO()));
	connect(hard_reset, SIGNAL(clicked()), this, SLOT(hardReset()));
	connect(userterm_reset, SIGNAL(clicked()), this, SLOT(userTermReset()));
	connect(enter_bbio, SIGNAL(clicked()), this, SLOT(enterMode()));
	connect(fetch_buffer, SIGNAL(clicked()), this, SLOT(getBuffer()));

	vlayout->addWidget(bbio_mode);
	vlayout->addWidget(hard_reset);
	vlayout->addWidget(userterm_reset);
	vlayout->addWidget(enter_bbio);
	vlayout->addSpacing(50);
	vlayout->addWidget(hiz_mode);
	vlayout->addWidget(normal_mode);
	vlayout->addWidget(open_collector);
	vlayout->addSpacing(50);
	vlayout->addWidget(short_test);
	vlayout->addWidget(long_test);
	vlayout->addWidget(fetch_buffer);
	setLayout(vlayout);
}
Exemple #9
0
void Bluetooth_HC05::begin(unsigned baud_rate, uint8_t reset_pin,
                           uint8_t mode_pin, HC05_Mode mode)
{
    m_uart->begin(baud_rate);
    
    m_resetPin = reset_pin;
    pinMode(m_resetPin, OUTPUT);
    digitalWrite(m_resetPin, HIGH);
    
    m_modePin = mode_pin;
    pinMode(m_modePin, OUTPUT);
    digitalWrite(m_modePin, (mode == HC05_MODE_DATA ? LOW : HIGH));
    
    hardReset();
}
Exemple #10
0
void DomainHandler::setSockAddr(const HifiSockAddr& sockAddr, const QString& hostname) {
    if (_sockAddr != sockAddr) {
        // we should reset on a sockAddr change
        hardReset();
        // change the sockAddr
        _sockAddr = sockAddr;
    }

    if (!_sockAddr.isNull()) {
        DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainSocket);
    }

    // some callers may pass a hostname, this is not to be used for lookup but for DTLS certificate verification
    _hostname = hostname;
}
boolean ESP8266::begin(void)
{
	connected = false;
	pinMode(ESP8266_RST, OUTPUT);
	clearAllRequests();
	hardReset();
	lastActivityTimestamp = 0;
	DBGBEG();
	_wifiSerial.begin(ESP8266_BAUD_RATE);

	//_wifiSerial.flush();
	//_wifiSerial.setTimeout(ESP8266_SERIAL_TIMEOUT);
	state = STATE_IDLE;
	attemptCounter = 0;
	softReset();
}
Exemple #12
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    mUi(new Ui::MainWindow)
{
    mUi->setupUi(this);
    mUi->b_disconnect->setEnabled(false);
    this->lockUI(true);
    mStlink = new stlinkv2();
    mDevices = new DeviceInfoList(this);
    mTfThread = new transferThread();

    mLastAction = ACTION_NONE;

    if (mDevices->IsLoaded()) {

        this->log(QString::number(mDevices->getDevicesCount())+" Device descriptions loaded.");
        QObject::connect(mUi->b_quit,SIGNAL(clicked()),this,SLOT(quit()));
        QObject::connect(mUi->b_connect, SIGNAL(clicked()), this, SLOT(connect()));
        QObject::connect(mUi->b_disconnect, SIGNAL(clicked()), this, SLOT(disconnect()));
        QObject::connect(mUi->b_send, SIGNAL(clicked()), this, SLOT(send()));
        QObject::connect(mUi->b_receive, SIGNAL(clicked()), this, SLOT(receive()));
        QObject::connect(mUi->b_verify, SIGNAL(clicked()), this, SLOT(verify()));
        QObject::connect(mUi->b_repeat, SIGNAL(clicked()), this, SLOT(repeat()));
        QObject::connect(mUi->b_halt, SIGNAL(clicked()), this, SLOT(haltMCU()));
        QObject::connect(mUi->b_run, SIGNAL(clicked()), this, SLOT(runMCU()));
        QObject::connect(mUi->b_reset, SIGNAL(clicked()), this, SLOT(resetMCU()));
        QObject::connect(mUi->r_jtag, SIGNAL(clicked()), this, SLOT(setModeJTAG()));
        QObject::connect(mUi->r_swd, SIGNAL(clicked()), this, SLOT(setModeSWD()));
        QObject::connect(mUi->b_hardReset, SIGNAL(clicked()), this, SLOT(hardReset()));

        // Thread
        QObject::connect(mTfThread, SIGNAL(sendProgress(quint32)), this, SLOT(updateProgress(quint32)));
        QObject::connect(mTfThread, SIGNAL(sendStatus(QString)), this, SLOT(updateStatus(QString)));
        QObject::connect(mTfThread, SIGNAL(sendLoaderStatus(QString)), this, SLOT(updateLoaderStatus(QString)));
        QObject::connect(mStlink, SIGNAL(bufferPct(quint32)), this, SLOT(updateLoaderPct(quint32)));
        QObject::connect(mTfThread, SIGNAL(sendLock(bool)), this, SLOT(lockUI(bool)));
        QObject::connect(mUi->b_stop, SIGNAL(clicked()), mTfThread, SLOT(halt()));
        QObject::connect(mTfThread, SIGNAL(sendLog(QString)), this, SLOT(log(QString)));

        // Help
        QObject::connect(mUi->b_help, SIGNAL(clicked()), this, SLOT(showHelp()));

        // Usb stuff
        QObject::connect(mStlink, SIGNAL(deviceDetected(QString)), this, SLOT(log(QString)));
    }
Exemple #13
0
void DomainHandler::setHostnameAndPort(const QString& hostname, quint16 port) {

    if (hostname != _hostname || _sockAddr.getPort() != port) {
        // re-set the domain info so that auth information is reloaded
        hardReset();

        if (hostname != _hostname) {
            // set the new hostname
            _hostname = hostname;

            qCDebug(networking) << "Updated domain hostname to" << _hostname;

            // re-set the sock addr to null and fire off a lookup of the IP address for this domain-server's hostname
            qCDebug(networking, "Looking up DS hostname %s.", _hostname.toLocal8Bit().constData());
            QHostInfo::lookupHost(_hostname, this, SLOT(completedHostnameLookup(const QHostInfo&)));

            UserActivityLogger::getInstance().changedDomain(_hostname);
            emit hostnameChanged(_hostname);
        }
Exemple #14
0
void initWifi() {
  hardReset();
  if (config.host.highSpeed) {
    wifi_set_sleep_type(NONE_SLEEP_T);
  } else {
    wifi_set_sleep_type(LIGHT_SLEEP_T);
  }

  // Connecting to an access point currently causes a hang. :(
  // TODO(maruel): Figure it out.
  //WifiEvents.onStationConnect(onStationConnect);
  //WifiEvents.onStationDisconnect(onStationDisconnect);
  //WifiEvents.onStationAuthModeChange(onStationAuthModeChange);
  WifiEvents.onStationGotIP(onStationGotIP);
  //WifiEvents.onAccessPointConnect(onAccessPointConnect);
  //WifiEvents.onAccessPointDisconnect(onAccessPointDisconnect);
  //WifiEvents.onAccessPointProbeReqRecved(onAccessPointProbeReqRecved);
  if (config.has_wifiClient && config.wifiClient.has_ssid && config.wifiClient.has_password) {
    Serial.printf("wifi client \"%s\"\n", config.wifiClient.ssid);
    if (!WifiStation.config(config.wifiClient.ssid, config.wifiClient.password, true)) {
      Serial.println("failure");
    }
    WifiStation.enable(true, false);
    WifiStation.connect();
  } else if (config.has_wifiAP && config.wifiAP.has_ssid && config.wifiAP.has_password) {
    Serial.printf("wifi AP \"%s\"\n", config.wifiAP.ssid);
    // TODO(maruel): Channel is hardcoded to 7, beacon at 200ms.
    if (!WifiAccessPoint.config(config.wifiAP.ssid, config.wifiAP.password, AUTH_WPA2_PSK)) {
      Serial.println("failure");
    }
    WifiAccessPoint.enable(true, false);
  } else {
    Serial.printf("wifi default AP: \"%s\"\n", config.host.name);
    // TODO(maruel): Scan networks.
    // TODO(maruel): Use WifiStation.smartConfigStart()
    //if (!WifiAccessPoint.config(config.host.name, chipID, AUTH_WPA2_PSK)) {
    if (!WifiAccessPoint.config(config.host.name, "", AUTH_OPEN)) {
      Serial.println("failure");
    }
    WifiAccessPoint.enable(true, false);
  }
}
Exemple #15
0
void DomainHandler::setURLAndID(QUrl domainURL, QUuid domainID) {
    _pendingDomainID = domainID;

    if (domainURL.scheme() != URL_SCHEME_HIFI) {
        _sockAddr.clear();

        // if this is a file URL we need to see if it has a ~ for us to expand
        if (domainURL.scheme() == HIFI_URL_SCHEME_FILE) {
            domainURL = PathUtils::expandToLocalDataAbsolutePath(domainURL);
        }
    }

    auto domainPort = domainURL.port();
    if (domainPort == -1) {
        domainPort = DEFAULT_DOMAIN_SERVER_PORT;
    }

    // if it's in the error state, reset and try again.
    if ((_domainURL != domainURL || _sockAddr.getPort() != domainPort) || _isInErrorState) {
        // re-set the domain info so that auth information is reloaded
        hardReset();

        QString previousHost = _domainURL.host();
        _domainURL = domainURL;

        if (previousHost != domainURL.host()) {
            qCDebug(networking) << "Updated domain hostname to" << domainURL.host();

            if (!domainURL.host().isEmpty()) {
                if (domainURL.scheme() == URL_SCHEME_HIFI) {
                    // re-set the sock addr to null and fire off a lookup of the IP address for this domain-server's hostname
                    qCDebug(networking, "Looking up DS hostname %s.", domainURL.host().toLocal8Bit().constData());
                    QHostInfo::lookupHost(domainURL.host(), this, SLOT(completedHostnameLookup(const QHostInfo&)));
                }

                DependencyManager::get<NodeList>()->flagTimeForConnectionStep(
                    LimitedNodeList::ConnectionStep::SetDomainHostname);

                UserActivityLogger::getInstance().changedDomain(domainURL.host());
            }
Exemple #16
0
void MainWindow::createActions()
{
    loadMemoryAction = new QAction(tr("&Load Memory from disk"),this);
    loadMemoryAction->setIcon(QIcon(":/images/loadMemory.png"));
    connect(loadMemoryAction, SIGNAL(triggered()), this, SLOT(loadMemory()));
    saveMemoryAction = new QAction(tr("&Save Memory to disk"),this);
    saveMemoryAction->setIcon(QIcon(":/images/saveMemory.png"));
    connect(saveMemoryAction, SIGNAL(triggered()), this, SLOT(saveMemory()));
    pasteCodeAction = new QAction(tr("&Paste Code"),this);
    pasteCodeAction->setIcon(QIcon(":/images/pasteCode.png"));
    connect(pasteCodeAction, SIGNAL(triggered()), this, SLOT(pasteCode()));
    quitAction = new QAction(tr("&Quit QtPom1"),this);
    quitAction->setIcon(QIcon(":/images/quit.png"));
    //quitAction->setIcon(QIcon(":/images/quit.png"));
    connect(quitAction, SIGNAL(triggered()), this, SLOT(quit()));

    resetAction = new QAction(tr("Soft &Reset"),this);
    resetAction->setIcon(QIcon(":/images/reset.png"));
    connect(resetAction, SIGNAL(triggered()), this, SLOT(reset()));
    hardResetAction = new QAction(tr("&Hard Reset"),this);
    hardResetAction->setIcon(QIcon(":/images/hardreset.png"));
    connect(hardResetAction, SIGNAL(triggered()), this, SLOT(hardReset()));
    debugCpuAction = new QAction(tr("&Debug Console"),this);
    debugCpuAction->setIcon(QIcon(":/images/debug.png"));
    connect(debugCpuAction, SIGNAL(triggered()), this, SLOT(debugCpu()));

    configScreenAction = new QAction(tr("&Screen Options"),this);
    configScreenAction->setIcon(QIcon(":/images/screen.png"));
    connect(configScreenAction, SIGNAL(triggered()), this, SLOT(configScreen()));
    configMemoryAction = new QAction(tr("&Memory Options"),this);
    configMemoryAction->setIcon(QIcon(":/images/memory.png"));
    connect(configMemoryAction, SIGNAL(triggered()), this, SLOT(configMemory()));

    aboutAction = new QAction(tr("&About QtPom1"),this);
    aboutAction->setIcon(QIcon(":/images/about.png"));
    connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
    aboutQtAction = new QAction(tr("About &Qt"),this);
    aboutQtAction->setIcon(QIcon(":/images/aboutQt.png"));
    connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
}
Exemple #17
0
bool NesEmulator::CreateNew(unsigned char* fileContent, int len, TVSystem tvsetting)
{
    Rom rom;
    if(rom.parseNes(fileContent, len, true) == false)
    {
        return false;
    }
    
    TVFormat = tvsetting;
    Memory::__instance->init(&rom);
    
    VSUnisystem::CheckGameVSUnisystem(rom.getSHA1(), rom.isVSUnisystem(), rom.getMapperNumber());
    
    hardReset();
    
    EmulationON = true;
    
    EmulationThread = new std::thread(&NesEmulator::clock, this);
    EmulationThread->detach();

    return true;
}
Exemple #18
0
void DomainHandler::setSocketAndID(const QString& hostname, quint16 port, const QUuid& domainID) {

    _pendingDomainID = domainID;

    if (hostname != _hostname || _sockAddr.getPort() != port) {
        // re-set the domain info so that auth information is reloaded
        hardReset();

        if (hostname != _hostname) {
            // set the new hostname
            _hostname = hostname;

            qCDebug(networking) << "Updated domain hostname to" << _hostname;

            // re-set the sock addr to null and fire off a lookup of the IP address for this domain-server's hostname
            qCDebug(networking, "Looking up DS hostname %s.", _hostname.toLocal8Bit().constData());
            QHostInfo::lookupHost(_hostname, this, SLOT(completedHostnameLookup(const QHostInfo&)));

            DependencyManager::get<NodeList>()->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SetDomainHostname);

            UserActivityLogger::getInstance().changedDomain(_hostname);
            emit hostnameChanged(_hostname);
        }
Exemple #19
0
int main() {
	uint32 state;

	systemInit();

	// Read bootloader state value
	state = readBootloaderState();

	// Direct branch code, use for testing
//	if (state == BL_STATE_NORMAL) {
//		bootOS(OS_START_ADDRESS);
//	} else {
//		while (1) {
//			blinkyLedToggle();
//			systemDelay(1000);
//		}
//	}

	switch (state) {
		case BL_STATE_NORMAL:
			break;
		case BL_STATE_HOST:
			faultPrintSerial("Bootloader radio host mode\n");
			faultPrintSerial("ID = ");
			faultPrintSerialDec(roneID);
			faultPrintSerial("\n\n");
			radioProgrammingInput();
			radioProgramming(RADIO_PROGRAMMING_HOST);
			// Control should not reach here
			break;
		case BL_STATE_RECEIVE:
			faultPrintSerial("Bootloader radio receiver mode\n");
			faultPrintSerial("ID = ");
			faultPrintSerialDec(roneID);
			faultPrintSerial("\n\n");
			radioProgramming(RADIO_PROGRAMMING_REMOTE);
			// Contorl should not reach here
			break;
		case BL_STATE_LIMBO:
			faultPrintSerial("Bootloader radio limbo mode\n");
			faultPrintSerial("ID = ");
			faultPrintSerialDec(roneID);
			faultPrintSerial("\n\n");
			radioProgramming(RADIO_PROGRAMMING_LIMBO);
			// Control should not reach here
			break;
		case BL_STATE_XMODEM:
			faultPrintSerial("Bootloader XMODEM mode\n\n");
			// To let the user know the robot is in xmodem mode
			blinkyLedSet(1);
			if (xmodemDownalodBinary() != 0) {
				faultPrintSerial("Error: XMODEM programming failed\n");
				while(1) {
					blinkyLedToggle();
					systemDelay(1000);
				}
			}
			break;
		default:
			faultPrintSerial("Error: invalid bootloader state\n\n");
			while(1) {
				blinkyLedToggle();
				systemDelay(1000);
			}
			break;
	}

	// Reset robot and run main program after programming
	writeBootloaderState(BL_STATE_NORMAL);
	hardReset();

	return 0;
}
void CSystemStateMachine::startTriggerHandler()
{
   LOG4CPLUS_TRACE(sLogger, "startTriggerHandler()");

   LOG4CPLUS_INFO(sLogger, "Trigger handler is now running...");

   eSSMTriggers trigger;

   while(true)
   {
      LOG4CPLUS_INFO(sLogger, "read trigger");

      trigger = CTriggerQueue::receiveTrigger();

      switch(trigger)
      {
      case EMPTY_TRIGGER_QUEUE:
         LOG4CPLUS_INFO(sLogger, "No incoming triggers");
         break;
      case INITIALIZED:
         LOG4CPLUS_INFO(sLogger, "INITIALIZED trigger");
         mSystemState->launchPhysicalLayer(this);
         break;
      case CONNECTIVITY_AGENT_STARTED:
         LOG4CPLUS_INFO(sLogger, "CONNECTIVITY_AGENT_STARTED trigger");
         break;
      case PHISYCAL_CONNECTION_ESTABLISHED:
         LOG4CPLUS_INFO(sLogger, "PHISYCAL_CONNECTION_ESTABLISHED trigger");
         mSystemState->launchChannelLayer(this);
         break;
      case PHISYCAL_CONNECTION_LOST:
         LOG4CPLUS_WARN(sLogger, "PHISYCAL_CONNECTION_LOST trigger");
         break;
      case CHANNEL_SUPERVISOR_STARTED:
         LOG4CPLUS_INFO(sLogger, "CHANNEL_SUPERVISOR_STARTED trigger");
         break;
      case CHANNEL_CONNECTION_ESTABLISHED:
         LOG4CPLUS_INFO(sLogger, "CHANNEL_CONNECTION_ESTABLISHED trigger");
         mSystemState->launchProfileManager(this);
         break;
      case CHANNEL_CONNECTION_LOST:
         LOG4CPLUS_WARN(sLogger, "CHANNEL_CONNECTION_LOST trigger");
         break;
      case PROFILE_MANAGER_STARTED:
         LOG4CPLUS_INFO(sLogger, "PROFILE_MANAGER_STARTED trigger");
         break;
      case PROFILE_MANAGER_CONNECTION_ESTABLISHED:
         LOG4CPLUS_INFO(sLogger, "PROFILE_MANAGER_CONNECTION_ESTABLISHED trigger");
         mSystemState->launchApplicationManager(this);
         break;
      case APPLICATION_MANAGER_STARTED:
         LOG4CPLUS_INFO(sLogger, "APPLICATION_MANAGER_STARTED trigger");
         break;
      case APPLICATION_MANAGER_CONNECTION_ESTABLISHED:
         LOG4CPLUS_INFO(sLogger, "APPLICATION_MANAGER_CONNECTION_ESTABLISHED trigger");
         if(authOn)
         {
            unlockAuthenticationProfile();
            mSystemState->startAuthentication(this);
         }
         else
         {
            mSystemState->finishAuthentication(this);
         }
         break;
      case AUTHENTICATION_ESTABLISHED:
         LOG4CPLUS_INFO(sLogger, "AUTHENTICATION_ESTABLISHED trigger");
         LOG4CPLUS_WARN(sLogger, "Unlock all profiles and switch to idle state");
         unlockProfiles();
         AuthenticationAppMsgProxy::requestShutDown();
         break;
      case AUTHENTICATION_CANCELED:
         AuthenticationAppMsgProxy::requestShutDown();
         hardReset(true);
         break;
      }
   }
}
void CODECClass::configure() {
	hardReset();
	PAGE_SELECT(0x00);
	softReset();

	//Clock
	write(0x0B, 0x81);	//NDAC on, div = 1
	write(0x0C, 0x82);	//MDAC on, div = 2
	write(0x0D, 0x00);	//DAC OSR = 128
	write(0x0E, 0x80);	// ^
	write(0x12, 0x81);	//NADC on, div = 1
	write(0x13, 0x82);	//NADC on, div = 2
	write(0x14, 0x80);	//ADC OSR = 128

	//Interface
	write(0x1B, 0x00);	//I2S, 16b, WCLK & BCLK inputs

	//Processing Block
	write(0x3C, 0x08);	//DAC: PRB_P8
	write(0x3D, 0x01);	//ADC: PRB_R1

	//Analog PS
	PAGE_SELECT(0x01);
	write(0x01, 0x08);	//Disable AVDD/DVDD connection
	write(0x02, 0x01);	//Enable AVDD LDO
	write(0x0A, 0x3B);	//Output common mode is 1.65V, Full chip CM is 0.9V, HP powered from LDO (1.8-3.6V)

	//Power up
	write(0x47, 0x31);	//Analog inputs power up in 3ms
	write(0x7B, 0x01);	//Reference powers up in 40ms
	write(0x14, 0x65);	//Headphone powers up in 50ms, charges for 5 time constants @ 6k ohms

	//DAC routing
	write(0x0C, 0x08);	//Left DAC -> Left headphone
	write(0x0D, 0x08);	//Right DAC -> Right headphone
	write(0x0E, 0x08);	//Left DAC -> Left line out
	write(0x0F, 0x08);	//Right DAC -> Right line out

	//ADC routing
	write(0x34, 0xC0);	//IN1L -> MICPGA L+, 40k
	write(0x36, 0xC0);	//CM -> MICPGA L-, 40k
	write(0x37, 0xC0);	//IN1R -> MICPGA R+, 40k
	write(0x39, 0xC0);	//CM -> MICPGA R-, 40k
	
	//1Hz filter L
	PAGE_SELECT(0x08);
	write(0x18, 0x7F);
	write(0x19, 0xFF);
	write(0x1A, 0x00);
	write(0x1C, 0x80);
	write(0x1D, 0x01);
	write(0x1E, 0x00);
	write(0x20, 0x7F);
	write(0x21, 0xFC);
	write(0x22, 0x00);

	//1Hz filter R
	PAGE_SELECT(0x09);
	write(0x20, 0x7F);
	write(0x21, 0xFF);
	write(0x22, 0x00);
	write(0x24, 0x80);
	write(0x25, 0x01);
	write(0x26, 0x00);
	write(0x28, 0x7F);
	write(0x29, 0xFC);
	write(0x2A, 0x00);

	return;
}
Exemple #22
0
// Reset
void Engine::dualReset() {
    if (drs == drHard)
        hardReset();
    else
        softReset();
}
Exemple #23
0
BPSettingsGui::BPSettingsGui(MainWidgetFrame *parent) : QWidget(parent)
{
	this->parent=parent;

	QHBoxLayout *m_layout = new QHBoxLayout;

	CreateBaudMap();
	QStringList baud_list;
	baud_list << "300" << "600" << "1200" << "2400" << "4800" << "9600" 
		<< "19200" << "38400" << "57600" << "115200";

	QStringList databits_list;
	databits_list << "5" << "6" << "7" << "8";

	QStringList parity_list;
	parity_list << "NONE" << "ODD" << "EVEN" << "SPACE"; 
	
	QStringList stopbits_list;
	stopbits_list << "1" << "2";

	QStringList flowctrl_list;
	flowctrl_list << "OFF" << "HARDWARE" << "SOFTWARE";


	QLabel *s_port_label = new QLabel("Serial Port: ");
	QLabel *s_baud_label = new QLabel("Port Baud Rate: ");
	QLabel *s_databits_label = new QLabel("Data bits: ");
	QLabel *s_stopbits_label = new QLabel("Stop bits: ");
	QLabel *s_parity_label = new QLabel("Parity: ");
	QLabel *s_flow_label = new QLabel("Flow Control: ");

	QPushButton *open = new QPushButton("Open BusPirate");
	open->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	QPushButton *close = new QPushButton("Close BusPirate");
	close->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	
	s_port = new QLineEdit(parent->cfg->serial_port_name);
	s_port->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

	s_baud = new QComboBox;
	s_baud->addItems(baud_list);
	s_baud->setCurrentIndex(s_baud->findText(usable_baud_rate->key(parent->cfg->baud_rate)));
	s_baud->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

	s_databits = new QComboBox;
	s_databits->addItems(databits_list);
	s_databits->setCurrentIndex(parent->cfg->databits);
	s_databits->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

	s_stopbits = new QComboBox;
	s_stopbits->addItems(stopbits_list);
	s_stopbits->setCurrentIndex(parent->cfg->stopbits);
	s_stopbits->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

	s_parity = new QComboBox;
	s_parity->addItems(parity_list);
	s_parity->setCurrentIndex(parent->cfg->parity);
	s_parity->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

	s_flow = new QComboBox;
	s_flow->addItems(flowctrl_list);
	s_flow->setCurrentIndex(parent->cfg->flowctrl);
	s_flow->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

	QVBoxLayout *vlayout = new QVBoxLayout;

	connect(open, SIGNAL(clicked()), this, SLOT(openPort()));
	connect(close, SIGNAL(clicked()), this, SLOT(closePort()));

	vlayout->addWidget(s_port_label);
	vlayout->addWidget(s_port);
	vlayout->addWidget(s_baud_label);
	vlayout->addWidget(s_baud);
	vlayout->addWidget(s_databits_label);
	vlayout->addWidget(s_databits);
	vlayout->addWidget(s_stopbits_label);
	vlayout->addWidget(s_stopbits);
	vlayout->addWidget(s_parity_label);
	vlayout->addWidget(s_parity);
	vlayout->addWidget(s_flow_label);
	vlayout->addWidget(s_flow);
	vlayout->addSpacing(50);
	vlayout->addWidget(open);
	vlayout->addWidget(close);

/* Power */
	QVBoxLayout *vlayout2 = new QVBoxLayout;

	QPushButton *bbio_mode = new QPushButton("Reset BBIO Mode");
	bbio_mode->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	QPushButton *hard_reset = new QPushButton("Hardware Reset - Bus Pirate");
	hard_reset->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	QPushButton *userterm_reset = new QPushButton("User Terminal Reset");
	userterm_reset->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	QPushButton *enter_bbio = new QPushButton("Enter BBIO Mode");
	enter_bbio->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

	QPushButton *hiz_mode =  new QPushButton("Enable Hi-Z Power");
	hiz_mode->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	QPushButton *normal_mode = new QPushButton("Enable 3.3v Power");
	normal_mode->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	QPushButton *open_collector = new QPushButton("Enable 5v Power");
	open_collector->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

	QPushButton *short_test = new QPushButton("Short Self-Test");
	short_test->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	QPushButton *long_test = new QPushButton("Long Self-Test");
	long_test->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	QPushButton *fetch_buffer = new QPushButton("Fetch Buffer Contents");
	fetch_buffer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	
	connect(hiz_mode, SIGNAL(clicked()), this, SLOT(hiz_power_enable()));

	connect(bbio_mode, SIGNAL(clicked()), this, SLOT(resetBBIO()));
	connect(hard_reset, SIGNAL(clicked()), this, SLOT(hardReset()));
	connect(userterm_reset, SIGNAL(clicked()), this, SLOT(userTermReset()));
	connect(enter_bbio, SIGNAL(clicked()), this, SLOT(enterMode()));
	connect(fetch_buffer, SIGNAL(clicked()), this, SLOT(getBuffer()));

	vlayout2->addWidget(bbio_mode);
	vlayout2->addWidget(hard_reset);
	vlayout2->addWidget(userterm_reset);
	vlayout2->addWidget(enter_bbio);
	vlayout2->addSpacing(50);
	vlayout2->addWidget(hiz_mode);
	vlayout2->addWidget(normal_mode);
	vlayout2->addWidget(open_collector);
	vlayout2->addSpacing(50);
	vlayout2->addWidget(short_test);
	vlayout2->addWidget(long_test);
	vlayout2->addWidget(fetch_buffer);

	m_layout->addLayout(vlayout);
	m_layout->addLayout(vlayout2);
	setLayout(m_layout);
	//setupBusPirate();
}