• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sleep_disable函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sleep_disable函数的典型用法代码示例。如果您正苦于以下问题:C++ sleep_disable函数的具体用法?C++ sleep_disable怎么用?C++ sleep_disable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sleep_disable函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: go_to_sleep

/*! Sleep function.
 *
 * Which IO line is in use is recorded in the progs struct.
 *
 * \note Incompatible with MONOSTABLE valve.
 */
void go_to_sleep(uint8_t valve, struct debug_t *debug)
{
	if (valve == BISTABLE) {
		set_sleep_mode(SLEEP_MODE_PWR_SAVE);
		/* shut down everything */
		i2c_shut();
		io_shut();
		led_shut();
		/* start sleep procedure */
		sleep_enable();
		sleep_bod_disable();
		sleep_cpu();
		sleep_disable();
		/* restart everything */
		led_init();
		io_init();
		i2c_init();
	} else {
		set_sleep_mode(SLEEP_MODE_IDLE);
		/* start sleep procedure */
		sleep_enable();
		sleep_cpu();
		sleep_disable();
	}
}
开发者ID:erossi,项目名称:opengarden,代码行数:31,代码来源:main.c


示例2: disableLEDs

void Pendant::sleepNow() {
  disableLEDs();

  PCMSK0 |= _BV(PCINT0);  // Watch pin PB1
  GIFR   |= _BV(PCIE0);   // clear any outstanding interrupts

  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  power_all_disable();  // power off ADC, Timer 0 and 1, serial interface
  sleep_enable();
  sleep_cpu();


  //
  // ... SLEEPING ...
  //


  // resumes here on wake
  sleep_disable();
  power_all_enable();    // power everything back on
  PCMSK0 &= ~_BV(PCINT0); // Turn off PB1 as interrupt pin

  sleepOnRelease = false;
  changeModeOnRelease = false;
  digitalWrite(PENDANT_LED_PWR_PIN, HIGH);
}
开发者ID:Squeegy,项目名称:ChakraPendant,代码行数:26,代码来源:Pendant.cpp


示例3: main

int main(void) {
    
    // General Interrupt Mask Register
    // INT0: enable external interrupt 0 (on PB1 / pin 6)
    // Attiny datasheet p46
    setBit(GIMSK, PCIE);
    setBit(PCMSK, PCINT1);
    
    // TODO: Power down modules
    
    // Set the sleep mode
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);
    
//    setAsOutput(LED);
//    setBit(PORTB, LED);
        
    while(1){
//          blinkTimes(state + 1);
        
        state %= 5;
        setState(state);

        sleep_enable();
        
        // Set enable interrupts
        sei();
        
        sleep_cpu();
        sleep_disable();
    }
    
}
开发者ID:remmelt,项目名称:taptationCtrl,代码行数:32,代码来源:taptationController.c


示例4: check_bootloader_message

