本文整理汇总了C++中sleep_disable函数的典型用法代码示例。如果您正苦于以下问题:C++ sleep_disable函数的具体用法?C++ sleep_disable怎么用?C++ sleep_disable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sleep_disable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
示例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);
}
示例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();
}
}
示例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
}
}
}
示例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);
}
示例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();
}
示例7: sleep
static void sleep(int mode)
{
set_sleep_mode(mode);
sleep_enable();
sleep_mode();
sleep_disable();
}
示例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();
}
示例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
}
}
示例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().
示例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();
}
示例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
}
}
示例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();
}
示例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);
}
}
}
示例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();
}
}
}