Ejemplo n.º 1
0
void hal_clocksource_init(void){
    //for debugging clocksource problems
    led_red_on();
    led_green_on();

    //power up osc (?)
    SLEEP &= ~CLOCKSOURCE_OSC_PD_BIT;
    //wait for XOSC stable
    while(!CLOCKSOURCE_XOSC_STABLE()){}
    NOP();

    //start crystal osc as HS clocksource, OSC32 is int rc osc
    CLKCON = 0x80;

    //wait for selection to be active
    while(!CLOCKSOURCE_XOSC_STABLE()){}
    NOP();

    //power down the unused oscillator
    SLEEP |= CLOCKSOURCE_OSC_PD_BIT;


    //for debugging clocksource problems
    led_red_off();
    led_green_off();
}
Ejemplo n.º 2
0
void default_handler (void) {
	uint64_t i;
	led_red_on();
	while (1) {
		for (i=0; i<0x00FFFFF; i++) {}
		led_green_off();
		for (i=0; i<0x00FFFFF; i++) {}
		led_green_on();
	}
	while (1);
}
Ejemplo n.º 3
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);
  }
}
Ejemplo n.º 4
0
void toggle_leds() {
        if(state == 0 ) {
           led_green_on();
           led_blue_off();
           state = 1;
        } else {
           led_green_off();
           led_blue_on();
           state = 0;
        }
        
}
Ejemplo n.º 5
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();
    }  

}
Ejemplo n.º 6
0
Archivo: led.c Proyecto: nesl/sos-2x
int8_t ker_led(uint8_t action)
{
  switch (action){
  case LED_RED_ON:        led_red_on();        break;
  case LED_GREEN_ON:      led_green_on();      break;
  case LED_YELLOW_ON:     led_yellow_on();     break;
  case LED_RED_OFF:       led_red_off();       break;
  case LED_GREEN_OFF:     led_green_off();     break;
  case LED_YELLOW_OFF:    led_yellow_off();    break;
  case LED_RED_TOGGLE:    led_red_toggle();    break;
  case LED_GREEN_TOGGLE:  led_green_toggle();  break;
  case LED_YELLOW_TOGGLE: led_yellow_toggle(); break;
  }
  return 0;
}
Ejemplo n.º 7
0
static PT_THREAD(thread_led_green(struct pt *pt))
{
    PT_BEGIN(pt);

    while(1)
    {
        PT_WAIT_UNTIL(pt, led_green_flag);
        led_green_on();
        TIMER_LED_GREEN_ON = 0;
        PT_WAIT_UNTIL(pt, timer_reached(TIMER_LED_GREEN_ON,
          led_green_duration));
        led_green_off();
        led_green_flag = 0;
    }

    PT_END(pt);
}
Ejemplo n.º 8
0
static void sfi_err_code_led_display(uint8_t errcode)
{
  uint8_t _led_display;				
  _led_display = errcode;				
  if (_led_display & 0x01)			
    led_yellow_on();				
  else					
    led_yellow_off();				
  _led_display >>= 1;				
  if (_led_display & 0x01)			
    led_green_on();				
  else					
    led_green_off();				
  _led_display >>= 1;				
  if (_led_display & 0x01)			
    led_red_on();				
  else					
    led_red_off();
  return;
}
Ejemplo n.º 9
0
// Definitions
// ------------------------------------
// Fonction permettant d'initialiser les leds
// ------------------------------------
void led_init(void)
{
   P1DIR |= LEDG | LEDR;        // bits 0 et 7 du port 1 sont des sorties
   led_green_off();
   led_red_off();
}
Ejemplo n.º 10
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);
    }
}