/*---------------------------------------------------------------------------*/
void check_bootloader_message(uint8_t timeout)
{
    uint8_t getDataCounter = 0;

    /* listen to any bootloader messages! */
    nrf24_powerUpRx();    
    while(getDataCounter++ < timeout)
    {
        _delay_ms(1);        
        if(nrf24_dataReady())
        {    
            nrf24_getData(data_array);        
            if((data_array[0] == 0) && (data_array[1] == 0xAA))
            {        
                /* prepare */
                cli();
                PORTA = 0x00;
                PORTB = 0x00;
                DDRA = 0x00;
                DDRB = 0x00;
                sleep_disable();

                /* jump to bootloader! */
                /* bootloader is located at: 0x1800 */
                asm volatile("lds r31, 0x18"); // R31 = ZH
                asm volatile("lds r30, 0x00"); // R30 = ZL
                asm volatile("icall"); // Jump to the Z register value
            }            
        }                            
    }        
开发者ID:kehribar,项目名称:nrf24l01_plus_bootloader,代码行数:31,代码来源:main.c


示例5: read_adc

static uint16_t read_adc(uint8_t mux)
{
	uint16_t adc_val;
	// read battery level
	ADMUX = mux & 0b11011111; // ensure right adjusted
#if (F_CPU == 8000000)
	ADCSRA =  0b10001110; // Enable ADC with clock/64, interrupt enable
#elif (F_CPU == 1000000)
	ADCSRA =  0b10001011; // Enable ADC with clock/8, interrupt enable
#else
#error Need 8Mhz or 1Mhz clock
#endif
	adc_val = 0;
	set_sleep_mode(SLEEP_MODE_ADC);
	// take 8 samples... 
	for (int i=0;i<8;i++) {
		adc_done = false;
		ADCSRA |= 0b01000000; // start the conversion
		cli();
		while (!adc_done) {
			sleep_enable();
			sei();
			sleep_cpu();
			sleep_disable();
		}
		sei();
		adc_val += ADCL;
		adc_val += (ADCH << 8);
	}
	ADCSRA &=  0b01111111; // turn off ADC 
	// then return the average
	return (adc_val >> 3);
}
开发者ID:mattcallow,项目名称:sensornet,代码行数:33,代码来源:rf-node.c


示例6: set_sleep_mode

void PowerManager::sleep()
{
    if (!clk_IO.locks) {
        if (!clk_ADC.locks) {
            if (!clk_ASY.locks) {
                if (!clk_MAIN.locks) {
                    set_sleep_mode(SLEEP_MODE_PWR_DOWN);
                } else {
                    set_sleep_mode(SLEEP_MODE_STANDBY);
                }
            } else {
                if (!clk_MAIN.locks) {
                    set_sleep_mode(SLEEP_MODE_PWR_SAVE);
                } else {
                    set_sleep_mode(SLEEP_MODE_EXT_STANDBY);
                }
            }
        } else {
            set_sleep_mode(SLEEP_MODE_ADC);
        }
    } else {
        set_sleep_mode(SLEEP_MODE_IDLE);
    }

    sleep_enable();
    sleep_cpu();
    sleep_disable();
}
开发者ID:cepr,项目名称:octopus,代码行数:28,代码来源:power_manager.cpp


示例7: sleep

static void sleep(int mode)
{
    set_sleep_mode(mode);
    sleep_enable();
    sleep_mode();
    sleep_disable();
}
开发者ID:Mpic,项目名称:avr,代码行数:7,代码来源:main.c


示例8: sleep_until_eswitch_pressed

void sleep_until_eswitch_pressed()
{
    WDT_off();
    ADC_off();

    // make sure switch isn't currently pressed
    while (button_is_pressed()) {}
    empty_event_sequence();  // cancel pending input on suspend
    //PCINT_since_WDT = 0;  // ensure PCINT won't ignore itself

    PCINT_on();  // wake on e-switch event

    // configure sleep mode
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);

    sleep_enable();
    sleep_bod_disable();
    sleep_cpu();  // wait here

    // something happened; wake up
    sleep_disable();

    #ifdef USE_THERMAL_REGULATION
    // forget what the temperature was last time we were on
    reset_thermal_history = 1;
    #endif

    // go back to normal running mode
    //PCINT_on();  // should be on already
    // FIXME? if button is down, make sure a button press event is added to the current sequence
    ADC_on();
    WDT_on();
}
开发者ID:schizobovine,项目名称:flashlights_are_hard,代码行数:33,代码来源:fsm-standby.c


示例9: uiPowerOff

/***********************************************************
* 	   
* uiPowerTimeOut
*  
***********************************************************/
  void TTUI::uiPowerTimeOut()
  {
    if(state_UIPower == true)
    {
      
	 #ifndef TT_SHIELD //if not TT shield
      if((millis() - previousMillis_UIPower) > UI_SLEEP_MS) 
      {
	    	
		uiPowerOff();
		set_sleep_mode(SLEEP_MODE_PWR_DOWN);
	    sleep_enable();
		sei(); //make sure interrupts are on!
		detachInterrupt(0);
	  	attachInterrupt(0,sleepHandler, FALLING);
	
	  	sleep_mode();  //sleep now
		//----------------------------- ZZZZZZ sleeping here----------------------
	    sleep_disable(); //disable sleep, awake now
		attachInterrupt(0,startDownHandler,FALLING); //trigger ISR function on start button press.
		uiPowerOn();
	    
      }
	 #endif //end TT_Shield
    }
  }
开发者ID:bcasbcas,项目名称:Triggertrap,代码行数:31,代码来源:TTUI.cpp


示例10: adc_read

void adc_read(const uint8_t ch)
{
	// Voltage reference for ACC is AVCC.
	// ch is for ADC channel selections.
	// Note: ch ={0x9, 0xA, 0xB, 0xC, 0xD} are reserved.
	// Note: ch ={0x4, 0x5} are used by TWI/I2c.
	ADMUX = (uint8_t)(_BV(REFS0) | (0x0F & ch));
	
	// Enable the ADC.
	// Setup for ADC noise reduction mode.
	ADCSRA = (uint8_t)(_BV(ADEN) | _BV(ADIF) | _BV(ADIE) | _BV(ADPS2) | _BV(ADPS1) | _BV(ADPS0));
	set_sleep_mode(SLEEP_MODE_ADC);
	sleep_enable();
	
	// Start and wait for ADC conversion. 
	// Enter sleep mode to start. 
	sleep_cpu();
	sleep_disable();
	
	// Disable ADC to save power.
	ADCSRA = 0x00;
	// Restore the sleep mode.
	set_sleep_mode(SLEEP_MODE_IDLE);
	
} // End of adc_read().
开发者ID:bjester,项目名称:project-leda,代码行数:25,代码来源:Adc.c


