Exemplo n.º 1
0
void power_down() //dodać zapis do eepromu
{
	eeprom_write_byte((uint8_t*)0, (uint8_t)VOL); // Save volume to eeprom
	
	eeprom_write_byte((uint8_t*)8, (uint8_t)id_tab[0][0]);
	eeprom_write_byte((uint8_t*)16, (uint8_t)id_tab[0][1]);
	eeprom_write_byte((uint8_t*)24, (uint8_t)id_tab[0][2]);
	
	eeprom_write_byte((uint8_t*)32, (uint8_t)id_tab[1][0]);
	eeprom_write_byte((uint8_t*)40, (uint8_t)id_tab[1][1]);
	eeprom_write_byte((uint8_t*)48, (uint8_t)id_tab[1][2]);
	
	eeprom_write_byte((uint8_t*)56, (uint8_t)id_tab[2][0]);
	eeprom_write_byte((uint8_t*)64, (uint8_t)id_tab[2][1]);
	eeprom_write_byte((uint8_t*)72, (uint8_t)id_tab[2][2]);
	
	eeprom_write_byte((uint8_t*)80, (uint8_t)id_tab[3][0]);
	eeprom_write_byte((uint8_t*)88, (uint8_t)id_tab[3][1]);
	eeprom_write_byte((uint8_t*)96, (uint8_t)id_tab[3][2]);
	
	cli();
	PCICR &= ~(1 << PCIE2) & ~(1 << PCIE0); // disable PCINT
	EIMSK |= (1 << INT1); // Enebale INT1 external interrupt on low state
	power_flag = 0;
	led_enable(0);
	while (!(B1_PIN & (1 << B1)));
	SMCR |= (1 << SM1) |(1 << SE);
	sleep_enable();
	sei();
	sleep_cpu();
	
	power_up();
	_delay_ms(50);
	if (((B1_PIN & (1 << B1)) ) !=0 ) 
	{
		power_flag = 0;
	}
	else 
	{
		led_enable(1);
		_delay_ms(5);
		power_flag = 1;	
		SPK_FREQ = 2;
		cli();
		play_speaker(50);
		sei();
	}
	
}
Exemplo n.º 2
0
static void *blink_led(void)
{
	while (run) {
		led_enable();
		usleep(200000);
		led_disable();
		usleep(200000);
	}
	pthread_exit(0);
}
Exemplo n.º 3
0
void main(void) {
    
    PLL_init();       // set system clock frequency to 24 MHz
    ad0_enable(); // enable a/d converter 0
    ad1_enable(); // enable a/d converter 1
    led_enable();
    seg7_disable();
    servo54_init();
    lcd_init();        // enable lcd
    motor1_init(); // enable 8-bit pwm1 for computer fan
  
     
         while(1) {
            
            for (width = 3000; width < 14500; width = width + 150) {
                flame = ad0conv(3); 	// read flame sensor output on channel 3 adc0
                range = ad0conv(5); 	// read range sensor output on channel 7 adc1
                
                set_lcd_addr(0x40);
                if (range > 550) {
                    type_lcd("Flame is near!  ");
                } else {
                    type_lcd("Out of range    ");
                }
                set_servo54(width);
                ms_delay(10);
                
                if (flame > 1000) {
                    set_lcd_addr(0x00);
                    ms_delay(10);
                    type_lcd("Flame Detected! ");
                    if (range > 550) {
                          ms_delay(10);
                          //Turn the motor on for 8 seconds
                          set_lcd_addr(0x40);
                          ms_delay(10);
                          type_lcd("Flame is near!  ");
                          ms_delay(10);
                          leds_on(0b11111000);     //Motor is on
                          ms_delay(8000);
                          motor1(speed);
                          ms_delay(10);
                    }
                } else {
                    leds_on(0b11111100);     //Motor is off
                    set_lcd_addr(0x00);
                    type_lcd("No Flame        ");
                }
                ms_delay(10);
            }
    }
}
Exemplo n.º 4
0
/**
 * Called when the system hits a non-recoverable error.  Ensure to use
 * the correct PANIC_CAUSE_* enum to help users inform us of the issue.
 */
void panic(const enum panic_cause cause)
{
        taskDISABLE_INTERRUPTS();

        led_enable(LED_ERROR);
        for(;;) {
                led_enable(LED_GPS);
                led_enable(LED_LOGGER);
                delay_seconds(FLASH_PAUSE_DELAY_S);
                led_disable(LED_GPS);
                led_disable(LED_LOGGER);
                delay_seconds(FLASH_DELAY_S);

                for (int c = 0; c < cause; ++c) {
                        led_enable(LED_GPS);
                        led_enable(LED_LOGGER);
                        delay_seconds(FLASH_DELAY_S);
                        led_disable(LED_GPS);
                        led_disable(LED_LOGGER);
                        delay_seconds(FLASH_DELAY_S);
                }
        }
}
Exemplo n.º 5
0
static void flashGpsStatusLed(enum GpsSignalQuality gpsQuality)
{
        if (g_flashCount == 0)
                led_disable(LED_GPS);

        g_flashCount++;

        const int targetFlashCount = isGpsSignalUsable(gpsQuality) ?
                GPS_LOCK_FLASH_COUNT : GPS_NOFIX_FLASH_COUNT;

        if (g_flashCount >= targetFlashCount) {
                led_enable(LED_GPS);
                g_flashCount = 0;
        }
}
Exemplo n.º 6
0
/**
 * Called when the system hits a non-recoverable error.  Ensure to use
 * the correct PANIC_CAUSE_* enum to help users inform us of the issue.
 */
void panic(const enum panic_cause cause)
{
        taskDISABLE_INTERRUPTS();
	led_device_set_all(false);

        led_enable(LED_ERROR);
        for(;;) {
                led_enable(LED_GPS);
                led_enable(LED_LOGGER);
                cpu_device_spin(FLASH_PAUSE_DELAY_MS);
                led_disable(LED_GPS);
                led_disable(LED_LOGGER);
                cpu_device_spin(FLASH_DELAY_MS);

                for (int c = 0; c < cause - 1; ++c) {
                        led_enable(LED_GPS);
                        led_enable(LED_LOGGER);
                        cpu_device_spin(FLASH_DELAY_MS);
                        led_disable(LED_GPS);
                        led_disable(LED_LOGGER);
                        cpu_device_spin(FLASH_DELAY_MS);
                }
        }
}
Exemplo n.º 7
0
void main(void) {

  char key;  //key pressed
  Flag *flag = createFlag();
  
  PLL_init();         //set system clock freq to 24MHz
  lcd_init();         //enable lcd display (clear display)
  keypad_enable();    //enable keypad
  led_enable();       //enable leds
  seg7_disable();     //turn off and disable seg7 display
  set_lcd_addr(0x40); //set display on 2nd line
  
 
  while(1){
     
    key = getkey();     //read keypad   
    if(flag->shift == true)  //shift key was pressed  
      shiftMode(key, flag);  //operator input keys
 
    else 
      stdMode(key, flag);   //standard input keys
      
  }  //end while(1)
}  //end main                            
Exemplo n.º 8
0
void charge_state_interrupt(enum gpio_signal signal)
{
	led_enable(gpio_get_level(signal));
}