void mls_Timing_Init(void)
{
	timer_init(QN_TIMER1, TMR1_Tick);
   timer_config(QN_TIMER1, TIMER_PSCAL_DIV, TIMER_COUNT_US(1000, TIMER_PSCAL_DIV));
   timer_enable(QN_TIMER1, MASK_ENABLE);
	Time_Tick = 0;
}
示例#2
0
文件: demo.c 项目: lijie169/stm32-tcp
int main(void)
{
//	uint32_t pre = 0 ;
	uint8_t* p = 0;
	timer_config();
	SPIx_Init();
	Led_Init();

	Key_Init();
	Usart2_Init(9600);
//	enc28j60_init(mac);
	install_uart_dev();
	stack_init();
//	test_hardhandler(2,(int*)1);
	my_tftp_init();
	telnet_service_init();
//	web_server_init();
//	*p = 1 ;
	#if 0
	while(1)
	{
		stack_process();
		Led_Process();
		shell();
		
	}
	#endif
	bootstart();

 return 0 ;
}
示例#3
0
文件: main.c 项目: Arcko/trochili
/*!
    \brief      main function
    \param[in]  none
    \param[out] none
    \retval     none
*/
int main(void)
{
    gpio_config(); 
    timer_config();

    while (1);
}
示例#4
0
文件: timer.c 项目: volans/apos
/*
 *	有了 timer_enable(),我们就可以方便的调整任何一个timer的频率并开启它
 */
void timer_enable(unsigned char timerX,unsigned int freq)
{
	switch(timerX)
	{
		case TIMER_0:
			irq_mask(INT_TIMER0,IRQ_MASK);
			timer_config(TIMER_0,26406/freq,0);
			timer_start(TIMER_0);
			irq_rotunie[INT_TIMER0]=&do_timer0;
			irq_mask(INT_TIMER0,IRQ_UNMASK);
			break;
			
		case TIMER_1:
			irq_mask(INT_TIMER1,IRQ_MASK);
			timer_config(TIMER_1,26406/freq,0);
			timer_start(TIMER_1);
			irq_rotunie[INT_TIMER1]=&do_timer1;
			irq_mask(INT_TIMER1,IRQ_UNMASK);
			break;
			
		case TIMER_2:
			irq_mask(INT_TIMER2,IRQ_MASK);
			timer_config(TIMER_2,26406/freq,0);
			timer_start(TIMER_2);
			irq_rotunie[INT_TIMER2]=&do_timer2;
			irq_mask(INT_TIMER2,IRQ_UNMASK);
			break;
			
		case TIMER_3:
			irq_mask(INT_TIMER3,IRQ_MASK);
			timer_config(TIMER_3,26406/freq,0);
			timer_start(TIMER_3);
			irq_rotunie[INT_TIMER3]=&do_timer3;
			irq_mask(INT_TIMER3,IRQ_UNMASK);
			break;
			
		case TIMER_4:
			irq_mask(INT_TIMER4,IRQ_MASK);
			timer_config(TIMER_4,26406/freq,0);
			timer_start(TIMER_4);
			irq_rotunie[INT_TIMER4]=&do_timer4;
			irq_mask(INT_TIMER4,IRQ_UNMASK);
			break;
	}

}
示例#5
0
文件: main.c 项目: Arcko/trochili
/*!
    \brief      main function
    \param[in]  none
    \param[out] none
    \retval     none
*/
int main(void)
{
    gpio_config(); 
    gd_eval_ledinit(LED1);
    timer_config();

    while (1);
}
示例#6
0
void __init mmp_timer_init(int irq, unsigned long rate)
{
	timer_config();

	sched_clock_register(mmp_read_sched_clock, 32, rate);

	ckevt.cpumask = cpumask_of(0);

	setup_irq(irq, &timer_irq);

	clocksource_register_hz(&cksrc, rate);
	clockevents_config_and_register(&ckevt, rate, MIN_DELTA, MAX_DELTA);
}
示例#7
0
void __init timer_init(int irq)
{
    timer_config();

    sched_clock_register(mmp_read_sched_clock, 32, MMP_CLOCK_FREQ);

    ckevt.cpumask = cpumask_of(0);

    setup_irq(irq, &timer_irq);

    clocksource_register_hz(&cksrc, MMP_CLOCK_FREQ);
    clockevents_config_and_register(&ckevt, MMP_CLOCK_FREQ,
                                    MIN_DELTA, MAX_DELTA);
}
示例#8
0
void __init timer_init(int irq)
{
	timer_config();

	setup_sched_clock(mmp_read_sched_clock, 32, CLOCK_TICK_RATE);

	ckevt.mult = div_sc(CLOCK_TICK_RATE, NSEC_PER_SEC, ckevt.shift);
	ckevt.max_delta_ns = clockevent_delta2ns(MAX_DELTA, &ckevt);
	ckevt.min_delta_ns = clockevent_delta2ns(MIN_DELTA, &ckevt);
	ckevt.cpumask = cpumask_of(0);

	setup_irq(irq, &timer_irq);

	clocksource_register_hz(&cksrc, CLOCK_TICK_RATE);
	clockevents_register_device(&ckevt);
}
示例#9
0
/**
 * @brief Function for application main entry.
 */
