From 2cd918a07a11f6b20ebde845bf3d57aa0e483d16 Mon Sep 17 00:00:00 2001 From: Laurent Navet Date: Thu, 30 Jun 2016 22:35:58 +0200 Subject: [PATCH] atmega_common: abstract Power Reduction Register PR Register is PRR0 on atmega2560 and atmega1281 but PRR on atmega328p. this abstracts as atmega Power Reduction Register as MEGA_PRR. --- boards/arduino-mega2560/include/periph_conf.h | 1 + boards/waspmote-pro/include/periph_conf.h | 1 + cpu/atmega_common/periph/gpio.c | 2 ++ cpu/atmega_common/periph/spi.c | 2 +- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/boards/arduino-mega2560/include/periph_conf.h b/boards/arduino-mega2560/include/periph_conf.h index a1c93857c6..a835e09c38 100644 --- a/boards/arduino-mega2560/include/periph_conf.h +++ b/boards/arduino-mega2560/include/periph_conf.h @@ -97,6 +97,7 @@ extern "C" { */ #define SPI_NUMOF 1 /* set to 0 to disable SPI */ #define SPI_0_EN 1 /* remove once SPI rework is done */ +#define MEGA_PRR PRR0 /* Power Reduction Register is PRR0 */ /** @} */ #ifdef __cplusplus diff --git a/boards/waspmote-pro/include/periph_conf.h b/boards/waspmote-pro/include/periph_conf.h index 6f9ca6d74f..22f7231fca 100644 --- a/boards/waspmote-pro/include/periph_conf.h +++ b/boards/waspmote-pro/include/periph_conf.h @@ -104,6 +104,7 @@ extern "C" { */ #define SPI_NUMOF 1 /* set to 0 to disable SPI */ #define SPI_0_EN 1 /* remove once SPI rework is done */ +#define MEGA_PRR PRR0 /* Power Reduction Resgister */ /** @} */ #ifdef __cplusplus diff --git a/cpu/atmega_common/periph/gpio.c b/cpu/atmega_common/periph/gpio.c index 36bf5b1fbf..cf76b88102 100644 --- a/cpu/atmega_common/periph/gpio.c +++ b/cpu/atmega_common/periph/gpio.c @@ -133,7 +133,9 @@ int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, uint8_t pin_num = _pin_num(pin); if ((_port_num(pin) == PORT_D && pin_num > 3) +#if defined (PORTE) || (_port_num(pin) == PORT_E && pin_num < 4) +#endif || ((mode != GPIO_IN) && (mode != GPIO_IN_PU))) { return -1; } diff --git a/cpu/atmega_common/periph/spi.c b/cpu/atmega_common/periph/spi.c index 5de8de222a..7d1338ae6e 100644 --- a/cpu/atmega_common/periph/spi.c +++ b/cpu/atmega_common/periph/spi.c @@ -61,7 +61,7 @@ int spi_init_master(spi_t dev, spi_conf_t conf, spi_speed_t speed) DDRB |= ((1 << DDB2) | (1 << DDB1) | (1 << DDB0)); /* make sure the SPI is not powered off */ - PRR0 &= ~(1 << PRSPI); + MEGA_PRR &= ~(1 << PRSPI); /* configure as master, with given mode and clock */ SPSR = (speed >> S2X_SHIFT);