Esempio n. 1
0
int window_fan() {
    rcc_config();
    delay_config();

    led_debug_config();
    motor_config();

    led_blue_off();
    led_green_off();

    servo_config();
    servo_set_pos(0);
    servo_start();

    u32 i;
    u32 from = 0;
    u32 to = 180;
    u32 delay = 2000;

  while(1) {

    motor_forward();

    led_blue_on();
    led_green_off();
    for(i=from; i<to; i++) {
        servo_set_pos(i);
        delay_ms(delay);
    }

    led_blue_off();
    led_green_on();
    for(i=to; i>from; i--) {
        servo_set_pos(i);
        delay_ms(delay);
    }

    motor_stop();
    delay_ms(10000);
  }
}
Esempio n. 2
0
void toggle_leds() {
        if(state == 0 ) {
           led_green_on();
           led_blue_off();
           state = 1;
        } else {
           led_green_off();
           led_blue_on();
           state = 0;
        }
        
}
Esempio n. 3
0
int reader_test() {
    rcc_config();

    led_debug_config();
    motor_config();
    reed_config();
    
    led_blue_off();
    led_green_off();
    
    uint8_t i;
  
    while(1) {
        // forward
        motor_forward();
        led_blue_on();
        reed_delay_left();
        
        // stop
        motor_stop();
        led_blue_off();
        bigDelay();
        bigDelay();
        bigDelay();

        // backward
        motor_back();
        led_green_on();
        reed_delay_right();
        
        // stop
        motor_stop();
        led_green_off();
        bigDelay();
        bigDelay();
        bigDelay();
    }  

}
Esempio n. 4
0
void show_boot_progress(int status)
{
	printf ("Status: %d\n", status);
        led_red_off();
	led_blue_off();

	if (status < -2 ) {
		led_red_on();
		return;
	}
	switch(status){
		case -1: /* Image Header has bad magic number */
			led_red_on();
			break;
						
                case 1:
                        break;
                case 2:
                        break;
                case 3:
                        break;
                case 4:
                        break;
                case 5:
                case 6:
                        break;
                case 7:
                case 8:	/* Image Type check ok */
			led_blue_on();
                        break;
                case 9:
                case 10:
                case 11:
                case 12:
                case 13:
                case 14:
                case 15: /* All preparation done, transferring control to OS */
			led_blue_on();
                        break;
                default:
                        break;
        }
}
Esempio n. 5
0
int stepper_test() {
    rcc_config();
    
    delay_config();
    led_debug_config();
    
    button_config();
    pwm_config();
    SysTick_Config( SystemCoreClock / 10000);

    
    pwm_start();

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
    uart_debug_config();
    //pwm_set(10);
        
    // 10        - 100 ms
    // 100       -  10 ms
    // 1000      -   1 ms
    // 10,000    - 100 us
    // 100,000   -  10 us
    // 1,000,000 -   3 us
     
    led_blue_off();
    led_green_off();

    //TIM2->CCR2 =  10;
    
    RCC_ClocksTypeDef Sys_RCC_Clocks;
    RCC_GetClocksFreq(&Sys_RCC_Clocks);


    debugf("SYSCLK_Frequency : %d Hz\n", Sys_RCC_Clocks.SYSCLK_Frequency);
    debugf("HCLK_Frequency   : %d Hz\n", Sys_RCC_Clocks.HCLK_Frequency);
    debugf("PCLK1_Frequency  : %d Hz\n", Sys_RCC_Clocks.PCLK1_Frequency);
    debugf("PCLK2_Frequency  : %d Hz\n", Sys_RCC_Clocks.PCLK2_Frequency);
    debugf("ADCCLK_Frequency : %d Hz\n", Sys_RCC_Clocks.ADCCLK_Frequency);

    
    int i=0;
    while(1) {
       //delay_ms(1000);
       for (int i=0; i<1000000; i++) {}
       
       if(i>100) i=0;
       i++;
       
       //TIM2->CCR2 =  i;
       //TIM2->CR1 |= TIM_CR1_CEN;
       // led_green_on();
       // led_blue_off();

       // delay_ms(1000);

       // led_green_off();
       // led_blue_on();

       // delay_ms(1000);
    }
}