示例#1
0
/////////////////////////////////////////////////////////////////
// wifi_event_handler_cb() - Callback function for WiFi events //
/////////////////////////////////////////////////////////////////
void wifi_event_handler_cb(System_Event_t *event)
{
    if (event == NULL)
    {
        return;
    }

    switch (event->event_id)  // Switch on the event that brought us here
    {
    case EVENT_STAMODE_SCAN_DONE: //  Once the scan is  done,
        setupTimer(&blink_timer, 100/2, blink); // Blink at 10Hz
        break;
    case EVENT_STAMODE_CONNECTED: // Once we've connected (no IP yet),
        setupTimer(&blink_timer, 250/2, blink); // Blink at 4Hz
        break;
    case EVENT_STAMODE_GOT_IP: // If we're connected and received an IP,
        // Start the Phant post timer:
        setupTimer(&post_timer, POST_FREQUENCY, post);
        setupTimer(&blink_timer, 0, blink); // Turn blink off
        GPIO_OUTPUT_SET(LED_PIN, 1); // Turn LED on
        break;
    case EVENT_STAMODE_DISCONNECTED: // If disconnected,
        setupTimer(&blink_timer, 5000/2, blink); // blink every 5s
        break;
    default:
        break;
    }
}
示例#2
0
void StoredFilter_Start(void) 
{
	Leds_SetLeds(0x4);	
  CMU_ClockEnable(cmuClock_USART2, true);
  CMU_ClockEnable(cmuClock_GPIO, true);
	SPI_setup(2, 0, true);
	setupMEM();	
	setupFPGA();

	setupSD();
	done = false;
	setupTimer();
	FPGA_Enable();
	while(1) {
		
		if (done)
			break;
	}
	FPGA_Disable();
	TIMER_Enable( TIMER0, false );
	TIMER_Reset( TIMER0 );
	FPGADriver_Destroy();
	SDDriver_Finalize();
	MEM_Destroy();	
}
示例#3
0
void HTTPResourceRequest::doSend() {
    DependencyManager::get<StatTracker>()->incrementStat(STAT_HTTP_REQUEST_STARTED);

    QNetworkRequest networkRequest(_url);
    networkRequest.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
    networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);

    if (_cacheEnabled) {
        networkRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
    } else {
        networkRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
    }

    if (_byteRange.isSet()) {
        QString byteRange;
        if (_byteRange.fromInclusive < 0) {
            byteRange = QString("bytes=%1").arg(_byteRange.fromInclusive);
        } else {
            // HTTP byte ranges are inclusive on the `to` end: [from, to]
            byteRange = QString("bytes=%1-%2").arg(_byteRange.fromInclusive).arg(_byteRange.toExclusive - 1);
        }
        networkRequest.setRawHeader("Range", byteRange.toLatin1());
    }
    networkRequest.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, false);

    _reply = NetworkAccessManager::getInstance().get(networkRequest);
    
    connect(_reply, &QNetworkReply::finished, this, &HTTPResourceRequest::onRequestFinished);
    connect(_reply, &QNetworkReply::downloadProgress, this, &HTTPResourceRequest::onDownloadProgress);

    setupTimer();
}
示例#4
0
void
CClient::connect()
{
	if (m_stream != NULL) {
		return;
	}
	if (m_suspended) {
		m_connectOnResume = true;
		return;
	}

	try {
		// resolve the server hostname.  do this every time we connect
		// in case we couldn't resolve the address earlier or the address
		// has changed (which can happen frequently if this is a laptop
		// being shuttled between various networks).  patch by Brent
		// Priddy.
		m_serverAddress.resolve();
		
		// m_serverAddress will be null if the hostname address is not reolved
		if (m_serverAddress.getAddress() != NULL) {
		  // to help users troubleshoot, show server host name (issue: 60)
		  LOG((CLOG_NOTE "connecting to '%s': %s:%i", 
		  m_serverAddress.getHostname().c_str(),
		  ARCH->addrToString(m_serverAddress.getAddress()).c_str(),
		  m_serverAddress.getPort()));
		}

		// create the socket
		IDataSocket* socket = m_socketFactory->create();

		// filter socket messages, including a packetizing filter
		m_stream = socket;
		if (m_streamFilterFactory != NULL) {
			m_stream = m_streamFilterFactory->create(m_stream, true);
		}
		m_stream = new CPacketStreamFilter(m_events, m_stream, true);

		if (m_crypto.m_mode != kDisabled) {
			m_cryptoStream = new CCryptoStream(
				m_events, m_stream, m_crypto, true);
			m_stream = m_cryptoStream;
		}

		// connect
		LOG((CLOG_DEBUG1 "connecting to server"));
		setupConnecting();
		setupTimer();
		socket->connect(m_serverAddress);
	}
	catch (XBase& e) {
		cleanupTimer();
		cleanupConnecting();
		delete m_stream;
		m_stream = NULL;
		LOG((CLOG_DEBUG1 "connection failed"));
		sendConnectionFailedEvent(e.what());
		return;
	}
}
示例#5
0
/*
 * main.c
 */