int main(void) {

    // setup
    gpio_config();
    hfclk_config();
    timer_config();

    // loop
    while (true) {
            // Enter System ON sleep mode
            __WFE();
            // Make sure any pending events are cleared
            __SEV();
            __WFE();
    }
}
static void
timer_hb_attach(device_t parent, device_t self, void *aux)
{
	struct hb_attach_args *ha = aux;

	if (ha->ha_ipl != TIMER_LEVEL)
		panic("clock_hb_attach: wrong interrupt level");

	ctrl_timer = (uint8_t *)(ha->ha_address); /* XXX needs bus_space */

	printf("\n");

	timer_config(timer_hb_initclocks);

#if 0 /* XXX this will be done in timer_hb_initclocks() */
	isrlink_custom(ha->ha_ipl, (void *)_isr_clock);
#endif
}
示例#11
0
void __init timer_init(int irq)
{
	timer_config();

	set_tcr2ns_scale(CLOCK_TICK_RATE);

	ckevt.mult = div_sc(CLOCK_TICK_RATE, NSEC_PER_SEC, ckevt.shift);
	ckevt.max_delta_ns = clockevent_delta2ns(MAX_DELTA, &ckevt);
	ckevt.min_delta_ns = clockevent_delta2ns(MIN_DELTA, &ckevt);
	ckevt.cpumask = cpumask_of(0);

	cksrc.mult = clocksource_hz2mult(CLOCK_TICK_RATE, cksrc.shift);

	setup_irq(irq, &timer_irq);

	clocksource_register(&cksrc);
	clockevents_register_device(&ckevt);
}
示例#12
0
文件: main.c 项目: Arcko/trochili
/*!
    \brief      main function
    \param[in]  none
    \param[out] none
    \retval     none
*/
int main(void)
{
    /* configure RCU */
    rcu_config();
    
    /* configure GPIO */
    gpio_config();
    
    /* configure leds */
    gd_eval_ledinit(LED3);
    
    /* configure comparator channel0 */
    cmp_mode_init(CMP_CHANNEL_CMP0, CMP_VERYLOWSPEED, CMP_1_4VREFINT, CMP_HYSTERESIS_NO);
    cmp_output_init(CMP_CHANNEL_CMP0, CMP_OUTPUT_TIM1IC3, CMP_OUTPUT_POLARITY_NOINVERTED);
    
    /* configure TIMER */
    timer_config();
    
    /* enable comparator channel0 */
    cmp_channel_enable(CMP_CHANNEL_CMP0);
    while(1);
}
示例#13
0
int main(void)
 {	
		

    // b. Umleiten der Standardausgabe stdout (Teil 2)
    //stdout = &mystdout;
 
 	// Init everything
	// Init Touch & Potis
	DDRA = 0x00; // ADWandler-Pins auf Eingang schalten
	uint16_t ADC_val;

	ADC_Init();
	// Init LED Matrix
	TLC5940_Init();
	// Init SPI
	init_SPI();
	// Init Timer
	timer_config();

	TLC5940_SetAllDC(63);
	TLC5940_ClockInDC();
	TLC5940_SetAllGS(0);	

	// Init all 74hc595
	init_74hc595();
	// Init all 74hc165
	init_74hc165();

	// Enable Interrupts globally


	// TEMP TEMP TEMP
	DDRC |= 0b01000000;

	// Kalibriere Touchpanel
	calibrate();
	sei();
	// Init UART
	uart_init();

	
	
	while (1)
	{
		static uint8_t current_potentiometer = 0;

		// POTENTIOMETER auslesen
		{		
			/*	switch( current_potentiometer )
			{
			//	case 1:
			//		PORTC &= ~0b01000000;
			//		break;
				case 2:
					PORTC |= 0b01000000;	
					break;

			}	*/		
			

			// erstes Auslesen immer Fehlerhaft wegen Touchpanel evtl
			// zweiter Wert beinhaltet richtiges Ergebniss!
			// POTI_ADC_SAMPLES sollte daher 2 sein damit nach dem zweiten lesen in ADC_val das richtige ergebniss steht
			ADC_val = 0;		
			for  ( uint8_t count = 0 ; count < POTI_ADC_SAMPLES ; count++ )   
				ADC_val = ADC_Read(potentiometer[current_potentiometer].adc_channel);


			if( ADC_val  > ( potentiometer[current_potentiometer].value + ADC_delta_for_change_poti ) || ( ADC_val  < ( potentiometer[current_potentiometer].value - ADC_delta_for_change_poti ) ) )  // +- 8 von 1024 Quantisierungsstufen / 128 Midi Schritte .  // if( ADC_val  > ( potentiometer[current_potentiometer].value + 10 ) || ( ADC_val  < ( potentiometer[current_potentiometer].value - 10 ) ) )																																			
			{
				potentiometer[current_potentiometer].value = ADC_val;
				controlChange(midi_channel, midi_poti_offset + current_potentiometer,ADC_val/8);
				//printf("%i. Poti %i\n", current_potentiometer , potentiometer[current_potentiometer].value );
			}

			current_potentiometer++;
			
			if ( current_potentiometer == potentiometer_count)
				current_potentiometer = 0;
		}

		
		//Display_SetCross(4,2);
		// TOUCHPANEL auslesen

		read_touchscreen();
	  
	  	  if(touchscreen.FLAG_Display_change) 
		  {
			TLC5940_SetAllGS(0);
			//Display_SetParabel(touchscreen.last_x , touchscreen.last_y );
			Display_SetCross(touchscreen.last_LED_x,touchscreen.last_LED_y);
			touchscreen.FLAG_Display_change = 0;
		  }	
	
  	}

	
}
示例#14
0
int main (void) 
{

    SystemInit();

    /* Initialize GPIO (sets up clock) */
    gpio_init(NULL);
    /* Set all pin to output */
    gpio_set_direction_field(LED_PINS, (uint32_t)GPIO_OUTPUT);
    gpio_write_pin_field(LED_PINS, (uint32_t)GPIO_HIGH);
    
    
#if TIMER_INTERRUPT_EXAMPLE
    timer_init(QN_TIMER0, led0_link);
    timer_config(QN_TIMER0, TIMER_PSCAL_DIV, TIMER_COUNT_US(1000, TIMER_PSCAL_DIV));
    timer_enable(QN_TIMER0, MASK_ENABLE);

    timer_init(QN_TIMER1, led1_link);
    timer_config(QN_TIMER1, TIMER_PSCAL_DIV, TIMER_COUNT_US(2000, TIMER_PSCAL_DIV));
    timer_enable(QN_TIMER1, MASK_ENABLE);

    timer_init(QN_TIMER2, led2_link);
    timer_config(QN_TIMER2, 10, TIMER_COUNT_MS(3, 10));
    timer_enable(QN_TIMER2, MASK_ENABLE);

    timer_init(QN_TIMER3, led3_link);
    timer_config(QN_TIMER3, 10, TIMER_COUNT_MS(4, 10));
    timer_enable(QN_TIMER3, MASK_ENABLE);
#endif

#if TIMER_PWM_EXAMPLE
    //P3.5 will output pwm wave with period for 1000us and pulse for 500us 
    timer_init(QN_TIMER0, NULL);
    timer_pwm_config(QN_TIMER0, TIMER_PSCAL_DIV, TIMER_COUNT_US(1000, TIMER_PSCAL_DIV), TIMER_COUNT_US(500, TIMER_PSCAL_DIV));
    timer_enable(QN_TIMER0, MASK_ENABLE);
    
    //P1.1 will output pwm wave with period for 2000us and pulse for 1000us
    timer_init(QN_TIMER1, NULL);
    timer_pwm_config(QN_TIMER1, TIMER_PSCAL_DIV, TIMER_COUNT_US(2000, TIMER_PSCAL_DIV), TIMER_COUNT_US(1000, TIMER_PSCAL_DIV));
    timer_enable(QN_TIMER1, MASK_ENABLE);
    
    //P2.6 will output pwm wave with period for 4ms and pulse for 2ms
    timer_init(QN_TIMER2, NULL);
    timer_pwm_config(QN_TIMER2, 10, TIMER_COUNT_MS(4, 10),  TIMER_COUNT_MS(2, 10));
    timer_enable(QN_TIMER2, MASK_ENABLE);
    
    //P2.3 will output pwm wave with period for 6ms and pulse for 3ms
    timer_init(QN_TIMER3, NULL);
    timer_pwm_config(QN_TIMER3, 10, TIMER_COUNT_MS(6, 10),  TIMER_COUNT_MS(3, 10));
    timer_enable(QN_TIMER3, MASK_ENABLE);
#endif

#if TIMER_CAPTURE_TIMER_MOD_EXAMPLE
    /*
     * Capture timer mode is to capture trigger event, and record the time-stamp.
     *
     * Make sure the macro TIMER0_CAP_MODE is INCAP_TIMER_MOD. 
     *
     * Timer0 will capture the P3.5 rising edge, and each rising edge will trigger 
     * the callback function, as the same time the counter value will transmit to 
     * timer0_env.count.
     * 
     * Other timers are similar to this.
     */
    timer_init(QN_TIMER0, timer0_callback);
    timer_capture_config(QN_TIMER0, INCAP_TIMER_MOD, 0, 0, 0);
    timer_enable(QN_TIMER0, MASK_ENABLE);
#endif

#if TIMER_CAPTURE_COUNTER_MOD_EXAMPLE
    /*
     * Capture event mode is to calculate the time of happened specified event with 
     * specified numbers.
     *
     * Make sure the macro TIMER0_CAP_MODE is INCAP_COUNTER_MOD. 
     *
     * Timer0 will count the time during 5 times rising edge of P3.5. After that, the 
     * callback function will be called, as the same time the time value will transmit to 
     * timer0_env.count.
     * 
     * Other timers are similar to this.
     */
    timer_init(QN_TIMER0, timer0_callback);
    timer_capture_config(QN_TIMER0, INCAP_COUNTER_MOD, 100, 0, 5);
    timer_enable(QN_TIMER0, MASK_ENABLE);
#endif

#if TIMER_CAPTURE_EVENT_MOD_EXAMPLE
    /*
     * Capture conter mode is used to count the numbers of a special event during a specified period.
     * 
     * Make sure the macro TIMER0_CAP_MODE is INCAP_EVENT_MOD. 
     *
     * Timer0 will count the numbers of rising edge during 1000ms with P3.5, and each rising 
     * edge will trigger the callback function, as the same time the counter value will transmit 
     * to timer0_env.count.
     * 
     * Other timers are similar to this.
     */
    timer_init(QN_TIMER0, timer0_callback);
    timer_capture_config(QN_TIMER0, INCAP_EVENT_MOD, 100, TIMER_COUNT_MS(1000, 100), 0);
    timer_enable(QN_TIMER0, MASK_ENABLE);
#endif

    while (1)                                /* Loop forever */
    {        
       
    }
}
示例#15
0
int main (void) 
{
    
    SystemInit();
    
#if 0
    if (0x00000004 & inp32(0x40000038)) {
        outp32(0x40000038, 0x80000000);
    }
    else {
        Led_flash();
        while(1);
    }
#endif
    
    /* Initialize GPIO */
    gpio_init(cb_gpio);
    
#if TEST_SLEEP_NORMAL == TRUE
    // --------------------------------------------
    // sleep wakeup
    // --------------------------------------------
    
    //set all pin to gpio
    syscon_SetPMCR0(QN_SYSCON, 0x00000000);
    syscon_SetPMCR1(QN_SYSCON, 0x00000000);
    //set all gpio input
    gpio_set_direction_field(GPIO_PIN_ALL, GPIO_INPUT); 
    gpio_write_pin_field(GPIO_PIN_ALL, (uint32_t)GPIO_HIGH);    
    // pin pull ( 00 : High-Z,  01 : Pull-down,  10 : Pull-up,  11 : Reserved )
    syscon_SetPPCR0(QN_SYSCON, 0xAAAA5AAA); // SWD pull-down save 20uA
    syscon_SetPPCR1(QN_SYSCON, 0x2AAAAAAA);  
    
    // power down BUCK needed
    syscon_SetIvrefX32WithMask(QN_SYSCON, SYSCON_MASK_BUCK_BYPASS|SYSCON_MASK_BUCK_DPD, MASK_ENABLE);    
    // power down Flash
    syscon_SetPGCR2WithMask(QN_SYSCON, SYSCON_MASK_FLASH_VCC_EN, MASK_DISABLE);
    // enable dbg power down
    syscon_SetPGCR2WithMask(QN_SYSCON, SYSCON_MASK_DBGPMUENABLE, MASK_ENABLE);
    // dis sar adc buffer
    syscon_SetPGCR1WithMask(QN_SYSCON, SYSCON_MASK_DIS_SAR_BUF, MASK_ENABLE);
    Led_flash();

    do {
        delay(10);
    } while (gpio_read_pin(GPIO_P14) == GPIO_HIGH);
    
    sleep_init();
    wakeup_by_sleep_timer(__32K_TYPE);
    wakeup_by_gpio(GPIO_P15, GPIO_WKUP_BY_LOW);
    
    do {
        gpio_set_direction(GPIO_P01, GPIO_INPUT);
        //enter_sleep(SLEEP_NORMAL, WAKEUP_BY_GPIO, Led_flash);
        if (wakeup_from_sleeptimer) {
            sleep_timer_set(32000);
            wakeup_from_sleeptimer = 0;
#if QN_32K_RCO == TRUE
            clock_32k_correction_enable(clock_32k_correction_cb);
#endif
        }

#if QN_32K_RCO == TRUE
        if (gpio_sleep_allowed() && !dev_get_bf())
#else
        if (gpio_sleep_allowed())
#endif
        enter_sleep(SLEEP_NORMAL, WAKEUP_BY_OSC_EN|WAKEUP_BY_GPIO, Led_flash);

    } while(1);
#endif
    
#if TEST_SLEEP_DEEP == TRUE
    // --------------------------------------------
    // deep sleep wakeup
    // --------------------------------------------
    
    //set all pin to gpio
    syscon_SetPMCR0(QN_SYSCON, 0x00000000);
    syscon_SetPMCR1(QN_SYSCON, 0x00000000);
    //set all gpio input
    gpio_set_direction_field(GPIO_PIN_ALL, (uint32_t)GPIO_INPUT); 
    gpio_write_pin_field(GPIO_PIN_ALL, (uint32_t)GPIO_HIGH);
    // pin pull ( 00 : High-Z,  01 : Pull-down,  10 : Pull-up,  11 : Reserved )
    syscon_SetPPCR0(QN_SYSCON, 0xAAAA5AAA); // SWD pull-down save 20uA
    syscon_SetPPCR1(QN_SYSCON, 0x2AAAAAAA);        
    
    // power down BUCK needed
    syscon_SetIvrefX32WithMask(QN_SYSCON, SYSCON_MASK_BUCK_BYPASS|SYSCON_MASK_BUCK_DPD, MASK_ENABLE);
    // power down Flash
    syscon_SetPGCR2WithMask(QN_SYSCON, SYSCON_MASK_FLASH_VCC_EN, MASK_DISABLE);
    // enable dbg power down
    syscon_SetPGCR2WithMask(QN_SYSCON, SYSCON_MASK_DBGPMUENABLE, MASK_ENABLE);
    // dis sar adc buffer
    syscon_SetPGCR1WithMask(QN_SYSCON, SYSCON_MASK_DIS_SAR_BUF, MASK_ENABLE);
    Led_flash();
    
    do {
        delay(10);
    } while (gpio_read_pin(GPIO_P14) == GPIO_HIGH);
    
    sleep_init();
    
    do {
        gpio_set_direction(GPIO_P01, GPIO_INPUT);
        wakeup_by_gpio(GPIO_P15, GPIO_WKUP_BY_CHANGE);
        enter_sleep(SLEEP_DEEP, WAKEUP_BY_GPIO, Led_flash);
                
    } while(1);
#endif

#if TEST_SLEEP_CPU_CLK_OFF == TRUE
    // --------------------------------------------
    // clock gating 
    // --------------------------------------------
    // Set timer 0 wakeup
    timer_init(QN_TIMER0, NULL);
    timer_config(QN_TIMER0, TIMER_PSCAL_DIV, TIMER_COUNT_MS(1000, TIMER_PSCAL_DIV));
    timer_enable(QN_TIMER0, MASK_ENABLE);  

    sleep_init();
    
    do {

        enter_sleep(SLEEP_CPU_CLK_OFF, WAKEUP_BY_TIMER0, NULL);
        Led_flash();
    
    }
    while(1);
#endif
    
    
}
示例#16
0
文件: main.cpp 项目: bnahill/acc_boat
int main(void) {
	uint32_t i;
	FRDMSlave * slave;
	FRDMSlave::data_t * data_iter;
	FRDMSlave::data_t * buffer_end;
	
	halInit();
	chSysInit();
	
	main_thread = chThdSelf();
	
	Platform::early_init();
	
	for(slave = slaves; slave < slaves + num_slaves; slave++){
		slave->init();
	}
	
	timer_config();
	button.set_press_handler((button_t::button_handler)button_cb, nullptr);
	term.launch();
	
	while(true){
		// Wait for a button press
		chEvtGetAndClearEvents(ALL_EVENTS);
		chEvtWaitOne(MAIN_SIG_BUTTON);
		
		/*
		for(slave = slaves; slave < slaves + num_slaves; slave++){
			if(!slave->ping())
				break;
		} if(slave != slaves + num_slaves){
			// One of the slaves didn't respond...
			for(i = 0; i < 10; i++){
				chThdSleep(MS2ST(100));
				leds[0].toggle();
				leds[1].toggle();
				leds[2].toggle();
				leds[3].toggle();
			}
		}
		*/
		
		// Flash lights 3 times
		for(i = 0; i < 5; i++){
			chThdSleep(MS2ST(500));
			leds[0].toggle();
			leds[1].toggle();
			leds[2].toggle();
			leds[3].toggle();
		}
		
		// Let the last one go for a whole second
		chThdSleep(MS2ST(500));
		leds[0].clear();
		leds[1].clear();
		leds[2].clear();
		leds[3].clear();
		
		// Trigger first sample
		sync_pin.toggle();
		timer_start();

		chEvtGetAndClearEvents(MAIN_SIG_BUTTON);
		sample_count = 0;
		data_iter = acc_buffer1;
		buffer_end = acc_buffer1 + sizeof(acc_buffer1)/sizeof(*acc_buffer1);
		while(!chEvtWaitOneTimeout(MAIN_SIG_BUTTON, TIME_IMMEDIATE)){
			chEvtWaitOne(MAIN_SIG_TICK);
			
			for(slave = slaves; slave < slaves + num_slaves; slave++){
				slave->start_read();
			}
			for(slave = slaves; slave < slaves + num_slaves; slave++){
				slave->finish_read(data_iter);
				data_iter += FRDMSlave::samples_per_transfer;
				sample_count += FRDMSlave::samples_per_transfer;
				if(data_iter == acc_buffer1 + (sizeof(acc_buffer1)/sizeof(*acc_buffer1))){
					data_iter = acc_buffer2;
				} else if(data_iter == acc_buffer2 + (sizeof(acc_buffer2)/sizeof(*acc_buffer2))){
					break;
				}
			} if(slave != slaves + num_slaves){
				break;
			}
			
			// Trigger next sample
			sync_pin.toggle();
#if 0
			for(slave = slaves; slave < slaves + num_slaves; slave++){
				slave->finish_read(data_iter);
				data_iter += FRDMSlave::samples_per_transfer;
				if((uint32_t)(buffer_end - data_iter) < FRDMSlave::samples_per_transfer * sizeof(FRDMSlave::data_t)){
					if(data_iter < acc_buffer1){
						// Buffer is full!
						break;
					}
					data_iter = acc_buffer2;
					buffer_end = acc_buffer2 + sizeof(acc_buffer2)/sizeof(*acc_buffer2);
				}
			} if(slave != slaves + num_slaves){
				for(i = 0; i < 10; i++){
					chThdSleep(MS2ST(100));
					leds[0].toggle();
					leds[1].toggle();
					leds[2].toggle();
					leds[3].toggle();
				}
				break;
			}
#endif
			
			leds[0].toggle();
		}
		
		timer_stop();
		
		for(slave = slaves; slave < slaves + num_slaves; slave++){
			slave->stop();
		}
		
		leds[0].clear();
		leds[1].clear();
		leds[2].clear();
		leds[3].clear();
	
		chThdSleep(MS2ST(250));
	}
}