Ejemplo n.º 1
0
/** Main program entry point. This routine configures the hardware required by the application, then
 *  starts the scheduler to run the USB management task.
 */
int main(void)
{
	/* Disable watchdog if enabled by bootloader/fuses */
	MCUSR &= ~(1 << WDRF);
	wdt_disable();

	/* Disable Clock Division */
	SetSystemClockPrescaler(0);

	/* Hardware Initialization */
	Joystick_Init();
	LEDs_Init();
	HWB_Init();
	
	/* Millisecond timer initialization, with output compare interrupt enabled for the idle timing */
	OCR0A  = 0x7D;
	TCCR0A = (1 << WGM01);
	TCCR0B = ((1 << CS01) | (1 << CS00));
	TIMSK0 = (1 << OCIE0A);

	/* Indicate USB not ready */
	UpdateStatus(Status_USBNotReady);
	
	/* Initialize USB Subsystem */
	USB_Init();

	/* Main program code loop */
	for (;;)
	{
		/* No main code -- all USB code is interrupt driven */
	}
}
Ejemplo n.º 2
0
/** Main program entry point. This routine configures the hardware required by the application, then
 *  starts the scheduler to run the application tasks.
 */
int main(void)
{
	/* Disable watchdog if enabled by bootloader/fuses */
	MCUSR &= ~(1 << WDRF);
	wdt_disable();

	/* Disable Clock Division */
	SetSystemClockPrescaler(0);

	/* Hardware Initialization */
	LEDs_Init();
	Dataflash_Init(SPI_SPEED_FCPU_DIV_2);

	/* Clear Dataflash sector protections, if enabled */
	DataflashManager_ResetDataflashProtections();
	
	/* Indicate USB not ready */
	UpdateStatus(Status_USBNotReady);
	
	/* Initialize Scheduler so that it can be used */
	Scheduler_Init();

	/* Initialize USB Subsystem */
	USB_Init();

	/* Scheduling - routine never returns, so put this last in the main function */
	Scheduler_Start();
}
Ejemplo n.º 3
0
int
main (void)
{
    /* Disable watchdog if enabled by bootloader/fuses. */
    MCUSR &= ~(1 << WDRF);
    wdt_disable ();
    /* Disable Clock Division. */
    SetSystemClockPrescaler (0);
    /* Initialise hardware. */
    select_init ();
    /* Initialize USB Subsystem. */
    USB_Init ();
    /* Main loop. */
    while (1)
      {
	if (usb_connected)
	    USB_USBTask ();
	if (usb_configured)
	  {
	    usb_twi_task ();
	  }
      }
}
Ejemplo n.º 4
0
int main(void)
{
	SetSystemClockPrescaler(0);
	init();
	sei();

	led_blink(3);

     while (1)
     {
    	if(SW_ACTIVE())
    	{
    		// SW pressed
    		uint8_t pressCnt = 100;

    		// wait until released
    		do
    		{
				// long term press detected?
    			if(pressCnt>0 && --pressCnt==0)
    				LED_ON();

    			_delay_ms(10);
    		} while(SW_ACTIVE());


    		// SW released
    		LED_OFF();
    		if(pressCnt>0)
    			handleSensor(1); // force transmit
    		else
    		{
    			// program mode
        		LED_ON();
        		fs20_resetbuffer();
        		fs20_rxon();
        		fstelegram_t t;
        		t.type = 'U'; // undefined
        		pressCnt = 100;

        		// wait for next telegram
        		// exit if button pressed or timeout occured
        		while(!fs20_readFS20Telegram(&t) && --pressCnt>0 && !SW_ACTIVE())
        			_delay_ms(100);

        		fs20_idle();
        		LED_OFF();

        		// save the result
        		if(t.type=='F')
        		{
        			saveConfig(t.housecode, t.button);
        			led_blink(2); // confirm save of config
        			handleSensor(1); // force transmit
        		}

        		// wait until sw releases
        		while(SW_ACTIVE());
    		}
    	}

		// check long term timer
		if(longTimerCnt >= LONGTIMER_VAL)
			handleSensor(1);

		// finaly check if sensor value changed
		// this will only be the case if the current sensor value haven't been sent
		// during this cycle
		handleSensor(0);

		// sleep well
		LED_OFF();
		SENS_ACTIVATE(0);
		set_sleep_mode(SLEEP_MODE_PWR_DOWN);
		sleep_mode();
     }
}