int main (void) {

	// preamble
	setupTestFuncs ();
	setupTimer ();

	// setup your processList
	int i;
	for (i = 0; i < MAX_THREADS; i++)
		threadList [i].state = FREE;
	currThread = -1;

	// add your threads
	int threadID;
	threadID = scheduler_startThread (&functionGreen);
	threadID = scheduler_startThread (&functionRed);
	threadID = scheduler_startThread (&functionGreen);
	threadID = scheduler_startThread (&functionRed);
	threadID = scheduler_startThread (&functionGreen);
	threadID = scheduler_startThread (&functionRed);
	threadID = scheduler_startThread (&functionGreen);
    threadID = scheduler_startThread (&functionRed);

	// ok, now enable the interrupts for everything to just magically start
	__enable_interrupt();

	// now just do nothing so the program can run for ever...
	while (1==1) {

		// currently do nothing
		// just loafing aroung
	}
}
int main(void) {
// Disable interrupts. ("Clear interrupt bit")
cli();
// One-time setup operations.
setupSerialPort();
setupRightLED();
setupLeftLED();
setupTimer();
// Enable interrupts. ("Set interrupt bit")
sei();
byteTx(128); // Start the open interface.
byteTx(132); // Switch to full mode.
// Toggle the LEDs once each second.
while(2+2==4) {
rightLEDon();
leftLEDoff();
byteTx(139); // Opcode for "Set LEDs"
byteTx(10); // Led bits: both on
byteTx(0); // Power led color: Fully green
byteTx(255); // Power led intensity
delayMs(1000);
rightLEDoff();
leftLEDon();
byteTx(139); // Opcode for "Set LEDs"
byteTx(0); // Led bits: both off
byteTx(255); // Power led color: Fully red
byteTx(255); // Power led intensity
delayMs(1000);
}
}
示例#7
0
int main(void)
{
	
	DO_TEST_HARNESS_PRE_INIT();

	setupIO();
	setupADC();
	setupTimer();
	setupStateMachine();
	
	pAverager = AVERAGER_GetAverager(U16, BUFFER_SIZE);
	
	sei();
	
	WD_DISABLE();
	
	DO_TEST_HARNESS_POST_INIT();
	
	while (true)
	{
		DO_TEST_HARNESS_RUNNING();
		
		if (ADC_TestAndClear(&adc))
		{
			adcHandler();
		}
		
		if (TMR8_Tick_TestAndClear(&appTick))
		{
			applicationTick();
		}		
	}

	return 0;
}
示例#8
0
int main(void)
{
	setupTimer();
	setupPWM();
	DDRB = 0xFF;
    while(1)
    {}
}
示例#9
0
void EventTimer::handleTimerEvent(const boost::system::error_code& error)
{
  if (!error && interval_ > 0)
  {
    (*callable_)(this);
    if (repetitively_) // if timer is not single shot type
      setupTimer(); // setup next trigger
  }
}
示例#10
0
void plugin::addToEvents(const QDateTime& nextTimeout, const plugin::EventTimeStructure& ts) {
    mEvents.insert(nextTimeout, ts);
    // property update
    SceneDocument sc = SceneDocument::createModelChangeItem("time.alarms");
    sc.setData("uid", ts.eventid);
    sc.setData("seconds", QDateTime::currentDateTime().secsTo(nextTimeout));
    changeProperty(sc.getData());
    setupTimer();
}
KQueueEventDispatcher::KQueueEventDispatcher() {
    // create the event queue
    eventFd = kqueue();

    // set up an event pipe
    setupEventPipe();

    // set up an event timer
    setupTimer();
}
示例#12
0
void main(void)
{
	__disable_interrupt();
	sysInit();
	setupIR();
	setupTimer();
	__enable_interrupt();
	
  __bis_SR_register(LPM3_bits + GIE);
}
示例#13
0
void initializeCommandModule(void){
  // Disable interrupts. ("Clear interrupt bit")
  cli();

  // One-time setup operations.
  setupIOPins();
  setupTimer();
  setupSerialPort();

  // Enable interrupts. ("Set interrupt bit")
  sei();
}
示例#14
0
//--------------------------------------------------------------
void ofApp::setup()
{
    ofSetFrameRate(FRAMERATE);
    // Setup Variables
    setupVariables();
    // Looks for masks inside of the Masks folder
    setupMasks();
    // Setup the GUI
    setupGUI();
    // Setup the Timer
    setupTimer();
    // Setup Custom openCV Class
    openCV.setup(CAM_WIDTH,CAM_HEIGHT,FRAMERATE);    
}
示例#15
0
void plugin::removeEvent ( const QString& eventid) {
    SceneDocument s = SceneDocument::createModelRemoveItem("time.alarms");
    QMutableMapIterator<QDateTime, EventTimeStructure>  i(mEvents);
    while(i.hasNext()) {
        i.next();
        if (i.value().eventid == eventid) {
            // property update
            s.setData("uid", eventid);
            changeProperty(s.getData());
            i.remove();
        }
    }
    setupTimer();
}
示例#16
0
文件: main.c 项目: LOGre/fpgaSynths
void setup(void)
{
	// setup 1KHz timer
	setupTimer();	
	
	// init LCD
	LCD_init();
	
	// init PPS
	// SPKR thru PPS
	pinMode(OUTPUTPIN,OUTPUT);
	pinModePPS(OUTPUTPIN,HIGH);
	outputPinForFunction( OUTPUTPIN, 14); 	
	
	/* set all the channels to same frequency, max level, no noise */
	/*unsigned int slots[] = { 10, 11 };
	unsigned int i;
	ym2149_channel_t chan;

	for (i = 0; i < sizeof(slots) / sizeof(slots[0]); ++i)
	{
		
		// select the YM module
		setDeviceSlot(slots[i]);

		for (chan = YM2149_CH_A; chan < YM2149_CH_MAX; ++chan)
		{
			setChannelFrequency(chan, 0x0500);
			setChannelMixerNoise(chan, 1); // 1 means disabled
			setChannelMixerTone(chan, 0);
			setChannelVolume(chan, 0x0f);
		}
	}*/


	setDeviceSlot(10);
	setChannelFrequency(YM2149_CH_C, 0x0500);
	setChannelMixerNoise(YM2149_CH_C, 1); // 1 means disabled
	setChannelMixerTone(YM2149_CH_C, 0);
	setChannelVolume(YM2149_CH_C, 0x0f);

	pokey_setDeviceSlot(12); 
	pokey_channel_t pokchan;
	for (pokchan = POKEY_CH_A; pokchan < POKEY_CH_D; ++pokchan) 
	{ 
		pokey_setChannelPeriodMultiplier(pokchan, 0x90); 
		pokey_setChannelControl(pokchan, 0x00); 	 
	}
	pokey_setAudioCtrl(0x0);
}
void RateClass::slot_send()
{
    // hey, we don't need to send anything
    if ( d->packetQueue.isEmpty() ) {
        return;
    }

    emit dataReady( d->packetQueue.dequeue() );
    d->bWaitingToSend = false;

    // more to go
    if ( !d->packetQueue.isEmpty() ) {
        setupTimer();
    }
}
示例#18
0
void plugin::timeout() {
    QMutableMapIterator<QDateTime, EventTimeStructure>  i(mEvents);
    while(i.hasNext()) {
        i.next();
        if (abs(QDateTime::currentDateTime().secsTo(i.key())) < 10) {
            plugin::EventTimeStructure ts = i.value();
            qDebug()<<"Alarm triggered"<<ts.sceneid;
            eventTriggered(ts.eventid, ts.sceneid);
            i.remove();
            if (ts.periodic)
                calculate_next_periodic_timeout(ts);
        }
    }
    setupTimer();
}
示例#19
0
文件: ex2.c 项目: imre-kerr/tdt4258
/* Your code will start executing here */
int main(void) 
{
	/* Call the peripheral setup functions */
	setupGPIO();
	setupDAC();
	setupTimer(SAMPLE_PERIOD);


	/*
	 * Deep sleep while waiting for interrupts
	 */
	*SCR = 6; //0110
	__asm volatile ("wfi");

	return 0;
}
示例#20
0
void main(void){

	configClock();
	setupPorts();

	setupTimer();

	_EINT();   // Not really necessary since CPU is going to LPM3 @ the main

	TACCTL0 &= ~CCIE;

	while(1)
	{
		__low_power_mode_3(); //enter LPM3 w/GIE
	}
}
示例#21
0
KinectV2Camera::KinectV2Camera()
{
    //Discovery device
    if(freenect2.enumerateDevices() == 0) {
        perror("FREENECT ERROR: no device connected");
        return;
    }

    string serial = freenect2.getDefaultDeviceSerialNumber();

    //Open device
    dev = freenect2.openDevice(serial);
    if(dev==0) {
        perror("OPENNI ERROR: Can't open device");
        return;
    }

    //Set listener
    listener = new libfreenect2::SyncMultiFrameListener(libfreenect2::Frame::Color | libfreenect2::Frame::Ir | libfreenect2::Frame::Depth);

    dev->setColorFrameListener(listener);
    dev->setIrAndDepthFrameListener(listener);

    gvdevice = new GVDevice("Microsoft Corp.",
                            "Kinect V2",
                            serial);
    gvdevice->configure3DCapabilities(70,60);

    gvdevice->createStreamChannel();
    gvdevice->createStreamChannel();
    gvdevice->createStreamChannel();

    connect(this,SIGNAL(initialization()),this,SLOT(setupTimer()));

    depthMap = new PixelMap(GVSP_PIX_MONO32, 512,424,0,0,0,0);
    colorMap = new PixelMap(GVSP_PIX_BGRA8, 1920,1080,0,0,0,0);
    DepthColorMap = new PixelMap(GVSP_PIX_MONO16_RGB8, 512, 424,0,0,0,0);

    initOk=true;

    dev->start();

    registration = new libfreenect2::Registration(dev->getIrCameraParams(), dev->getColorCameraParams());
    undistorted = new libfreenect2::Frame(512,424,4);
    registered = new libfreenect2::Frame(512,424,4);
}
int main(void)
{	
  //write enable port 0, 1, 2
  DDRB = (1<<PB0) | (1<<PB1) | (1<<PB2);
  
  //read enable port 3 
  DDRB |= (0<<PB3);
  
  //enable port 3 pullup
  PORTB |= (1<<PB3);

  //configure the PWM and timer interrupts
  setupTimer();

	//set the initial state
	state=ANIMATE;
	msAnimateStart = millis;
	channel=A;
	
	//if the button is held down, reset the color
	if (readPin(BUTTON_PIN)==false) {
		hue[A]=0.001;
		hue[B]=0.501;
		saveABColors(hue[A], hue[B]);
		
		//wait until the button is released
		do {
			delay(MSEC_BUTTON_DEBOUNCE);
		} while (readPin(BUTTON_PIN)==false);
	}
	//otherwise load the saved color
	else {
		loadABColors(&hue[A], &hue[B]);
	}

	//set the initial color
	//updateColor(hue[A]);	

	//input handling loop
	while(true) {
		loop();
	}
	
	return 0;
}
示例#23
0
void
CClient::connect()
{
	if (m_stream != NULL) {
		return;
	}
	if (m_suspended) {
		m_connectOnResume = true;
		return;
	}

	try {
		// resolve the server hostname.  do this every time we connect
		// in case we couldn't resolve the address earlier or the address
		// has changed (which can happen frequently if this is a laptop
		// being shuttled between various networks).  patch by Brent
		// Priddy.
		m_serverAddress.resolve();

		// create the socket
		IDataSocket* socket = m_socketFactory->create();

		// filter socket messages, including a packetizing filter
		m_stream = socket;
		if (m_streamFilterFactory != NULL) {
			m_stream = m_streamFilterFactory->create(m_stream, true);
		}
		m_stream = new CPacketStreamFilter(m_stream, true);

		// connect
		LOG((CLOG_DEBUG1 "connecting to server"));
		setupConnecting();
		setupTimer();
		socket->connect(m_serverAddress);
	}
	catch (XBase& e) {
		cleanupTimer();
		cleanupConnecting();
		delete m_stream;
		m_stream = NULL;
		LOG((CLOG_DEBUG1 "connection failed"));
		sendConnectionFailedEvent(e.what());
		return;
	}
}
示例#24
0
void main(void)
{
    SDA = SCL = 1;
    SCL_IN = SDA_IN = 0;
    i2ccmd.address = 0xb0;
    i2ccmd.command = 'U';
    i2ccmd.measureType = 1;
    i2ccmd.fetchCount = 1;
    setupTimer();
    //setupTerminal();
    //setupI2C();
    while(1) {
        communications();
        if (flagTimer) {
            //communications();
            flagTimer = 0;
        }
    }
}
示例#25
0
int main(void)
{

	/* Disable watchdog: not required for this application */
	MCUSR &= ~(1 << WDRF);
	wdt_disable();

	setupTimer();
	setupIO();
	
	UI_Init();

	/* All processing interrupt based from here*/

	DO_TEST_HARNESS_SETUP();
	
	sei();

	// Update display on first application tick
	s_settings = Strobe_Init();
	s_bSettingsChanged = true;
	
	while (true)
	{
		DO_TEST_HARNESS_RUNNING();
		
		UI_Tick();
		
		if (TMR8_Tick_TestAndClear(&appTick))
		{
			applicationTick();
			DO_TEST_HARNESS_TICK();
		}

		if (TMR8_Tick_TestAndClear(&heartbeatTick))
		{
			IO_Control(IO_PORTB, 5, IO_TOGGLE);
		}
	}

	return 0;
}
示例#26
0
文件: ex2.c 项目: Catuna/TDT4258
int main(void) 
{  
  setupGPIO();                //Setup general purpose input/output
  setupDAC();                 //Setup digital to analog converter
  setupTimer();               //Setup timer
  
  /*page 140 manual. Used to prescale the clock. 
   *Only used for testing purposes*/
  //*CMU_HFPERCLKDIV = (1<<8) | (4 << 0);

  //Setup ability to deep sleep
  *SETUP_SCR |= 6;

  while(1)
  {
	   wfi();	 //call wait for inerrupt
  }

  return 0;
}
示例#27
0
void setup(void) {
  
  // Turn off interrupts  
  cli();

  // Reset buffer locations
  LightBuffer.bufferLocation = 0;
  SoundBuffer.bufferLocation = 0;

  setupIO();

  prepareADC();

  enableSPI();

  setupTimer();

  // Unleash the interrupts!
  sei();
}
示例#28
0
文件: ex2.c 项目: krissvor/TDT42581
int main(void) 

