Waspmote API  v 0.32
wiring.c File Reference
#include "wiring_private.h"
#include "WaspConstants.h"
Include dependency graph for wiring.c:

Go to the source code of this file.

Functions

void wakeUpNowDefault ()
void setup_watchdog (uint8_t ii)
 ISR (WDT_vect)
void off_watchdog (void)
 SIGNAL (SIG_OVERFLOW0)
 SIGNAL (SIG_OVERFLOW2)
unsigned long millis ()
unsigned long millisTim2 ()
void delay (unsigned long ms)
void delayMicroseconds (unsigned int us)
void wait (uint8_t mode)
void waitFor (uint8_t mode, uint8_t time)
void init ()
void setIPF_ (uint8_t peripheral)
void resetIPF_ (uint8_t peripheral)

Variables

uint8_t IPRA = 0
uint8_t IPRB = 0
volatile uint8_t f_wdt = 1
volatile unsigned long timer0_overflow_count
volatile unsigned long timer2_overflow_count

Function Documentation

void delay ( unsigned long  ms)

Definition at line 144 of file wiring.c.

References millis().

Referenced by WaspRFID13::authenticate(), WaspUtils::blinkLEDs(), WaspACC::boot(), WaspSensorParking::calibration(), WaspRFID13::changeBaudRate(), WaspGPRS::check(), WaspGPS::check(), WaspGPRS_Pro::check(), WaspXBeeCore::checkNewProgram(), WaspWIFI::commandMode(), WaspRFID13::configureSAM(), WaspSensorGas::configureSensor(), WaspGPRS::createSocket(), WaspXBeeCore::delete_firmware(), WaspGPRS::downloadFile(), WaspBT_Pro::eraseSDFiles(), WaspXBeeXSC::exitCommandMode(), WaspGPS::extractDate(), WaspGPS::extractTime(), WaspSensorSmart_v20::flow_reading(), WaspXBeeXSC::forceReset(), WaspXBeeXSC::forceWakeUP(), WaspRFID13::getACK(), WaspXBee802::getACKcounter(), WaspXBeeXSC::getAddressMask(), WaspWIFI::getAdhocSettings(), WaspGPS::getAltitude(), WaspWIFI::getAPstatus(), WaspXBeeXSC::getAwakeTime(), WaspXBeeXSC::getBaudRate(), WaspWIFI::getBroadcastSettings(), WaspXBee802::getCCAcounter(), WaspGPRS::getCellInfo(), WaspXBee868::getChannelRSSI(), WaspXBeeDM::getChannelRSSI(), WaspWIFI::getComSettings(), WaspWIFI::getConnectionInfo(), WaspGPS::getCourse(), WaspXBeeXSC::getDelaySlots(), WaspXBeeXSC::getDestAddress(), WaspXBeeZB::getDeviceType(), WaspXBee868::getDeviceType(), WaspWIFI::getDNSsettings(), WaspXBeeZB::getExtendedPAN(), WaspWIFI::getFile(), WaspRFID13::getFirmware(), WaspWIFI::getFTPsettings(), WaspXBee868::getGoodPackets(), WaspXBeeDM::getGoodPackets(), WaspXBeeXSC::getHoppingChannel(), WaspGPRS::getIfReady(), WaspGPRS_Pro::getIfReady(), WaspWIFI::getIP(), WaspGPS::getLatitude(), WaspGPS::getLongitude(), WaspWIFI::getMAC(), WaspXBeeDM::getMeshNetworkRetries(), WaspXBeeDM::getNetworkDelaySlots(), WaspXBeeDM::getNetworkHops(), WaspXBeeDM::getNetworkRouteRequests(), WaspXBeeZB::getOperatingPAN(), WaspWIFI::getOptionSettings(), WaspXBeeXSC::getPacketTimeout(), WaspXBeeCore::getPAN(), WaspXBeeXSC::getPinWakeUP(), WaspGPS::getPosition(), WaspGPS::getRaw(), WaspXBeeXSC::getReceiveErrorCount(), WaspXBeeXSC::getReceiveGoodCount(), WaspXBeeXSC::getRetries(), WaspXBee868::getRFerrors(), WaspXBeeDM::getRFerrors(), WaspXBeeXSC::getRSSI(), WaspWIFI::getRSSI(), WaspXBeeCore::getRSSI(), WaspXBeeXSC::getRSSItime(), WaspXBeeXSC::getRSSIvalue(), WaspXBeeXSC::getSleepMode(), WaspXBeeXSC::getSoftVersion(), WaspXBeeXSC::getSourceMacHigh(), WaspXBeeXSC::getSourceMacLow(), WaspGPS::getSpeed(), WaspWIFI::getStats(), WaspXBeeXSC::getStopBits(), WaspXBee868::getSupplyVoltage(), WaspXBeeDM::getSupplyVoltage(), WaspXBeeZB::getSupplyVoltage(), WaspWIFI::getSystemSettings(), WaspBT_Pro::getTemp(), WaspXBee868::getTemperature(), WaspXBeeDM::getTemperature(), WaspWIFI::getTime(), WaspXBeeXSC::getTimeBeforeInit(), WaspXBeeXSC::getTimeBeforeWakeUP(), WaspXBeeXSC::getTimeWakeUpInit(), WaspXBee868::getTransmisionErrors(), WaspXBeeDM::getTransmisionErrors(), WaspXBeeXSC::getTransmitErrorCount(), WaspXBeeXSC::getTransmitLimit(), WaspWIFI::getUARTsettings(), WaspWIFI::getUpTime(), WaspXBeeXSC::getVendorID(), WaspWIFI::getVersion(), WaspWIFI::getWLANsettings(), WaspPWR::hibernate(), WaspPWR::ifHibernate(), WaspSensorRadiation::init(), WaspRFID13::init(), WaspBT_Pro::init(), WaspGPS::init(), WaspWIFI::isConnected(), WaspGPS::loadEphems(), WaspSensorEvent::loadInt(), WaspSensorSmart::loadInt(), WaspSensorCities::loadInt(), WaspGPRS::makeLostCall(), WaspGPRS_Pro::makeLostCall(), WaspXBeeCore::new_firmware_end(), WaspWIFI::OFF(), WaspSensorRadiation::ON(), WaspRFID13::ON(), WaspWIFI::ON(), WaspXBeeXSC::ON(), WaspXBeeCore::ON(), WaspWIFI::open(), WaspWIFI::openHTTP(), WaspRFID13::powerDown(), WaspSensorGas::pulse(), WaspSensorGas_v20::pulse(), WaspSensorAgr_v20::readAnemometer(), WaspBT_Pro::readCommandAnswer(), WaspRFID13::readData(), WaspWIFI::readData(), WaspGPRS::readData(), WaspGPRS::readDataFTP(), WaspGPRS_Pro::readDataFTP(), WaspSensorAgr_v20::readDendrometer(), WaspSensorAgr::readDendrometer(), WaspGPRS::readMail(), WaspSensorParking::readParkingSetReset(), WaspSensorAgr_v20::readPluviometer(), WaspSensorAgr::readPluviometer(), WaspSensorAgr_v20::readPT1000(), WaspSensorAgr::readPT1000(), WaspSensorAgr_v20::readRadiation(), WaspSensorAgr::readRadiation(), WaspSensorParking::readTemperature(), WaspSensorSmart::readValue(), WaspSensorCities::readValue(), WaspSensorGas_v20::readValue(), WaspSensorSmart::readValue_int(), WaspXBeeCore::request_bootlist(), WaspXBeeCore::request_ID(), WaspBT_Pro::reset(), WaspWIFI::reset(), WaspWIFI::resolve(), WaspXBeeXSC::restoreDefaults(), WaspGPS::saveEphems(), WaspWIFI::saveReboot(), WaspWIFI::scan(), WaspBT_Pro::scanNetwork(), WaspBT_Pro::scanNetworkLimited(), WaspBT_Pro::sendCommand(), WaspGPRS::sendCommand(), WaspGPRS_Pro::sendCommand(), WaspXBeeXSC::sendCommandAT(), WaspXBeeCore::sendCommandAT(), WaspBT::sendData(), WaspGPRS::sendData(), WaspGPRS::sendDataFTP(), WaspGPRS_Pro::sendDataFTP(), WaspGPRS::sendMail(), WaspWIFI::sendPing(), WaspRFID13::sendTX(), WaspXBeeCore::sendXBee(), WaspXBeeCore::sendXBeePriv(), WaspXBeeXSC::setAddressMask(), WaspSensorGas::setAmplifier(), WaspSensorGas_v20::setAmplifier(), WaspSensorPrototyping::setAmplifierGain(), WaspSensorSmart::setAmplifierGain(), WaspSensorCities::setAudioGain(), WaspXBeeXSC::setAwakeTime(), WaspXBeeXSC::setBaudRate(), WaspSensorAgr::setBoardMode(), WaspXBeeXSC::setCommandMode(), WaspGPS::setCommMode(), WaspXBeeXSC::setDelaySlots(), WaspXBeeXSC::setDestAddress(), WaspSensorAgr::setDigipot(), WaspSensorEvent::setDigipot0(), WaspSensorCities::setDigipot0(), WaspSensorSmart::setDigipot0(), WaspSensorEvent::setDigipot1(), WaspSensorCities::setDigipot1(), WaspSensorSmart::setDigipot1(), WaspXBeeXSC::setHoppingChannel(), WaspWIFI::setJoinMode(), WaspSensorPrototyping::setLoadResistor(), WaspSensorSmart::setLoadResistor(), WaspPWR::setLowBatteryThreshold(), WaspBT_Pro::setMode(), WaspSD::setMode(), WaspGPRS::setMode(), WaspGPRS_Pro::setMode(), WaspXBeeXSC::setPacketTimeout(), WaspXBeeXSC::setPinWakeUP(), WaspXBeeXSC::setReceiveErrorCount(), WaspXBeeXSC::setReceiveGoodCount(), WaspSensorGas::setResistor(), WaspSensorGas_v20::setResistor(), WaspXBeeXSC::setRetries(), WaspXBeeXSC::setRSSItime(), WaspXBeeXSC::setSleepMode(), WaspXBeeXSC::setStopBits(), WaspXBeeXSC::setTimeBeforeInit(), WaspXBeeXSC::setTimeBeforeWakeUP(), WaspXBeeXSC::setTimeWakeUpInit(), WaspXBeeXSC::setTransmitErrorCount(), WaspXBeeXSC::setTransmitLimit(), WaspXBeeXSC::setVendorID(), WaspGPRS_Pro::switchtoCommandMode(), WaspXBeeCore::synchronization(), SoftwareSerial::tunedDelay(), WaspXBeeCore::upload_firmware(), WaspWIFI::uploadFile(), WaspGPRS::uploadFile(), WaspGPRS::waitForData(), WaspGPRS_Pro::waitForData(), WaspBT_Pro::waitInquiryAnswer(), WaspRFID13::waitResponse(), WaspBT_Pro::waitScanDeviceAnswer(), WaspXBeeXSC::wake(), WaspWIFI::wake(), WaspXBeeCore::wake(), WaspRFID13::wakeUp(), WaspRFID13::writeData(), and WaspXBeeXSC::writeValues().

