error for sleep function

good day everyone

im trying to build a sunlogger following the guides from Data-Logger/Datalogger.ino at master · Make-Magazine/Data-Logger · GitHub

however, because i needed to take data of 10 separate sensors, i used mega2560 instead of uno. during compilation into uno things are fine, but not when im uploading into the mega, where it shows these errors:

Arduino: 1.6.5 (Windows 8), Board: “Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)”

sketch_jul01a.ino: In function ‘void sleepCPU_delay(long int)’:
sketch_jul01a:194: error: ‘PRR’ was not declared in this scope
sketch_jul01a.ino: In function ‘int doSleep(long int)’:
sketch_jul01a:221: error: ‘BODS’ was not declared in this scope
sketch_jul01a:221: error: ‘BODSE’ was not declared in this scope
‘PRR’ was not declared in this scope

here written sleep function (obtained from the link abv):

// Delay function
void sleepCPU_delay(long sleepTime) {
  ADCSRA &= ~(1<<ADEN);  // adc off
  PRR = 0xFF; // modules off

  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  int trem = doSleep(sleepTime*calibv);
  timeSleep += (sleepTime-trem);

  PRR = 0x00; //modules on
  ADCSRA |= (1<<ADEN);  // adc on
}


// internal function.  
int doSleep(long timeRem) {
  byte WDTps = 9;  // WDT Prescaler value, 9 = 8192ms

  isrcalled = 0;
  sleep_enable();
  while(timeRem > 0) {

    while ((0x10<<WDTps) > timeRem && WDTps > 0) {
      WDTps--;
    }

    WDT_On((WDTps & 0x08 ? (1<<WDP3) : 0x00) | (WDTps & 0x07));
    isrcalled=0;
    while (isrcalled==0) {

      MCUCR |= (1<<BODS) | (1<<BODSE);
      MCUCR &= ~(1<<BODSE);  // must be done right before sleep
      sleep_cpu();  // sleep here
    }

    timeRem -= (0x10<<WDTps);
  }
  sleep_disable();
  return timeRem;
}


// wdt int service routine
ISR(WDT_vect) {
  WDT_Off();
  isrcalled=1;
}

i have no idea which part to modify for my arduino mega.
any help would be greatly appreciated. thank you =)

sketch_jul01a:194: error: ‘PRR’ was not declared in this scope

The m2560 does not have a single PRR register. The two registers are named PRR0 and PRR1.

I suggest using the power function instead…
http://www.nongnu.org/avr-libc/user-manual/group__avr__power.html

sketch_jul01a:221: error: 'BODS' was not declared in this scope
sketch_jul01a:221: error: 'BODSE' was not declared in this scope

The m2560 does not support disabling the Brown Out Detector. That code will have to removed.

so i can safely remove these functions from the code without affecting its ability to collect data? only with increase in current draw right?
// Calibrate watchdog timer with millis() timer(timer0)
// Delay function
// internal function.
// wdt int service routine

#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet.h>
#include <EthernetClient.h>
#include <EthernetServer.h>
#include <EthernetUdp.h>

#include <SPI.h>
#include <SD.h>
#include <Time.h>  
#include <avr/sleep.h>
#include <avr/wdt.h>

long timeSleep = 0;  // total time due to sleep
float calibv = 0.93; // ratio of real clock with WDT clock
volatile byte isrcalled = 0;  // WDT vector flag

#define TIME_MSG_LEN  11   // time sync to PC is HEADER followed by unix time_t as ten ascii digits
#define TIME_HEADER  'T'   // Header tag for serial time sync message
#define TIME_REQUEST  7    // ASCII bell character requests a time sync message 
#define SAMPLEDELAY 300000  // Delay before making a sample

const int chipSelect = 53;
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup()
{
  Serial.begin(9600);
  

  pinMode(10, OUTPUT);
  

  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");

    return;
  }
  Serial.println("card initialized.");

  setSyncProvider( requestSync);  //set function to call when sync required
  Serial.println("Waiting for sync message");
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop()
{
  if(Serial.available() ) 
  {
    processSyncMessage();
  }
  if(timeStatus()!= timeNotSet) 
  {
    while(true)
    {
      // Sample
      String dataString = "";
      
      for (int analogPin = 0; analogPin < 9; analogPin++) {
    int sensor = analogRead(analogPin);
      
      dataString += String(dayStr(weekday()));
      dataString += String(",");
      dataString += String(day());
      dataString += String(",");
      dataString += String(monthShortStr(month())); 
      dataString += String(",");
      dataString += String(year());
      dataString += String(",");

      dataString += String(hour());
      dataString += String(":");
      dataString += String(minute());
      dataString += String(":");
      dataString += String(second());
      dataString += String(",");
      
      dataString += String(sensor);
      
    if (analogPin < 8) {
      dataString += "; ";
    }
      }
    
      // Write
      WriteValToCard(dataString);

      // Wait
      delay(SAMPLEDELAY);
    }
  }
}

