Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for m328pb and m168pb #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions LowPower.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* LowPower Library
* Version: 1.80
* Version: 1.90
* Date: 04-10-2018
* Author: Lim Phang Moh
* Company: Rocket Scream Electronics
Expand All @@ -13,6 +13,7 @@
*
* Revision Description
* ======== ===========
* 1.90 Added support for ATmega328PB and ATmega168PB.
* 1.80 Added support for ATmega88 and ATmega168P. PowerExtStandby()
* modified because not supported on Atmega88 / Atmega168
* Contributed by mrguen.
Expand Down Expand Up @@ -48,7 +49,7 @@

#if defined (__AVR__)
// Only Pico Power devices can change BOD settings through software
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168P__)
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168P__) || defined (__AVR_ATmega328PB__) || defined (__AVR_ATmega168PB__)
#ifndef sleep_bod_disable
#define sleep_bod_disable() \
do { \
Expand Down Expand Up @@ -78,7 +79,7 @@ do { \
} while (0);

// Only Pico Power devices can change BOD settings through software
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168P__)
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168P__) || defined (__AVR_ATmega328PB__) || defined (__AVR_ATmega168PB__)
#define lowPowerBodOff(mode)\
do { \
set_sleep_mode(mode); \
Expand Down Expand Up @@ -159,7 +160,7 @@ do { \
* (b) TWI_ON - Leave TWI module in its default state
*
*******************************************************************************/
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168__) || defined (__AVR_ATmega168P__) || defined (__AVR_ATmega88__)
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168__) || defined (__AVR_ATmega168P__) || defined (__AVR_ATmega88__) || defined (__AVR_ATmega328PB__) || defined (__AVR_ATmega168PB__)
void LowPowerClass::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)
Expand Down Expand Up @@ -871,7 +872,7 @@ void LowPowerClass::powerDown(period_t period, adc_t adc, bod_t bod)
}
if (bod == BOD_OFF)
{
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168P__)
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168P__) || defined (__AVR_ATmega328PB__) || defined (__AVR_ATmega168PB__)
lowPowerBodOff(SLEEP_MODE_PWR_DOWN);
#else
lowPowerBodOn(SLEEP_MODE_PWR_DOWN);
Expand Down Expand Up @@ -958,7 +959,7 @@ void LowPowerClass::powerSave(period_t period, adc_t adc, bod_t bod,

if (bod == BOD_OFF)
{
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168P__)
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168P__) || defined (__AVR_ATmega328PB__) || defined (__AVR_ATmega168PB__)
lowPowerBodOff(SLEEP_MODE_PWR_SAVE);
#else
lowPowerBodOn(SLEEP_MODE_PWR_SAVE);
Expand Down Expand Up @@ -1023,7 +1024,7 @@ void LowPowerClass::powerStandby(period_t period, adc_t adc, bod_t bod)

if (bod == BOD_OFF)
{
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168P__)
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168P__) || defined (__AVR_ATmega328PB__) || defined (__AVR_ATmega168PB__)
lowPowerBodOff(SLEEP_MODE_STANDBY);
#else
lowPowerBodOn(SLEEP_MODE_STANDBY);
Expand Down Expand Up @@ -1106,7 +1107,7 @@ void LowPowerClass::powerExtStandby(period_t period, adc_t adc, bod_t bod,
#else
if (bod == BOD_OFF)
{
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168P__)
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168P__) || defined (__AVR_ATmega328PB__) || defined (__AVR_ATmega168PB__)
lowPowerBodOff(SLEEP_MODE_EXT_STANDBY);
#else
lowPowerBodOn(SLEEP_MODE_EXT_STANDBY);
Expand Down
4 changes: 2 additions & 2 deletions LowPower.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class LowPowerClass
public:
#if defined (__AVR__)

#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168__) || defined (__AVR_ATmega168P__) || defined (__AVR_ATmega88__)
#if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega328PB__) || defined (__AVR_ATmega168__) || defined (__AVR_ATmega168PB__) || 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);
Expand All @@ -145,7 +145,7 @@ class LowPowerClass
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 88, 168, 168P, 328P, 32U4, 2560 or 256RFR2."
#error "Please ensure chosen MCU is either 88, 168, 168P(B), 328P(B), 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")));
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
### Low-Power
Lightweight low power library for Arduino.

Version: 1.80
Version: 1.90

Date: 04-10-2018
Date: 05-01-2020

Devices Supported:
* ATMega88
* ATMega168
* ATMega168P
* ATMega328P
* ATMega168PB
* ATMega328PB
* ATMega32U4
* ATMega644P
* ATMega1284P
Expand Down