示例11: power_down

static void power_down(uint8_t wdto)
{
#ifdef PROTOCOL_LUFA
    if (USB_DeviceState == DEVICE_STATE_Configured) return;
#endif
    wdt_timeout = wdto;

    // Watchdog Interrupt Mode
    wdt_intr_enable(wdto);

    // TODO: more power saving
    // See PicoPower application note
    // - I/O port input with pullup
    // - prescale clock
    // - BOD disable
    // - Power Reduction Register PRR
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);
    sleep_enable();
    sei();
    sleep_cpu();
    sleep_disable();

    // Disable watchdog after sleep
    wdt_disable();
}
开发者ID:Eleuin,项目名称:tmk_keyboard,代码行数:25,代码来源:suspend.c


示例12: Sleep_Task

void Sleep_Task (void) {
    if (!MustSleep) return;
    // Sleep if Current color is black => LED is faded down yet
    if (
            (ELight.CurrentColor.Red   == 0) &&
            (ELight.CurrentColor.Green == 0) &&
            (ELight.CurrentColor.Blue  == 0) &&
            (ELight.CurrentColor.Uf  == 0)
        ) {
        // Enter sleep
        CC_ENTER_IDLE();    // }
        CC_POWERDOWN();     // } Shutdown CC
        //LED_PWR_OFF();      // Shutdown LED power

        // Enable IRQ to wake
        cli();
        HANDLE_IRQ_SETUP_MASK();
        HANDLE_IRQ_CLEAR();
        HANDLE_IRQ_ENABLE();
        sei();
        // Enter sleep mode
        set_sleep_mode(SLEEP_MODE_PWR_DOWN);
        sleep_enable();
        wdt_disable();
        sleep_cpu();    // Sleep now
        // Something happened, wake now
        wdt_enable(WDTO_2S);
        sleep_disable();
        HANDLE_IRQ_DISABLE();
       // ESens.HandleIsOn = true;
        // Event hanler will do the rest
       // EVENT_HandleTouched();  // Execute it from here to switch on immediately
    }
}
开发者ID:Kreyl,项目名称:nute,代码行数:34,代码来源:olwen.c


示例13: check_if_sleepy

void check_if_sleepy(){
bool readyforbed = true;
for(int j = 0; j < NumberOfFlys; j++)
     {
	if ( flystatus[j] == 1 )
	readyforbed=false;
     }
if ( lightness_counter < 10 )
	readyforbed=false;
cli();
if ( readyforbed==true )
{ 
     DDRB = 0;
//     PORTB = 1<<anode[0]|0<<cathode[0];
 //    DDRB = 1<<anode[0]|1<<cathode[0];

     set_sleep_mode(SLEEP_MODE_PWR_DOWN);
     sleep_mode();
     sleep_enable();
     sei();
     sleep_cpu();
     sleep_disable();
}
sei();
}
开发者ID:solarkennedy,项目名称:fireflies,代码行数:25,代码来源:fireflies.c


示例14: m_rdy_line_handle

void m_rdy_line_handle(void)
{
  hal_aci_data_t *p_aci_data;
  
  sleep_disable();
  detachInterrupt(1);
  
  // Receive or transmit data
  p_aci_data = hal_aci_tl_poll_get();
  
  // Check if we received data
  if (p_aci_data->buffer[0] > 0)
  {
    if (!m_aci_q_enqueue(&aci_rx_q, p_aci_data))
    {
      /* Receive Buffer full.
         Should never happen.
         Spin in a while loop.
         */
       while(1);
    }
    if (m_aci_q_is_full(&aci_rx_q))
    {
      /* Disable RDY line interrupt.
         Will latch any pending RDY lines, so when enabled it again this
         routine should be taken again */
      toggle_eimsk(false);
    }    
  }
}
开发者ID:JamieB226,项目名称:ArduinoWatch,代码行数:30,代码来源:hal_aci_tl.cpp


示例15: main

int main(void) {
    unsigned char ret;

    init_io();

    cli();
    check_wdt();
    setup_wdt();
    sei();                                      // Enables interrupts

    // Enable Sleep Mode for Power Down
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);    // Set Sleep Mode: Power Down
    sleep_enable();                     // Enable Sleep Mode

    for(;;) {                                               // Event Loop
        if(tick_flag) {
            tick_flag = 0;
            sleep_disable();

            set_sleep_mode(SLEEP_MODE_PWR_DOWN);
            sleep_enable();
            sleep_mode();
        }
    }
}
开发者ID:thaletterb,项目名称:ssd1306_adxl335_accelerometer,代码行数:25,代码来源:watchdog_interrupt.c