{  

  /* Call the peripheral setup functions */

  setupGPIO();

  setupDAC();

  setupTimer(SAMPLE_PERIOD);

  

  /* Enable interrupt handling */



  *SCR = 2;

  setupNVIC();

  __asm volatile("wfi");

  

  /* TODO for higher energy efficiency, sleep while waiting for interrupts

     instead of infinite loop for busy-waiting

  */

  while(1);



  return 0;

}
int main() {
// Disable interrupts. ("Clear interrupt bit")
cli();
// One-time setup operations.
setupSerialPort();
setupRightLED();
setupLeftLED();
setupTimer();
// Enable interrupts. ("Set interrupt bit")
sei();
byteTx(128); // Start the open interface.
byteTx(132); // Switch to full Mode
while(2+2==4) {
delayMs(100);
// Ask the robot about its bump sensors.
byteTx(142); // Opcode for "Read sensors"
byteTx(7); // Sensor packet 7: Bumps and wheel drops
// Read the one-byte response and extract the relevant bits.
uint8_t bumps = byteRx();
uint8_t bumpRight = bumps & (1 << 0);
uint8_t bumpLeft = bumps & (1 << 1);
// Set the command module LEDs based on this sensor data.
if(bumpLeft) {
leftLEDon();
}
else {
leftLEDoff();
}
if(bumpRight) {
rightLEDon();
}
else {
rightLEDoff();
}
}
}
示例#30
0
int main(void)
{
	cli();
	// Disable the watchdog
	wdt_disable();
	
	// Setup LEDS
	setupLeds();
	
	// Two second blink
	setLeds(0xFF);
	_delay_ms(2000);
	setLeds(0);
	
	setupTimer();
	
	setupInterrupt();

	// Enable interrupts
	sei();
	
	// Halt
	while(1);
}