本文整理汇总了C++中set_sleep_mode函数的典型用法代码示例。如果您正苦于以下问题:C++ set_sleep_mode函数的具体用法?C++ set_sleep_mode怎么用?C++ set_sleep_mode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_sleep_mode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: sleep_proc
// IMPORTANT: if interrupts are not enabled, the processor will never wake
// from sleep
void sleep_proc() {
enable_pcint();
// Turn off timer0
disable_pwm();
disp_off();
// probably want power save mode
// everything off but Timer2 interrupts
set_sleep_mode(SLEEP_MODE_PWR_SAVE);
sleep_mode();
// Continue here on wake
disable_pcint();
return;
}
开发者ID:laszuba,项目名称:binary_watch,代码行数:18,代码来源:main.c
示例2: rf12_sendWait
/// @details
/// Wait for completion of the preceding rf12_sendStart() call, using the
/// specified low-power mode.
/// @note rf12_sendWait() should only be called right after rf12_sendStart().
/// @param mode Power-down mode during wait: 0 = NORMAL, 1 = IDLE, 2 = STANDBY,
/// 3 = PWR_DOWN. Values 2 and 3 can cause the millisecond time to
/// lose a few interrupts. Value 3 can only be used if the ATmega
/// fuses have been set for fast startup, i.e. 258 CK - the default
/// Arduino fuse settings are not suitable for full power down.
void rf12_sendWait (uint8_t mode) {
// wait for packet to actually finish sending
// go into low power mode, as interrupts are going to come in very soon
while (rxstate != TXIDLE)
if (mode) {
// power down mode is only possible if the fuses are set to start
// up in 258 clock cycles, i.e. approx 4 us - else must use standby!
// modes 2 and higher may lose a few clock timer ticks
set_sleep_mode(mode == 3 ? SLEEP_MODE_PWR_DOWN :
#ifdef SLEEP_MODE_STANDBY
mode == 2 ? SLEEP_MODE_STANDBY :
#endif
SLEEP_MODE_IDLE);
sleep_mode();
}
}
开发者ID:szildroid,项目名称:new_Funky,代码行数:25,代码来源:RF12x.cpp
示例3: go_sleep
void go_sleep()
{
cbi(ADCSRA,ADEN); // switch Analog to Digitalconverter OFF
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
cli();
sleep_enable();
sleep_bod_disable();
sei();
sleep_cpu();
//sleep_mode();
/* wake up here */
sleep_disable();
sbi(ADCSRA,ADEN); // switch Analog to Digitalconverter ON
initvars();
setup();
}
开发者ID:duns,项目名称:electronics,代码行数:16,代码来源:helmet_firmware.cpp
示例4: fn_wait_for_event
obj fn_wait_for_event (obj args)
{
(void) args;
sleep_enable ();
set_sleep_mode (SLEEP_MODE_IDLE);
for (;;)
{
noInterrupts ();
if (isReady ())
break;
interrupts ();
sleep_cpu ();
}
interrupts ();
return (obj_NIL);
}
开发者ID:ianwild,项目名称:qsl,代码行数:16,代码来源:hardware.cpp
示例5: main
int main(void)
{
cli();
ir.enableIRIn();
TIMER_DISABLE_INTR; //start up the IR thing, then turn off the interrupt
DDRB &= ~((1 << IR_PIN) | (1 << SCL)); //Configure clock and IR pin as input
SETUP_PIN_CHANGE;
ENABLE_PIN_INTR;
sei();
set_sleep_mode(2);
sleep_enable();
while (1)
{
sleep_cpu();
}
}
开发者ID:db-dropDatabase,项目名称:DuinoTagHardware,代码行数:16,代码来源:main.c
示例6: main
int main(void) {
WDT_off(); //watchdog erstmal abschalten
wdt_disable();
LED_DDR = (1<<LED_PIN); //register setzen
LED(0); //LED auf LOW ziehen --> AN
delayms(20); //Delayzeit stellt die Impulsdauer und damit den Helligkeitseindruck ein
LED(1); //LED auf HIGH setzen --> AUS
wdt_enable(WDTO_2S); //setze den Watchdogtimer auf 2s
set_sleep_mode(SLEEP_MODE_PWR_DOWN); //PWR_DOWN --> quasi nur wdt kann chip wecken
sleep_mode(); //in den Tiefschlaf wechseln
while(1);
return 0;
}
开发者ID:patkan,项目名称:ewiger_blinker,代码行数:16,代码来源:main.c
示例7: acx565akm_panel_power_on
static int acx565akm_panel_power_on(struct omap_dss_device *dssdev)
{
struct panel_drv_data *ddata = to_panel_data(dssdev);
struct omap_dss_device *in = ddata->in;
int r;
dev_dbg(&ddata->spi->dev, "%s\n", __func__);
in->ops.sdi->set_timings(in, &ddata->vm);
r = in->ops.sdi->enable(in);
if (r) {
pr_err("%s sdi enable failed\n", __func__);
return r;
}
/*FIXME tweak me */
msleep(50);
if (gpio_is_valid(ddata->reset_gpio))
gpio_set_value(ddata->reset_gpio, 1);
if (ddata->enabled) {
dev_dbg(&ddata->spi->dev, "panel already enabled\n");
return 0;
}
/*
* We have to meet all the following delay requirements:
* 1. tRW: reset pulse width 10usec (7.12.1)
* 2. tRT: reset cancel time 5msec (7.12.1)
* 3. Providing PCLK,HS,VS signals for 2 frames = ~50msec worst
* case (7.6.2)
* 4. 120msec before the sleep out command (7.12.1)
*/
msleep(120);
set_sleep_mode(ddata, 0);
ddata->enabled = 1;
/* 5msec between sleep out and the next command. (8.2.16) */
usleep_range(5000, 10000);
set_display_state(ddata, 1);
set_cabc_mode(ddata, ddata->cabc_mode);
return acx565akm_bl_update_status(ddata->bl_dev);
}
开发者ID:JamesChenFromChina,项目名称:linux,代码行数:47,代码来源:panel-sony-acx565akm.c
示例8: initialise
void initialise(void)
{
/* Disable interrupts during initialisation
*/
cli();
/* Setup i/o pins
* PORTB - all output except input MISO on PB4
* PORTC - all input except outputs PC0(?), PC4 (?) and PC5 (Led)
* PORTD - all output except inputs PD0 (RX), PD2 (signal) and
* PD3(int1)
*/
DDRB = ~(1 << DDB4);
DDRC = (1 << ACTIVITY_LED) | (1 << DDC4) | (1 << DDC0);
DDRD = ~((1 << DDD3) | (1 << DDD2) | (1 << DDD0));
/* Enable external interrupt on INT0 (PD2) - falling edge trigger
*/
EICRA = (1 << ISC01);
EIMSK = (1 << INT0);
/* Setup a 16 bit timer to generate 1s interrupts for display updates
*/
TCCR1B |= (1 << CS12) | (1 << WGM12);
OCR1A = (F_CPU / 256) - 1;
TIMSK1 |= (1 << OCIE1A);
/* Setup UART0
*/
UCSR0B |= (GEIGER_XFER);
UCSR0C |= (GEIGER_XFER_CFG);
UBRR0H = UBRRH_VALUE;
UBRR0L = UBRRL_VALUE;
#if USE_2X
UCSR0A |= (1 << U2X0);
#else
UCSR0A &= ~(1 << U2X0);
#endif
PORTC |= LED_OFF_MASK;
/* Allow the CPU to sleep and be woken on timer and external
* interrupts
*/
set_sleep_mode(SLEEP_MODE_IDLE);
sei();
}
开发者ID:memes,项目名称:geiger,代码行数:47,代码来源:geiger.c
示例9: sleep
/*-----------------------------------------------------------------------*/
static
uint8_t sleep(void)
{
/* 1/32 Clock */
cli();
CLKPR = _BV(CLKPCE);
CLKPR = 0b0101;
sei();
PRR = _BV(PRTWI) | _BV(PRTIM2) | _BV(PRTIM0) | _BV(PRTIM1) | _BV(PRSPI)
| _BV(PRUSART0) | _BV(PRADC);
/* CA2's dp on */
PORTB |= 0b00101000;
PORTD = 0b00000010;
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
/* PCINT enable */
PCMSK1 = _BV(PCINT9) | _BV(PCINT11) | _BV(PCINT13);
do {
cli();
wdt_reset();
WDTCSR = _BV(WDCE) | _BV(WDE);
WDTCSR = _BV(WDIE) | 0b110; /* 1s */
sei();
sleep_mode();
if ( !(PCMSK1 & _BV(PCINT9)) ) break;
xorshift();
/* blink dot per 0.5ms */
PIND = 0b00000010;
} while (1);
cli();
wdt_reset();
WDTCSR = _BV(WDCE) | _BV(WDE);
WDTCSR = 0;
sei();
/* if s1 pushed exit idle loop, else continue idle */
return (PINC & _BV(5));
}
开发者ID:mick909,项目名称:ncnl,代码行数:48,代码来源:main.c
示例10: su_sleep
void su_sleep(int16_t seconds)
{
s_toSleep = seconds;
ADCSRA |= (0<<ADEN); // Switch Analog to Digital converter OFF
while ( true )
{
set_sleep_mode( SLEEP_MODE_PWR_DOWN);
sleep_mode();
s_toSleep -= 10;
if ( s_toSleep < 0 ) break;
}
ADCSRA |= (1<<ADEN); // Switch Analog to Digital converter ON
}
开发者ID:BackupGGCode,项目名称:surveillance-camera,代码行数:17,代码来源:SleepUtils.cpp
示例11: sleepNow
// go to sleep until the MCU is reset
void sleepNow(void)
{
// configure sleep mode and enable it
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sleep_bod_disable();
// disable interupts
cli();
// set ports to inputs and disabled pullups
DDRB = 0;
PORTB = 0;
// sleep
sleep_mode();
}
开发者ID:N5QM,项目名称:FireFlyJar,代码行数:18,代码来源:main.c
示例12: main
int main()
{
cli();
state = 0;
/*
* Setup LED display.
*
* Fortunately, LED pins are the exactly the DDRB pins (8-13),
* so setting it all of them to input output mode is as simple as
* setting all bits of DDRB to 1.
*/
DDRB = ~((uint8_t)0);
/*
* Setup button controls.
*
* We treat all DDRD pins (except for RX and TX ones) as our input
* controls. Therefore, we just clear the whole mask leaving only
* original RX (pin 0) and TX (pin 1) values.
*/
DDRD = (DDRD & _BV(0)) | (DDRD & _BV(1));
/*
* Setup interrupts.
*
* The clear button is connected to the pin 3 (interrupt 1) and we want
* it to trigger on the falling signal (when use raises his finger).
*
* Signal of the value keys is combined with diodes and connected to the
* pin 2 (interrupt 1). We want interrupt to trigger on the rising signal
* to be able to determine which button is being pressed.
*/
sei();
EICRA = (EICRA & ~(_BV(ISC01) | _BV(ISC00))) | _BV(ISC01) | _BV(ISC00);
EICRA = (EICRA & ~(_BV(ISC11) | _BV(ISC10))) | _BV(ISC11);
EIMSK = _BV(INT0) | _BV(INT1);
set_sleep_mode(SLEEP_MODE_IDLE);
sleep_enable();
for (;;) {
sleep_mode();
}
}
开发者ID:mrhania,项目名称:studies,代码行数:46,代码来源:task25.c
示例13: tileSetup
void tileSetup(void){
//Initialization routines
initIO();
setPort(&PORTB);
sendColor(LEDCLK,LEDDAT,dark);
sei();
initAD();
initTimer();
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
//Set up timing ring buffers
uint8_t i;
for(i = 0; i<6; i++){
timeBuf[i]=0;
}
mode = running;
}
开发者ID:jbobrow,项目名称:AutomaTiles,代码行数:17,代码来源:AutomaTiles.c
示例14: main
int main(void)
{
set_sleep_mode(SLEEP_MODE_IDLE);
PORTF.DIRSET |= 0x01;
initialize_console();
initialize_games();
start_vga();
while(1)
{
sleep_mode();
if(vsync_backporch) {
vsync_backporch = 0x00;
update_state();
}
}
}
开发者ID:PMurph,项目名称:VGA_SNAKE_XMEGA_A,代码行数:17,代码来源:main.c
示例15: set_sleep_mode
/// @see http://www.nongnu.org/avr-libc/user-manual/group__avr__sleep.html
void Sleepy::powerDown() {
byte adcsraSave = ADCSRA;
ADCSRA &= ~bit(ADEN); // disable the ADC
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
ATOMIC_BLOCK(ATOMIC_FORCEON) {
sleep_enable();
// sleep_bod_disable(); // can't use this - not in my avr-libc version!
#ifdef BODSE
MCUCR = MCUCR | bit(BODSE) | bit(BODS); // timed sequence
MCUCR = (MCUCR & ~bit(BODSE)) | bit(BODS);
#endif
}
sleep_cpu();
sleep_disable();
// re-enable what we disabled
ADCSRA = adcsraSave;
}
开发者ID:gitter-badger,项目名称:arduino-sensor-network,代码行数:18,代码来源:MilliTimer.cpp
示例16: main
int main(void)
{
uint8_t i,
led; /* port D LEDs */
DDRD = 0xFF; /* set port D as output */
DDRE &= ~(_BV(PORTE4)); /* set PE4 as input */
PORTE |= _BV(PORTE4); /* enable PE4 pull up resistor */
cli(); /* global interrupt disable */
EIMSK = 0x00; /* disable all external interrupts */
EICRB = 0x00; /* 0 0 The low level of INT4 generates an interrupt request. */
EIFR = 0x00; /* clear all interrupt flags */
EIMSK = _BV(INT4); /* enable external interrupts */
sei(); /* global interrupt enable */
/*
* SLEEP_MODE_IDLE ... Idle
* SLEEP_MODE_ADC ... ADC Noise Reduction
* SLEEP_MODE_PWR_DOWN ... Power-down
* SLEEP_MODE_PWR_SAVE ... Power-save
* SLEEP_MODE_STANDBY ... Standby
* SLEEP_MODE_EXT_STANDBY ... Extended Standby
*/
set_sleep_mode(SLEEP_MODE_IDLE); /* set sleep mode */
while(1)
{
led = 1; /* indicate we are ready */
PORTD = ~led;
sleep_enable(); /* set Sleep Enable bit */
sleep_cpu(); /* sleep - waiting for INT4 */
sleep_disable(); /* clear Sleep Enable bit */
while (led) /* action after wake-up */
{
led <<= 1; /* walking LED */
PORTD = ~led;
for (i = 0; i < 100; i++) /* delay 1s */
_delay_ms(10);
}
}
}
开发者ID:h0nzZik,项目名称:school,代码行数:46,代码来源:powerint.c
示例17: IdleMain
//---------------------------------------------------------------------------
static void IdleMain( void *unused )
{
while(1)
{
#if 1
// LPM code;
set_sleep_mode(SLEEP_MODE_IDLE);
cli();
sleep_enable();
sei();
sleep_cpu();
sleep_disable();
sei();
#endif
}
return 0;
}
开发者ID:moslevin,项目名称:Mark3C,代码行数:18,代码来源:mark3test.c
示例18: sleepWithWDT
void sleepWithWDT(uint8_t wdt_period) {
wdt_enable(wdt_period);
wdt_reset();
#if defined(__AVR_ATtiny85__)
WDTCR |= _BV(WDIE); //wake up interrupt when time is up
#else //ATTiny84, ATMega328
WDTCSR |= _BV(WDIE); //wake up interrupt when time is up
#endif
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_mode();
wdt_disable();
#if defined(__AVR_ATtiny85__)
WDTCR &= ~_BV(WDIE);
#else //ATTiny84, ATMega328
WDTCSR &= ~_BV(WDIE);
#endif
}
开发者ID:cano64,项目名称:ArduinoSleep,代码行数:17,代码来源:sdelay.cpp
示例19: main
int main(void)
{
_delay_ms(1000); //power_on_delay
RFM73_Initialize();
RED_LED_OUT();
RED_LED_OFF();
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sei(); // enable interrupts globally
sleep_mode(); // go to sleep
while(1)
{
Receive_Packet();
sleep_mode();
}
}
开发者ID:visakhanc,项目名称:RFM70,代码行数:17,代码来源:main.c
示例20: main
// Start program
int main(void)
{
// Timer initialize
InitTimer1();
InitTimer0();
// Set LED pin to output
LED_DDR = (1 << LED_OUT);
// Enable interrupts
sei();
while(1)
{
// Sleep Mode
set_sleep_mode(SLEEP_MODE_IDLE);
sleep_mode();
// If command exists ... compare
if (CmdDone == 1)
{
// If matches required command
if (RC5_cmd_val == RC5_CMD)
{
// Sleep disablen
//sleep_disable();
// Set output to 1
LED_PORT |= (1 << LED_OUT);
// Set CmdMatch to 1 ... no new command will be sampled
CmdMatch = 1;
// Set TimerValue to zero
TimerValue = 0;
// Start counting
StartTimer0();
}
// Reset all values
RC5_cmd_val = 0x00;
CmdBitNumber = 7;
StartBit = 0;
CmdDone = 0;
}
}
}
开发者ID:cronJ,项目名称:RC5ControlledClocklight,代码行数:46,代码来源:RC5ControlledClocklight.c
注:本文中的set_sleep_mode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论