//////////////////////////////////////////////////////////////////////////////////////////////////
void WriteValToCard(String val)
{

  File dataFile = SD.open("datalog.txt", FILE_WRITE);

  if (dataFile) 
  {
    dataFile.println(val);
    dataFile.close();

    Serial.println(val);
  }  

  else {
    Serial.println("Error opening datalog.txt");
  } 

}

/////////////////////////////////////////////////////////////////////////////////////////////////
void processSyncMessage() {

  while(Serial.available() >=  TIME_MSG_LEN ){  
    char c = Serial.read() ; 
    Serial.print(c);  
    if( c == TIME_HEADER ) {       
      time_t pctime = 0;
      for(int i=0; i < TIME_MSG_LEN -1; i++){   
        c = Serial.read();          
        if( c >= '0' && c <= '9'){   
          pctime = (10 * pctime) + (c - '0') ; // convert digits to a number    
        }
      }   
      setTime(pctime);   // Sync Arduino clock to the time received on the serial port
    }  
  }
}

/////////////////////////////////////////////////////////////////////////////////////////////////
time_t requestSync()
{
  Serial.write(TIME_REQUEST);  
  return 0; // the time will be sent later in response to serial mesg
}

/////////////////////////////////////////////////////////////////////////////////////////////////
// Internal function: Start watchdog timer

void WDT_On (byte psVal)
{

  byte ps = (psVal | (1<<WDIE)) & ~(1<<WDE);
  cli();
  wdt_reset();
  /* Clear WDRF in MCUSR */
  MCUSR &= ~(1<<WDRF);

  WDTCSR |= (1<<WDCE) | (1<<WDE);

  WDTCSR = ps;
  sei();
}

/////////////////////////////////////////////////////////////////////////////////////////////////
// Internal function.  Stop watchdog timer
void WDT_Off() {
  cli();
  wdt_reset();
  /* Clear WDRF in MCUSR */
  MCUSR &= ~(1<<WDRF);
  /* Write logical one to WDCE and WDE */
  /* Keep old prescaler setting to prevent unintentional time-out */
  WDTCSR |= (1<<WDCE) | (1<<WDE);
  /* Turn off WDT */
  WDTCSR = 0x00;
  sei();
}

/////////////////////////////////////////////////////////////////////////////////////////////////
// Calibrate watchdog timer with millis() timer(timer0)
void calibrate() {

  set_sleep_mode(SLEEP_MODE_IDLE);
  long tt1=millis();
  doSleep(256);
  long tt2=millis();
  calibv = 256.0/(tt2-tt1);
}

/////////////////////////////////////////////////////////////////////////////////////////////////

long estMillis() {
  return millis()+timeSleep;
}

/////////////////////////////////////////////////////////////////////////////////////////////////
// Delay function
void sleepCPU_delay(long sleepTime) {
  ADCSRA &= ~(1<<ADEN);  // adc off
  PRR0 = 0xFF; // modules off

  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  int trem = doSleep(sleepTime*calibv);
  timeSleep += (sleepTime-trem);

  PRR0 = 0x00; //modules on
  ADCSRA |= (1<<ADEN);  // adc on
}

/////////////////////////////////////////////////////////////////////////////////////////////////
// internal function.  
int doSleep(long timeRem) {
  byte WDTps = 9;  // WDT Prescaler value, 9 = 8192ms

  isrcalled = 0;
  sleep_enable();
  while(timeRem > 0) {

    while ((0x10<<WDTps) > timeRem && WDTps > 0) {
      WDTps--;
    }

    WDT_On((WDTps & 0x08 ? (1<<WDP3) : 0x00) | (WDTps & 0x07));
    isrcalled=0;
    while (isrcalled==0) {

      MCUCR |= (1<<BODS) | (1<<BODSE);
      MCUCR &= ~(1<<BODSE);  // must be done right before sleep
      sleep_cpu();  // sleep here
    }

    timeRem -= (0x10<<WDTps);
  }
  sleep_disable();
  return timeRem;
}

//////////////////////////////////////////////////////////////////////////////////////////////////
// wdt int service routine
ISR(WDT_vect) {
  WDT_Off();
  isrcalled=1;
}

tried removing these functions, and it seems that the logger would not log anything.

so there's no workaround for this issue?