{
        unsigned long start = millis();
        
        while (millis() - start < ms);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void delayMicroseconds ( unsigned int  us)

Definition at line 154 of file wiring.c.

Referenced by WaspSensorAgr_v20::readSensirion(), and WaspSensorAgr::readSensirion().

{
        uint8_t oldSREG;

        // calling avrlib's delay_us() function with low values (e.g. 1 or
        // 2 microseconds) gives delays longer than desired.
        //delay_us(us);

#if F_CPU >= 16000000L
    // for the 16 MHz clock on most Arduino boards

        // for a one-microsecond delay, simply return.  the overhead
        // of the function call yields a delay of approximately 1 1/8 us.
        if (--us == 0)
                return;

        // the following loop takes a quarter of a microsecond (4 cycles)
        // per iteration, so execute it four times for each microsecond of
        // delay requested.
        us <<= 2;

        // account for the time taken in the preceeding commands.
        us -= 2;
#else
    // for the 8 MHz internal clock on the ATmega168

    // for a one- or two-microsecond delay, simply return.  the overhead of
    // the function calls takes more than two microseconds.  can't just
    // subtract two, since us is unsigned; we'd overflow.
        if (--us == 0)
                return;
        if (--us == 0)
                return;

        // the following loop takes half of a microsecond (4 cycles)
        // per iteration, so execute it twice for each microsecond of
        // delay requested.
        us <<= 1;
    
    // partially compensate for the time taken by the preceeding commands.
    // we can't subtract any more than this or we'd overflow w/ small delays.
    us--;
#endif

        // disable interrupts, otherwise the timer 0 overflow interrupt that
        // tracks milliseconds will make us delay longer than we want.
        oldSREG = SREG;
        cli();

        // busy wait
        __asm__ __volatile__ (
                "1: sbiw %0,1" "\n\t" // 2 cycles
                "brne 1b" : "=w" (us) : "0" (us) // 2 cycles
        );

        // reenable interrupts.
        SREG = oldSREG;
}

Here is the caller graph for this function:

void init ( void  )

Definition at line 278 of file wiring.c.

References cbi, sbi, and timer0_overflow_count.

Referenced by main().

{
        // this needs to be called before setup() or some functions won't
        // work there
        sei();
        
    /* Setup Watchdog */      
    // Use Timed Sequence for disabling Watchdog System Reset Mode if it has been enabled unintentionally.
    cbi(MCUSR, WDRF);                                 // Clear WDRF if it has been unintentionally set.

        // timer 0 is used for millis() and delay()
        timer0_overflow_count = 0;
        // on the ATmega168, timer 0 is also used for fast hardware pwm
        // (using phase-correct PWM would mean that timer 0 overflowed half as often
        // resulting in different millis() behavior on the ATmega8 and ATmega168)
        sbi(TCCR0A, WGM01);
        sbi(TCCR0A, WGM00);

        // set timer 0 prescale factor to 64
        sbi(TCCR0B, CS01);
        sbi(TCCR0B, CS00);

        // enable timer 0 overflow interrupt
        sbi(TIMSK0, TOIE0);

        // timers 1 and 2 are used for phase-correct hardware pwm
        // this is better for motors as it ensures an even waveform
        // note, however, that fast pwm mode can achieve a frequency of up
        // 8 MHz (with a 16 MHz clock) at 50% duty cycle

        // set timer 1 prescale factor to 64
        sbi(TCCR1B, CS11);
        sbi(TCCR1B, CS10);
        // put timer 1 in 8-bit phase correct pwm mode
        sbi(TCCR1A, WGM10);

        // set timer 2 prescale factor to 64
        sbi(TCCR2B, CS22);
        sbi(TCCR3B, CS32);

        // configure timer 2 for phase correct pwm (8-bit)
        sbi(TCCR2A, WGM20);
        sbi(TCCR3A, WGM30);

        // configure and enable a2d conversions
    //FIXME: this is to turn on ADC!! 
        //PWR.setIPF(IPADC); //---> the following is taken from WaspPWR
        // turn on the power on the ADC
        // by writing a zero to the register
        cbi(PRR0, PRADC);

            // set a2d reference to AVCC (5 volts)
            cbi(ADMUX, REFS1);
            sbi(ADMUX, REFS0);

                // set a2d prescale factor to 128
                // 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range.
                // FIXME: this will not work properly for other clock speeds, and
                // this code should use F_CPU to determine the prescale factor.
                sbi(ADCSRA, ADPS2);
                sbi(ADCSRA, ADPS1);

        // enable a2d conversions
        sbi(ADCSRA, ADEN);
        

        // the bootloader connects pins 0 and 1 to the USART; disconnect them
        // here so they can be used as normal digital i/o; they will be
        // reconnected in Serial.begin()
        UCSR0B = 0;
        UCSR1B = 0;
}

Here is the caller graph for this function:

ISR ( WDT_vect  )

Definition at line 76 of file wiring.c.

References digitalWrite(), f_wdt, LOW, and WTD_INT_PIN_MON.

              {
        cli();
  f_wdt=1;  // set global flag
        WDTCSR |= (1<<WDIF);
        WDTCSR &= ~(1<<WDIE);               // Disable Watchdog Interrupt Mode
        digitalWrite(WTD_INT_PIN_MON,LOW);
        sei();
}

Here is the call graph for this function:

unsigned long millis ( void  )

Definition at line 118 of file wiring.c.

References timer0_overflow_count.

Referenced by WaspGPS::check(), WaspXBeeXSC::check(), WaspXBeeCore::checkNewProgram(), WaspXBeeCore::checkOtapTimeout(), WaspGPRS::createSocket(), delay(), WaspXBeeCore::delete_firmware(), WaspGPRS::downloadFile(), WaspGPS::extractDate(), WaspGPS::extractTime(), WaspSensorSmart_v20::flow_reading(), WaspGPS::getAltitude(), WaspGPRS::getCellInfo(), WaspGPRS_Pro::getCellInfo(), WaspGPS::getCourse(), WaspSensorRadiation::getCPM(), WaspGPRS::getIMEI(), WaspGPRS_Pro::getIMEI(), WaspGPRS::getIMSI(), WaspGPRS_Pro::getIMSI(), WaspGPRS_Pro::getIP(), WaspGPS::getLatitude(), WaspGPS::getLongitude(), WaspGPS::getPosition(), WaspSensorRadiation::getRadiation(), WaspGPS::getSpeed(), Sd2Card::init(), WaspGPS::init(), WaspGPS::loadEphems(), WaspGPRS_Pro::manageIncomingData(), WaspGPRS::manageIncomingGSMData(), WaspXBeeCore::new_firmware_end(), WaspXBeeCore::new_firmware_packets(), WaspXBeeCore::new_firmware_received(), WaspBT::parse_data(), WaspXBeeCore::parse_message(), WaspWIFI::read(), WaspSensorAgr_v20::readAnemometer(), WaspXBeeXSC::readData(), WaspGPRS::readData(), WaspGPRS::readDataFTP(), WaspGPRS_Pro::readDataFTP(), WaspGPRS::readMail(), WaspSensorAgr_v20::readPluviometer(), WaspSensorAgr::readPluviometer(), WaspSensorAgr_v20::readSensirion(), WaspSensorAgr::readSensirion(), WaspGPRS::readSMS(), WaspGPRS_Pro::readSMS(), WaspSensorAgr_v20::readWatermark(), WaspSensorAgr::readWatermark(), WaspXBeeCore::readXBee(), WaspXBeeCore::request_bootlist(), WaspXBeeCore::request_ID(), WaspGPS::saveEphems(), WaspGPRS::sendData(), WaspGPRS::sendDataFTP(), WaspGPRS_Pro::sendDataFTP(), WaspGPRS::sendMail(), WaspXBeeCore::sendXBeePriv(), WaspXBeeCore::synchronization(), WaspXBeeCore::txStatusResponse(), WaspXBeeCore::txZBStatusResponse(), WaspXBeeCore::upload_firmware(), WaspGPRS::uploadFile(), WaspBT_Pro::waitInquiryAnswer(), Sd2Card::waitNotBusy(), WaspBT_Pro::waitScanDeviceAnswer(), and Sd2Card::waitStartBlock().

{
        // timer 0 increments every 64 cycles, and overflows when it reaches
        // 256.  we would calculate the total number of clock cycles, then
        // divide by the number of clock cycles per millisecond, but this
        // overflows too often.
        //return timer0_overflow_count * 64UL * 256UL / (F_CPU / 1000UL);
        
        // instead find 1/128th the number of clock cycles and divide by
        // 1/128th the number of clock cycles per millisecond
        return timer0_overflow_count * 64UL * 2UL / (F_CPU / 128000UL);
}

Here is the caller graph for this function:

unsigned long millisTim2 ( void  )

Definition at line 131 of file wiring.c.

References timer2_overflow_count.

{
        // timer 1 increments every 64 cycles, and overflows when it reaches
        // 256.  we would calculate the total number of clock cycles, then
        // divide by the number of clock cycles per millisecond, but this
        // overflows too often.
        //return timer0_overflow_count * 64UL * 256UL / (F_CPU / 1000UL);
        
        // instead find 1/128th the number of clock cycles and divide by
        // 1/128th the number of clock cycles per millisecond
        return timer2_overflow_count;
}
void off_watchdog ( void  )

Definition at line 87 of file wiring.c.

References digitalWrite(), HIGH, and WTD_INT_PIN_MON.

Referenced by WaspPWR::setWatchdog(), and waitFor().

{
   cli();
   //watchdog_reset();
   MCUSR &= ~(1<<WDRF);

   WDTCSR |= (1<<WDCE) | (1<<WDIE) | (1<<WDE);  // Start timed sequence
   WDTCSR =  0x00;  // turn off WDT
   digitalWrite(WTD_INT_PIN_MON,HIGH);
   sei();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void resetIPF_ ( uint8_t  peripheral)

Definition at line 426 of file wiring.c.

References cbi, IPADC, IPRA, IPSPI, IPTWI, IPUSART0, IPUSART1, and sbi.

Referenced by closeSerial(), and WaspPWR::resetIPF().

{
    // mark it on the IPFA
    IPRA &= ~peripheral; 

    // check which flags have been de-activated
    // ADC, flag IPADC
    if (peripheral & IPADC > 0) {
        // disable a2d conversions
        cbi(ADCSRA, ADEN);
        // turn off the power on the ADC
        // by writing a one to the register
        sbi(PRR0, PRADC);
    }
    // TWI, flag IPTWI (also known as I2C)
    if (peripheral & IPTWI > 0) {
        // turn off the power on the TWI
        // by writing a one to the register
        sbi(PRR0, PRTWI);
    }
    // SPI, flag IPSPI (where the SD card hangs)
    if (peripheral & IPSPI > 0) {
        // turn off the power on the SPI
        // by writing a one to the register
        sbi(PRR0, PRSPI);
    }
    // USART0, flag IPUSART0 
    if (peripheral & IPUSART0 > 0) {
        // turn off the power on the USART0
        // by writing a one to the register
        sbi(PRR0, PRUSART0);
    }
    // USART1, flag IPUSART1 
    if (peripheral & IPUSART1 > 0) {
        // turn off the power on the USART0
        // by writing a one to the register
        sbi(PRR1, PRUSART1);
    }
}

Here is the caller graph for this function:

void setIPF_ ( uint8_t  peripheral)

Definition at line 360 of file wiring.c.

References cbi, IPADC, IPRA, IPSPI, IPTWI, IPUSART0, IPUSART1, and sbi.

Referenced by beginSerial(), and WaspPWR::setIPF().

{
    // mark it on the IPFA
    IPRA |= peripheral; 

    // check which flags have been activated
    // ADC, flag IPADC
    if (peripheral & IPADC > 0) {
        // turn on the power on the ADC
        // by writing a zero to the register
        cbi(PRR0, PRADC);

        // set a2d reference to AVCC (5 volts)
        cbi(ADMUX, REFS1);
        sbi(ADMUX, REFS0);

        // set a2d prescale factor to 128
        // 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range.
        // FIXME: this will not work properly for other clock speeds, and
        // this code should use F_CPU to determine the prescale factor.
        sbi(ADCSRA, ADPS2);
        sbi(ADCSRA, ADPS1);

        // enable a2d conversions
        sbi(ADCSRA, ADEN);
    }
    // TWI, flag IPTWI
    if (peripheral & IPTWI > 0) {
        // turn on the power on the TWI
        // by writing a zero to the register
        cbi(PRR0, PRTWI);

        // initialize the TWI
        //FIXME: without this reinitialization the peripheral may not work!!
        //Wire.begin();
    }
    // SPI, flag IPSPI (aka SD card)
    if (peripheral & IPSPI > 0) {
        // turn on the power on the SPI
        // by writing a zero to the register
        cbi(PRR0, PRSPI);

        // initialize the SD
        // FIXME: this command is not ready yet, since the library is not finished
        //SD.begin();
    }
    // USART0, flag IPUSART0
    if (peripheral & IPUSART0 > 0) {
        // turn on the power on the USART0
        // by writing a zero to the register
        cbi(PRR0, PRUSART0);
    }
    // USART1, flag IPUSART1
    if (peripheral & IPUSART1 > 0) {
        // turn on the power on the USART0
        // by writing a zero to the register
        cbi(PRR1, PRUSART1);
    }
}

Here is the caller graph for this function:

void setup_watchdog ( uint8_t  ii)

Definition at line 51 of file wiring.c.

References f_wdt.

Referenced by WaspPWR::setWatchdog(), and waitFor().

                                {

        cli();
  f_wdt = 0;
  uint8_t bb;
  uint8_t ww;
  if (ii > 9 ) ii=9;
  bb=ii & 7;
  if (ii > 7) bb|= (1<<5);
  bb|= (1<<WDCE);
  ww=bb;

  MCUSR &= ~(1<<WDRF);
  // start timed sequence
  WDTCSR |= (1<<WDCE) | (1<<WDE);

  // set new watchdog timeout value
  WDTCSR = bb;
  WDTCSR |= _BV(WDIE);
        sei();


}

Here is the caller graph for this function:

SIGNAL ( SIG_OVERFLOW0  )

Definition at line 104 of file wiring.c.

References timer0_overflow_count.

SIGNAL ( SIG_OVERFLOW2  )

Definition at line 113 of file wiring.c.

References timer2_overflow_count.

void wait ( uint8_t  mode)

Definition at line 255 of file wiring.c.

References waitFor().

                         {
                waitFor( mode, 9);                       // by default we take the longest time available (8secs)
}

Here is the call graph for this function:

void waitFor ( uint8_t  mode,
uint8_t  time 
)

Definition at line 264 of file wiring.c.

References cbi, off_watchdog(), sbi, and setup_watchdog().

Referenced by wait().

                                          {
            cbi(ADCSRA,ADEN);        // switch Analog to Digitalconverter OFF
        set_sleep_mode(mode);    // sleep mode is set here
                setup_watchdog(time);
        sleep_enable();          // enables the sleep bit in the mcucr register
                                 // so sleep is possible. just a safety pin 
        
        sleep_mode();            // here the device is actually put to sleep!!
                                 // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP
                off_watchdog();
        sleep_disable();         // first thing after waking from sleep:
            sbi(ADCSRA,ADEN);        // switch Analog to Digitalconverter ON
}

Here is the call graph for this function:

Here is the caller graph for this function:

void wakeUpNowDefault ( void  )

Definition at line 39 of file wiring.c.

{
  // execute code here after wake-up before returning to the loop() function
  // timers and code using timers (serial.print and more...) will not work here.
  // we don't really need to execute any special functions here, since we
  // just want the thing to wake up
}

Variable Documentation

volatile uint8_t f_wdt = 1

Definition at line 47 of file wiring.c.

Referenced by ISR(), and setup_watchdog().

uint8_t IPRA = 0

Definition at line 32 of file wiring.c.

Referenced by resetIPF_(), and setIPF_().

uint8_t IPRB = 0

Definition at line 33 of file wiring.c.

volatile unsigned long timer0_overflow_count

Definition at line 102 of file wiring.c.

Referenced by init(), millis(), and SIGNAL().

volatile unsigned long timer2_overflow_count

Definition at line 111 of file wiring.c.

Referenced by millisTim2(), and SIGNAL().

 All Data Structures Files Functions Variables Typedefs Friends Defines