コード例 #1
0
void WIFI_idle()
{
	Control_RGB_LEDs(1,0,0);
	Delay(90);
		if(!Disable_AutoConnect())
			{
				Control_RGB_LEDs(1,0,0);
      }
		PTC->PSOR = MASK(12);
		if(!DeepSleep())         // Enter DeepSleep
      {
				Control_RGB_LEDs(1,0,0);
      }
}
コード例 #2
0
ファイル: MainUnit.c プロジェクト: Kreyl/Calmari
void LiveInLight (void){
	PORTB &= ~(1<<LedPin); // Light-up LED
	PWMStop();
	while (1){
		EnableInput ();
		DeepSleep();
		DisableInput ();
		if (Valto != None) {
			EventHandler ();
			// if key pressed then shutdown
			if (Valto==KeyPressed) break; 
		}
	}
	PWMStart(250);
	PORTB |= (1<<LedPin); // Shutdown LED
}
コード例 #3
0
ファイル: sleep.c プロジェクト: geliang201201/RTL_Ameba
/**
  * @brief  To make the system entering the Deep Sleep power saving mode.
  *         The CPU, memory and peripheral power is off when entering
  *         deep sleep power saving mode. The program needs to be reload
  *         and all peripheral needs be re-configure when system resume.
  *
  * @param  wakeup_event: A bit map of wake up event. Available event:
  *                         DSLEEP_WAKEUP_BY_TIMER
  *                         DSLEEP_WAKEUP_BY_GPIO
  *         sleep_duration: the system sleep duration in ms, only valid
  *         for DSLEEP_WAKEUP_BY_TIMER wake up event.
  *
  * @retval None
  */
void deepsleep_ex(uint32_t wakeup_event, uint32_t sleep_duration)
{
    u8 wake_ev=0;
    
    if ((wakeup_event & DSLEEP_WAKEUP_BY_TIMER) && (sleep_duration > 0)) {
        // wake up by timeout or GPIO pin goes high
        wake_ev |= DS_TIMER33;
    }
    
    if (wakeup_event & DSLEEP_WAKEUP_BY_GPIO) {
        // wake up by GPIO pin goes high
        wake_ev |= DS_GPIO;
    }

    if (wake_ev == 0) {
        // error: No wake up event, skip entering deep sleep mode
        return;
    }
    DeepSleep (wake_ev, sleep_duration);    
}
コード例 #4
0
ファイル: MainUnit.c プロジェクト: Kreyl/Calmari
int main (void){
	// Setup IO
	DDRB  = (0<<PB0)|(1<<PB1)|(0<<PB2)|(0<<PB3)|(0<<PB4);
	PORTB = (1<<PB0)|(1<<PB1)|(1<<PB2)|(0<<PB3)|(0<<PB4); // VCC-based LED
	
	while (1){
		EnableInput ();
		DeepSleep();
		DisableInput ();
		// **** Why wake? ****
		EventHandler();
		if (Valto==KeyPressed) {
			Valto = None;
			Wait (_2_s);
			LightUp();
			if (Valto == None) LiveInLight();
			LightDown();
		}
	}
}