示例16: _getAdcValue

static uint8_t _getAdcValue(uint8_t pin) {
	uint8_t  ret = 0;

	ADMUX &= ~(_BV(MUX0) | _BV(MUX1));

	ADMUX |= pin;

	adcBufferWritten = 0;

	ADCSRA |= _BV(ADIE);

	set_sleep_mode(SLEEP_MODE_IDLE);
	sleep_enable();

	while (adcBufferWritten != ADC_BUFFER_SIZE) {
		while (TCNT0 != TIMER_TOP) {}

		sleep_cpu();

		adcBufferWritten++;
	};

	sleep_disable();

#if defined(ADC_MEDIAN_INSTEAD_OF_AVERAGE)
	ret = _getMedian(adcBuffer, adcBufferWritten);
#else
	ret = _average(adcBuffer, adcBufferWritten);
#endif

	return ret;
}
开发者ID:bielskij,项目名称:avr,代码行数:32,代码来源:main.c


示例17: main

int main(void) {
  char refreshed;

  editor_init(&refreshed);
  editor_refresh();

  set_sleep_mode(SLEEP_MODE_STANDBY);
  sei();


  for (;;) {
    cli();
    if (refreshed) {
      sleep_enable();
      sei();
      sleep_cpu();
      sleep_disable();
    } else {
      refreshed = 1;
      sei();
      editor_refresh();
    }
  }

};
开发者ID:wojtekzozlak,项目名称:Studia.Archiwum,代码行数:25,代码来源:main.c


示例18: maybe_sleep

/*
 * Put the processor into sleep mode, maybe
 */
void maybe_sleep(void)
{
    // If we need to do the main loop again, don't bother going to sleep
    if (do_main_poll || TIFR0 & 0x1 << OCF0A)
        goto done;

    // Otherwise, we have some time to kill before our next poll. Time for bed.

    // Enable the poll interrupt. He is going to tell us to stop sleeping.
    TIMSK0 |= 0x1 << OCIE0A;

    do {
        sleep_enable();  // Enable SLEEP instruction
        sleep_cpu();     // Wake me when you need me...
        sleep_disable(); // Woken up. Disable SLEEP instruction

    // If the ISR we just serviced was not our poll ISR, go back to sleep
    } while (!do_main_poll);

done:
    // Disable our poll interrupt during our main routine, because we don't
    // need someone to tell us to do the main poll; we are already doing it!
    TIMSK0 &= ~(0x1 << OCIE0A);
    do_main_poll = 0;
}
开发者ID:balthamos,项目名称:openkeyboard,代码行数:28,代码来源:sleep.c


示例19: set_sleep_mode

/*
* set the microcontroller to sleep. 
*/ 
void Interrupt::sleep()
{
  RX8025.getRtcTime(sleep_timestamp_ptr);
  Timer1.detachInterrupt();
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  if(WRITE_INTERRUPT_INFO) Serial.print("\nProcessor going to sleep.\n");
  if(USE_LED)  digitalWrite(LED_port,LOW);
  digitalWrite(latch_control_port,HIGH);
  RTC.refreshINTA();
  sleep_enable();
  attachInterrupt(interrupt0, clock_interupt_ISR, LOW); 
  if(! ROUTER) attachInterrupt(interrupt1, sensor_interupt_ISR, RISING);
  // if the sensor interrupt goes off between attaching the interrupt and sleep mode finishing, that interrupt is locked out until the RTC interrupt occurs.
  // The same does not apply to RTC interrupt occuring between attaching the interrupt and sleep mode finishing.
  sleep_mode();
  
  // Processor is sleeping //
  
  sleep_disable();
  detachInterrupt(interrupt0);
  if(! ROUTER) detachInterrupt(interrupt1);
  if(WRITE_INTERRUPT_INFO)  Serial.print("\nProcessor waking up.\n\n");
  if(USE_LED)  digitalWrite(LED_port,HIGH);
  
  sleep_SMC();
  sleep_packet_handler();
  sleep_packet_counter();
  digitalWrite(latch_control_port,LOW); // read sensors
}
开发者ID:KevinScottP,项目名称:MyProjects,代码行数:32,代码来源:Interrupt.cpp


示例20: sleep_and_wake

void sleep_and_wake()
{
  sleep_enable();    // set the sleep enable bit in the SMCR register
  sleep_cpu();       // use the sleep command
  sleep_disable();  // unset th esleep enable bit, for safety
  OCR2B = flag;
}
开发者ID:jbremnant,项目名称:project_ledi,代码行数:7,代码来源:main.c



注:本文中的sleep_disable函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sleep_milliseconds函数代码示例发布时间:2022-05-30
下一篇:
C++ sleep函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap