Commit b7e7d5b1 authored by Frank Radzio 's avatar Frank Radzio

Tracking Node 01 erstellt

parent 77d23090
This diff is collapsed.
This diff is collapsed.
/*
ExternalWakeup
This sketch demonstrates the usage of External Interrupts (on pins) to wakeup a chip in sleep mode.
Sleep modes allow a significant drop in the power usage of a board while it does nothing waiting for an event to happen. Battery powered application can take advantage of these modes to enhance battery life significantly.
In this sketch, shorting pin 8 to a GND will wake up the board.
Please note that, if the processor is sleeping, a new sketch can't be uploaded. To overcome this, manually reset the board (usually with a single or double tap to the RESET button)
This example code is in the public domain.
*/
#include "ArduinoLowPower.h"
// Blink sequence number
// Declare it volatile since it's incremented inside an interrupt
volatile int repetitions = 1;
// Pin used to trigger a wakeup
const int pin = 8;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
// Set pin 8 as INPUT_PULLUP to avoid spurious wakeup
pinMode(pin, INPUT_PULLUP);
// Attach a wakeup interrupt on pin 8, calling repetitionsIncrease when the device is woken up
LowPower.attachInterruptWakeup(pin, repetitionsIncrease, CHANGE);
}
void loop() {
for (int i = 0; i < repetitions; i++) {
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
}
// Triggers an infinite sleep (the device will be woken up only by the registered wakeup sources)
// The power consumption of the chip will drop consistently
LowPower.sleep();
}
void repetitionsIncrease() {
// This function will be called once on device wakeup
// You can do some little operations here (like changing variables which will be used in the loop)
// Remember to avoid calling delay() and long running functions since this functions executes in interrupt context
repetitions ++;
}
\ No newline at end of file
/*
PrimoDeepSleep.ino
Written by Chiara Ruggeri (chiara@arduino.org)
This example for the Arduino Primo board shows how to use
low power library to enter in power off mode and save power.
This mode ensure the deepest power saving mode. If you need
a faster response from the board use standby function instead.
Please note that once exited from the deepest sleep mode the
board will reset (so setup will be run again).
The functions enableWakeupFrom set the peripheral that will wake up
the board. By calling it more than once you can choose more than
a wakeup source.
The board will be reset when it wakes up from power off.
You can use wakeUpCause() function to find out what signals woke up
the board if you use more than one wakeUpBy.. function.
This example code is in the public domain.
*/
#include "ArduinoLowPower.h"
// Pin used to wakeup the board
const int digitalPin = 10;
// Pin used in Compatarot module to wake up the board
const int analogPin = A0;
void StmEspPM(bool sleep){
// enable USER1_BUTTON to turn STM32 off and on when pressed.
// note that when STM32 is off you cannot load any new sketch.
pinMode(USER1_BUTTON, STM32_IT);
// turn ESP8266 off or on
digitalWrite(GPIO_ESP_PW, sleep ? LOW: HIGH);
}
void setup() {
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
//look for what peripheral woke up the board
//reason is 0 at the first execution
wakeup_reason reason=LowPower.wakeupReason();
if(reason==GPIO_WAKEUP) //GPIO caused the wake up
doMyStuff();
else
if(reason==NFC_WAKEUP) //NFC caused the wake up
doMyStuffWithNFC();
else
if(reason==ANALOG_COMPARATOR_WAKEUP) //Comparator caused the wake up
doOtherStuff();
Serial.println("Hi all, I return to sleep");
LowPower.companionLowPowerCallback(StmEspPM);
// Send sleep command to ESP and enable USER1_BUTTON to turn STM off
LowPower.companionSleep();
//set digital pin 10 to wake up the board when LOW level is detected
LowPower.enableWakeupFrom(GPIO_WAKEUP, digitalPin, LOW);
//let the board be woken up by any NFC field
LowPower.enableWakeupFrom(NFC_WAKEUP);
//wake up the board when the voltage on pin A0 goes below the voltage on pin AREF
LowPower.enableWakeupFrom(ANALOG_COMPARATOR_WAKEUP, analogPin, AREF, UP);
//go in low power mode. Note that the board will reset once it is woken up
LowPower.deepSleep();
}
void loop() {}
void doMyStuff(){
//insert your code here
}
void doMyStuffWithNFC(){
//insert your code here
}
void doOtherStuff(){
//insert your code here
}
/*
TianStandby
This sketch demonstrates the usage of SAMD chip to furtherly reduce the power usage of Tian
board. This method can be applied to any board with companion chips which expose a method
(via direct pin interrupt or via a command) to enter and exit standby.
Sleep modes allow a significant drop in the power usage of a board while it does nothing waiting for an event to happen. Battery powered application can take advantage of these modes to enhance battery life significantly.
In this sketch, the internal RTC of SAMD chip will wake up the processor every 20 seconds.
Before going to sleep, the SAMD chip tells the MIPS CPU to standby too.
Please note that, if the processor is sleeping, a new sketch can't be uploaded. To overcome this, manually reset the board (usually with a single or double tap to the RESET button)
This example code is in the public domain.
*/
#include "ArduinoLowPower.h"
#define MIPS_PIN 32
void MipsPM(bool sleep) {
pinMode(MIPS_PIN, OUTPUT);
digitalWrite(MIPS_PIN, sleep ? LOW: HIGH);
}
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
LowPower.companionLowPowerCallback(MipsPM);
// Uncomment this function if you wish to attach function dummy when RTC wakes up the chip
LowPower.attachInterruptWakeup(RTC_ALARM_WAKEUP, onWakeup, CHANGE);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
// Triggers a 2000 ms sleep (the device will be woken up only by the registered wakeup sources and by internal RTC)
// The power consumption of the chip will drop consistently
// Send sleep command to MIPS CPU and then go to sleep
LowPower.companionSleep();
LowPower.sleep(20000);
}
void onWakeup() {
// This function will be called once on device wakeup
// You can do some little operations here (like changing variables which will be used in the loop)
// Remember to avoid calling delay() and long running functions since this functions executes in interrupt context
// Wakeup the companion chip, too
LowPower.companionWakeup();
}
/*
TimedWakeup
This sketch demonstrates the usage of Internal Interrupts to wakeup a chip in sleep mode.
Sleep modes allow a significant drop in the power usage of a board while it does nothing waiting for an event to happen. Battery powered application can take advantage of these modes to enhance battery life significantly.
In this sketch, the internal RTC will wake up the processor every 2 seconds.
Please note that, if the processor is sleeping, a new sketch can't be uploaded. To overcome this, manually reset the board (usually with a single or double tap to the RESET button)
This example code is in the public domain.
*/
#include "ArduinoLowPower.h"
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
// Uncomment this function if you wish to attach function dummy when RTC wakes up the chip
// LowPower.attachInterruptWakeup(RTC_ALARM_WAKEUP, dummy, CHANGE);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
// Triggers a 2000 ms sleep (the device will be woken up only by the registered wakeup sources and by internal RTC)
// The power consumption of the chip will drop consistently
LowPower.sleep(2000);
}
void dummy() {
// This function will be called once on device wakeup
// You can do some little operations here (like changing variables which will be used in the loop)
// Remember to avoid calling delay() and long running functions since this functions executes in interrupt context
}
\ No newline at end of file
#######################################
# Syntax Coloring Map For Energy Saving
#######################################
#######################################
# Datatypes (KEYWORD1)
#######################################
ArduinoLowPower KEYWORD1
LowPower KEYWORD1
#######################################
# Methods and Functions (KEYWORD2)
#######################################
idle KEYWORD2
sleep KEYWORD2
deepSleep KEYWORD2
attachInterruptWakeup KEYWORD2
enableWakeupFrom KEYWORD2
companionLowPowerCallback KEYWORD2
companionSleep KEYWORD2
companionWakeup KEYWORD2
wakeupReason KEYWORD2
#######################################
# Constants (LITERAL1)
#######################################
OTHER_WAKEUP LITERAL1
GPIO_WAKEUP LITERAL1
NFC_WAKEUP LITERAL1
ANALOG_COMPARATOR_WAKEUP LITERAL1
\ No newline at end of file
name=Arduino Low Power
version=1.2.0
author=Arduino
maintainer=Arduino LLC
sentence=Power save primitives features for SAMD and nRF52 32bit boards
paragraph=With this library you can manage the low power states of newer Arduino boards
category=Device Control
url=http://arduino.cc/libraries/ArduinoLowPower
architectures=samd,nrf52
#ifndef _ARDUINO_LOW_POWER_H_
#define _ARDUINO_LOW_POWER_H_
#include <Arduino.h>
#ifdef ARDUINO_ARCH_AVR
#error The library is not compatible with AVR boards
#endif
#ifdef ARDUINO_ARCH_SAMD
#include "RTCZero.h"
#endif
#if defined(ARDUINO_SAMD_TIAN) || defined(ARDUINO_NRF52_PRIMO)
// add here any board with companion chip which can be woken up
#define BOARD_HAS_COMPANION_CHIP
#endif
#define RTC_ALARM_WAKEUP 0xFF
//typedef void (*voidFuncPtr)( void ) ;
typedef void (*onOffFuncPtr)( bool ) ;
typedef enum{
OTHER_WAKEUP = 0,
GPIO_WAKEUP = 1,
NFC_WAKEUP = 2,
ANALOG_COMPARATOR_WAKEUP = 3
} wakeup_reason;
class ArduinoLowPowerClass {
public:
void idle(void);
void idle(uint32_t millis);
void idle(int millis) {
idle((uint32_t)millis);
}
void sleep(void);
void sleep(uint32_t millis);
void sleep(int millis) {
sleep((uint32_t)millis);
}
void deepSleep(void);
void deepSleep(uint32_t millis);
void deepSleep(int millis) {
deepSleep((uint32_t)millis);
}
void attachInterruptWakeup(uint32_t pin, voidFuncPtr callback, uint32_t mode);
#ifdef BOARD_HAS_COMPANION_CHIP
void companionLowPowerCallback(onOffFuncPtr callback) {
companionSleepCB = callback;
}
void companionSleep() {
companionSleepCB(true);
}
void companionWakeup() {
companionSleepCB(false);
}
#endif
#ifdef ARDUINO_ARCH_NRF52
void enableWakeupFrom(wakeup_reason peripheral, uint32_t pin = 0xFF, uint32_t event = 0xFF, uint32_t option = 0xFF);
wakeup_reason wakeupReason();
#endif
private:
void setAlarmIn(uint32_t millis);
#ifdef ARDUINO_ARCH_SAMD
RTCZero rtc;
#endif
#ifdef BOARD_HAS_COMPANION_CHIP
void (*companionSleepCB)(bool);
#endif
};
extern ArduinoLowPowerClass LowPower;
#endif
/*
ArduinoLowPower class for nRF52.
Written by Chiara Ruggeri (chiara@arduino.org)
Copyright (c) 2017 Arduino AG. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if defined(ARDUINO_ARCH_NRF52)
#include "ArduinoLowPower.h"
#include "WInterrupts.h"
#include "nrf_rtc.h"
volatile bool event = false;
void (*functionPointer)(void);
nrf_lpcomp_input_t aPin[]={NRF_LPCOMP_INPUT_1, NRF_LPCOMP_INPUT_2, NRF_LPCOMP_INPUT_4, NRF_LPCOMP_INPUT_5, NRF_LPCOMP_INPUT_6, NRF_LPCOMP_INPUT_7};
void wakeUpGpio(){
event = true;
if(functionPointer)
functionPointer();
}
void ArduinoLowPowerClass::idle() {
// nRF52 has just two low power modes. Call sleep if idle is called.
sleep();
}
void ArduinoLowPowerClass::idle(uint32_t millis) {
setAlarmIn(millis);
idle();
}
void ArduinoLowPowerClass::sleep() {
sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
event=false;
while(!event){
sd_app_evt_wait();
}
}
void ArduinoLowPowerClass::sleep(uint32_t millis) {
setAlarmIn(millis);
sleep();
}
void ArduinoLowPowerClass::deepSleep() {
//Enter in systemOff mode only when no EasyDMA transfer is active
//this is achieved by disabling all peripheral that use it
NRF_UARTE0->ENABLE = UARTE_ENABLE_ENABLE_Disabled; //disable UART
NRF_SAADC ->ENABLE = (SAADC_ENABLE_ENABLE_Disabled << SAADC_ENABLE_ENABLE_Pos); //disable ADC
NRF_PWM0 ->ENABLE = (PWM_ENABLE_ENABLE_Disabled << PWM_ENABLE_ENABLE_Pos); //disable all pwm instance
NRF_PWM1 ->ENABLE = (PWM_ENABLE_ENABLE_Disabled << PWM_ENABLE_ENABLE_Pos);
NRF_PWM2 ->ENABLE = (PWM_ENABLE_ENABLE_Disabled << PWM_ENABLE_ENABLE_Pos);
NRF_TWIM1 ->ENABLE = (TWIM_ENABLE_ENABLE_Disabled << TWIM_ENABLE_ENABLE_Pos); //disable TWI Master
NRF_TWIS1 ->ENABLE = (TWIS_ENABLE_ENABLE_Disabled << TWIS_ENABLE_ENABLE_Pos); //disable TWI Slave
//Enter in System OFF mode
sd_power_system_off();
/*Only for debugging purpose, will not be reached without connected debugger*/
while(1);
}
void ArduinoLowPowerClass::setAlarmIn(uint32_t millis) {
nrf_rtc_prescaler_set(NRF_RTC1, 32);
//enable interrupt
NVIC_SetPriority(RTC1_IRQn, 2); //high priority
NVIC_ClearPendingIRQ(RTC1_IRQn);
NVIC_EnableIRQ(RTC1_IRQn);
nrf_rtc_event_clear(NRF_RTC1, NRF_RTC_EVENT_COMPARE_0);
nrf_rtc_int_enable(NRF_RTC1, NRF_RTC_INT_COMPARE0_MASK);
//Tick every 1 ms
nrf_rtc_cc_set(NRF_RTC1, 0, millis);
//start RTC
nrf_rtc_task_trigger(NRF_RTC1, NRF_RTC_TASK_START);
}
void ArduinoLowPowerClass::attachInterruptWakeup(uint32_t pin, voidFuncPtr callback, uint32_t mode) {
functionPointer = callback;
if(pin == RTC_ALARM_WAKEUP)
return;
pinMode(pin, INPUT_PULLUP);
attachInterrupt(pin, wakeUpGpio, mode);
}
void ArduinoLowPowerClass::enableWakeupFrom(wakeup_reason peripheral, uint32_t pin, uint32_t event, uint32_t option){
if(peripheral == NFC_WAKEUP){
NRF_NFCT->TASKS_SENSE=1;
return;
}
if(peripheral == ANALOG_COMPARATOR_WAKEUP){
detect_mode mode;
if(option == DOWN)
mode = DOWN;
else if(option == UP)
mode = UP;
else
mode = CROSS;
nrf_lpcomp_config_t config={(nrf_lpcomp_ref_t)event, (nrf_lpcomp_detect_t)mode};
nrf_lpcomp_configure(&config);
if(pin<14 && pin>19)
return; //no analog pin is choosen
nrf_lpcomp_input_select(aPin[pin-14]);
nrf_lpcomp_enable();
nrf_lpcomp_task_trigger(NRF_LPCOMP_TASK_START);
while(!nrf_lpcomp_event_check(NRF_LPCOMP_EVENT_READY));
return;
}
if(peripheral == GPIO_WAKEUP){
if(pin > 20)// allow wake up only from digital and analog pins
return;
if(event==LOW)
nrf_gpio_cfg_sense_input(g_APinDescription[pin].ulPin, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
else
nrf_gpio_cfg_sense_input(g_APinDescription[pin].ulPin, NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_SENSE_HIGH);
}
}
wakeup_reason ArduinoLowPowerClass::wakeupReason(){
uint32_t guilty;
sd_power_reset_reason_get(&guilty);
if(guilty & 0x10000){ // GPIO
//RESETREAS is a cumulative register. We need to clear it by writing 1 in the relative field
sd_power_reset_reason_clr(1 << 16);
return GPIO_WAKEUP;
}
if(guilty & 0x80000){ //NFC
sd_power_reset_reason_clr(1 << 19);
return NFC_WAKEUP;
}
if(guilty & 0x20000){ //COMP
sd_power_reset_reason_clr(1 << 17);
return ANALOG_COMPARATOR_WAKEUP;
}
return OTHER_WAKEUP;
}
ArduinoLowPowerClass LowPower;
#ifdef __cplusplus
extern "C"{
#endif
void RTC1_IRQHandler(void)
{
event=true;
nrf_rtc_event_clear(NRF_RTC1, NRF_RTC_EVENT_COMPARE_0);
nrf_rtc_task_trigger(NRF_RTC1, NRF_RTC_TASK_CLEAR);
nrf_rtc_task_trigger(NRF_RTC1, NRF_RTC_TASK_STOP);
if(functionPointer)
functionPointer();
}
#ifdef __cplusplus
}
#endif
#endif // ARDUINO_ARCH_NRF52
\ No newline at end of file
#if defined(ARDUINO_ARCH_SAMD)
#include "ArduinoLowPower.h"
#include "WInterrupts.h"
void ArduinoLowPowerClass::idle() {
SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;
PM->SLEEP.reg = 2;
__DSB();
__WFI();
}
void ArduinoLowPowerClass::idle(uint32_t millis) {
setAlarmIn(millis);
idle();
}
void ArduinoLowPowerClass::sleep() {
bool restoreUSBDevice = false;
if (SerialUSB) {
USBDevice.standby();
} else {
USBDevice.detach();
restoreUSBDevice = true;
}
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
__DSB();
__WFI();
if (restoreUSBDevice) {
USBDevice.attach();
}
}
void ArduinoLowPowerClass::sleep(uint32_t millis) {
setAlarmIn(millis);
sleep();
}
void ArduinoLowPowerClass::deepSleep() {
sleep();
}
void ArduinoLowPowerClass::deepSleep(uint32_t millis) {
sleep(millis);
}
void ArduinoLowPowerClass::setAlarmIn(uint32_t millis) {
if (!rtc.isConfigured()) {
attachInterruptWakeup(RTC_ALARM_WAKEUP, NULL, 0);
}
uint32_t now = rtc.getEpoch();
rtc.setAlarmEpoch(now + millis/1000);
rtc.enableAlarm(rtc.MATCH_HHMMSS);
}
void ArduinoLowPowerClass::attachInterruptWakeup(uint32_t pin, voidFuncPtr callback, uint32_t mode) {
if (pin > PINS_COUNT) {
// check for external wakeup sources
// RTC library should call this API to enable the alarm subsystem
switch (pin) {
case RTC_ALARM_WAKEUP:
rtc.begin(false);
rtc.attachInterrupt(callback);
/*case UART_WAKEUP:*/
}
return;
}
EExt_Interrupts in = g_APinDescription[pin].ulExtInt;
if (in == NOT_AN_INTERRUPT || in == EXTERNAL_INT_NMI)
return;
//pinMode(pin, INPUT_PULLUP);
attachInterrupt(pin, callback, mode);
// enable EIC clock
GCLK->CLKCTRL.bit.CLKEN = 0; //disable GCLK module
while (GCLK->STATUS.bit.SYNCBUSY);
GCLK->CLKCTRL.reg = (uint16_t) (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK6 | GCLK_CLKCTRL_ID( GCM_EIC )) ; //EIC clock switched on GCLK6
while (GCLK->STATUS.bit.SYNCBUSY);
GCLK->GENCTRL.reg = (GCLK_GENCTRL_GENEN | GCLK_GENCTRL_SRC_OSCULP32K | GCLK_GENCTRL_ID(6)); //source for GCLK6 is OSCULP32K
while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY);
GCLK->GENCTRL.bit.RUNSTDBY = 1; //GCLK6 run standby
while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY);
// Enable wakeup capability on pin in case being used during sleep
EIC->WAKEUP.reg |= (1 << in);
/* Errata: Make sure that the Flash does not power all the way down
* when in sleep mode. */
NVMCTRL->CTRLB.bit.SLEEPPRM = NVMCTRL_CTRLB_SLEEPPRM_DISABLED_Val;
}
ArduinoLowPowerClass LowPower;
#endif // ARDUINO_ARCH_SAMD
\ No newline at end of file
This diff is collapsed.
......@@ -6,7 +6,7 @@
enum period_t
{
SLEEP_15MS,
SLEEP_30MS,
SLEEP_30MS,
SLEEP_60MS,
SLEEP_120MS,
SLEEP_250MS,
......@@ -119,49 +119,53 @@ class LowPowerClass
{
public:
#if defined (__AVR__)
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168__)
void idle(period_t period, adc_t adc, timer2_t timer2,
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168__) || defined (__AVR_ATmega168P__) || defined (__AVR_ATmega88__)
void idle(period_t period, adc_t adc, timer2_t timer2,
timer1_t timer1, timer0_t timer0, spi_t spi,
usart0_t usart0, twi_t twi);
#elif defined __AVR_ATmega644P__ || defined (__AVR_ATmega1284P__)
void idle(period_t period, adc_t adc, timer2_t timer2,
timer1_t timer1, timer0_t timer0, spi_t spi,
usart1_t usart1, usart0_t usart0, twi_t twi);
#elif defined __AVR_ATmega2560__
void idle(period_t period, adc_t adc, timer5_t timer5,
void idle(period_t period, adc_t adc, timer5_t timer5,
timer4_t timer4, timer3_t timer3, timer2_t timer2,
timer1_t timer1, timer0_t timer0, spi_t spi,
usart3_t usart3, usart2_t usart2, usart1_t usart1,
usart3_t usart3, usart2_t usart2, usart1_t usart1,
usart0_t usart0, twi_t twi);
#elif defined __AVR_ATmega256RFR2__
void idle(period_t period, adc_t adc, timer5_t timer5,
void idle(period_t period, adc_t adc, timer5_t timer5,
timer4_t timer4, timer3_t timer3, timer2_t timer2,
timer1_t timer1, timer0_t timer0, spi_t spi,
usart1_t usart1,
usart1_t usart1,
usart0_t usart0, twi_t twi);
#elif defined __AVR_ATmega32U4__
void idle(period_t period, adc_t adc, timer4_t timer4,
timer3_t timer3, timer1_t timer1, timer0_t timer0,
spi_t spi, usart1_t usart1, twi_t twi, usb_t usb);
#elif defined __AVR_ATmega32U4__
void idle(period_t period, adc_t adc, timer4_t timer4,
timer3_t timer3, timer1_t timer1, timer0_t timer0,
spi_t spi, usart1_t usart1, twi_t twi, usb_t usb);
#else
#error "Please ensure chosen MCU is either 168, 328P, 32U4, 2560 or 256RFR2."
#error "Please ensure chosen MCU is either 88, 168, 168P, 328P, 32U4, 2560 or 256RFR2."
#endif
void adcNoiseReduction(period_t period, adc_t adc, timer2_t timer2) __attribute__((optimize("-O1")));
void powerDown(period_t period, adc_t adc, bod_t bod) __attribute__((optimize("-O1")));
void powerSave(period_t period, adc_t adc, bod_t bod, timer2_t timer2) __attribute__((optimize("-O1")));
void powerStandby(period_t period, adc_t adc, bod_t bod) __attribute__((optimize("-O1")));
void powerExtStandby(period_t period, adc_t adc, bod_t bod, timer2_t timer2) __attribute__((optimize("-O1")));
#elif defined (__arm__)