Exemplo n.º 1
0
/**  Blink led as a south cardinal mark.
 *  Pattern:   ^_^_^_^_^_^_^^^___
 * 
 * Exemple usage:
 * \code
 * blink(PB0);
 * \endcode
 * 
 * @param pin the pin of the led
 * 
 */
void blink (int pin)
{
   int i;

   set_AC(0);
   // set a timer0
   TIMSK  |=   _BV(TOIE0);  // enable interrupt on overflow
   TCCR0B |=   _BV(CS00);   // set prescaler to CLKio/(No prescaling)
   PRR    &= ~ _BV(PRTIM0); // enable Timer0 module
   
   for (i=0; i<6; i++)
   {
      PORTB |= _BV(pin); // on
      idle_sleep (333, 1);
      PORTB &= ~ _BV(pin); // off
      idle_sleep (333, 1);
      
   }
   PORTB |= _BV(pin); // on
   idle_sleep (3000, 1);
   PORTB &= ~ _BV(pin); // off
   idle_sleep (3000, 1);
   
   // remove timer0
   PRR    |=   _BV(PRTIM0); // disable Timer0 module
   TIMSK  &= ~ _BV(TOIE0);  // disable interrupt on overflow
   TCCR0B &= ~ _BV(CS00);   // unset prescaler to CLKio/(No prescaling)
   
   set_AC(1);
} // blink()
Exemplo n.º 2
0
Arquivo: sleep.c Projeto: Tilatti/AVR
int main(void)
{
  DDRB = 0xFF; // All port B are outputs

  /*
   * Configure TIMER0
   *  - Enable timer0 interrupt
   *  - Set prescaler
   */

  TIMSK |= _BV(TOIE0);
  TCCR0B |= _BV(CS02);

  sei();

  while (1)
  {
    idle_sleep(6000, 256);
    PORTB = 0xFF;
    idle_sleep(1000, 256);
    PORTB = 0x00;
  }
}
Exemplo n.º 3
0
void cpu_idle(void)
{
	while (1) {
		tick_nohz_idle_enter();
		local_irq_disable();
		while (!need_resched()) {
			idle_sleep();
			/*  interrupts wake us up, but aren't serviced  */
			local_irq_enable();	/* service interrupt   */
			local_irq_disable();
		}
		local_irq_enable();
		tick_nohz_idle_exit();
		schedule();
	}
}