diff --git a/boards/atmega256rfr2-xpro/Makefile b/boards/atmega256rfr2-xpro/Makefile new file mode 100644 index 0000000000..3134740b39 --- /dev/null +++ b/boards/atmega256rfr2-xpro/Makefile @@ -0,0 +1,5 @@ +MODULE = board + +DIRS = $(RIOTBOARD)/common/atmega + +include $(RIOTBASE)/Makefile.base diff --git a/boards/atmega256rfr2-xpro/Makefile.dep b/boards/atmega256rfr2-xpro/Makefile.dep new file mode 100644 index 0000000000..5fbb1fda53 --- /dev/null +++ b/boards/atmega256rfr2-xpro/Makefile.dep @@ -0,0 +1,7 @@ +USEMODULE += boards_common_atmega + +ifneq (,$(filter saul_default,$(USEMODULE))) + # I2C sensor available at address 0x4B + USEMODULE += at30tse75x + USEMODULE += saul_gpio +endif diff --git a/boards/atmega256rfr2-xpro/Makefile.features b/boards/atmega256rfr2-xpro/Makefile.features new file mode 100644 index 0000000000..d74e7bdea9 --- /dev/null +++ b/boards/atmega256rfr2-xpro/Makefile.features @@ -0,0 +1,7 @@ +CPU = atmega256rfr2 + +FEATURES_PROVIDED += periph_adc +FEATURES_PROVIDED += periph_i2c +FEATURES_PROVIDED += periph_spi +FEATURES_PROVIDED += periph_timer +FEATURES_PROVIDED += periph_uart diff --git a/boards/atmega256rfr2-xpro/Makefile.include b/boards/atmega256rfr2-xpro/Makefile.include new file mode 100644 index 0000000000..3f55b658d4 --- /dev/null +++ b/boards/atmega256rfr2-xpro/Makefile.include @@ -0,0 +1,16 @@ +# configure the terminal program +PORT_LINUX ?= /dev/ttyACM0 +PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) +BAUD ?= 9600 +include $(RIOTMAKE)/tools/serial.inc.mk + +# Use EDBG (xplainedpro) programmer with avrdude +PROGRAMMER ?= xplainedpro + +# This board can be reset via avrdude +RESET ?= avrdude -c $(PROGRAMMER) -p m256rfr2 +# Use edbg interface for debugging +DEBUGSERVER_INTERFACE ?= --edbg + +include $(RIOTMAKE)/tools/avrdude.inc.mk +include $(RIOTBOARD)/common/atmega/Makefile.include diff --git a/boards/atmega256rfr2-xpro/dist/debug.sh b/boards/atmega256rfr2-xpro/dist/debug.sh new file mode 100755 index 0000000000..d1fb3d67ea --- /dev/null +++ b/boards/atmega256rfr2-xpro/dist/debug.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# The setsid command is needed so that Ctrl+C in GDB doesn't kill avarice +: ${SETSID:=setsid} + +sleep 2 +${SETSID} -w avarice $1 & +sleep 3 && avr-gdb -ex "target remote localhost:$3" $4 + +# avarice exits with 1 if the connection is released, therefore we always exit with 0 +exit 0 diff --git a/boards/atmega256rfr2-xpro/dist/debug_srv.sh b/boards/atmega256rfr2-xpro/dist/debug_srv.sh new file mode 100755 index 0000000000..8e7de053ab --- /dev/null +++ b/boards/atmega256rfr2-xpro/dist/debug_srv.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +sleep 2 +avarice $1 + +# avarice exits with 1 if the connection is released, therefore we always exit with 0 +exit 0 diff --git a/boards/atmega256rfr2-xpro/dist/gdb.conf b/boards/atmega256rfr2-xpro/dist/gdb.conf new file mode 100644 index 0000000000..ca68eb344c --- /dev/null +++ b/boards/atmega256rfr2-xpro/dist/gdb.conf @@ -0,0 +1 @@ +set $pc=0x00 diff --git a/boards/atmega256rfr2-xpro/doc.txt b/boards/atmega256rfr2-xpro/doc.txt new file mode 100644 index 0000000000..1c7d677cad --- /dev/null +++ b/boards/atmega256rfr2-xpro/doc.txt @@ -0,0 +1,29 @@ +/** +@defgroup boards_atmega256rfr2-xpro Atmega256RFR2 Xplained Pro +@ingroup boards +@brief Support for the Atmega256RFR2 Xplained Pro board + +### General information + +The [Atmega256RFR2 Xplained Pro](https://www.microchip.com/DevelopmentTools/ProductDetails/ATMEGA256RFR2-XPRO) +is an evaluation kit by Microchip for their ATmega256RFR2 microcontroller. + +### Flash the board + +You can flash the board using the on-board EDBG programmer via JTAG. Avrdude has +support for programming an AVR via EDBG with its xplainedpro programmer: + +``` +make BOARD=atmega256rfr2-xpro -C examples/hello-world flash +``` + +### Accessing STDIO via UART + +STDIO can be accessed through the USB connector. The on-board UART-USB +adapter is not affected by flashing. It shows up as /dev/ttyACM0 on Linux. +It will be used automatically with `make term`: +``` +make BOARD=atmega256rfr2-xpro -C examples/hello-world term +``` + +*/ diff --git a/boards/atmega256rfr2-xpro/include/board.h b/boards/atmega256rfr2-xpro/include/board.h new file mode 100644 index 0000000000..327958937e --- /dev/null +++ b/boards/atmega256rfr2-xpro/include/board.h @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2019 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup boards_atmega256rfr2-xpro + * @{ + * + * @file + * @brief Board specific definitions for the Atmega256RFR2 Xplained Pro + * + * @author Alexandre Abadie + */ + +#ifndef BOARD_H +#define BOARD_H + +#include "cpu.h" +#include "periph/gpio.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name STDIO configuration + * + * As the CPU is too slow to handle 115200 baud, we set the default + * baudrate to 9600 for this board + * @{ + */ +#define STDIO_UART_BAUDRATE (9600U) +/** @} */ + +/** + * @brief Use the UART 1 for STDIO on this board + */ +#define STDIO_UART_DEV (UART_DEV(1)) + +/** + * @name xtimer configuration values + * + * Xtimer runs at 8MHz / 64 = 125kHz + * @{ + */ +#define XTIMER_DEV (0) +#define XTIMER_CHAN (0) +#define XTIMER_WIDTH (16) +#define XTIMER_HZ (125000UL) +#define XTIMER_BACKOFF (40) +/** @} */ + +/** + * @name Macros for controlling the on-board LED + * @{ + */ +#define LED0_PIN GPIO_PIN(PORT_B, 4) +#define LED0_MODE GPIO_OUT +#define LED0_ENABLE_PORT DDRB |= LED0_PIN +#define LED0_ON PORTB |= LED0_PIN +#define LED0_OFF PORTB &= ~LED0_PIN +#define LED0_TOGGLE PORTB ^= LED0_PIN +/** @} */ + +/** + * @name Button pin configuration + * @{ + */ +#define BTN0_PIN GPIO_PIN(PORT_E, 4) +#define BTN0_MODE GPIO_IN_PU +/** @} */ + +/** + * @brief Initialize board specific hardware, including clock, LEDs and std-IO + */ +void board_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* BOARD_H */ +/** @} */ diff --git a/boards/atmega256rfr2-xpro/include/gpio_params.h b/boards/atmega256rfr2-xpro/include/gpio_params.h new file mode 100644 index 0000000000..3b6a97a33b --- /dev/null +++ b/boards/atmega256rfr2-xpro/include/gpio_params.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2019 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup boards_atmega256rfr2-xpro + * @{ + * + * @file + * @brief Configuration of SAUL mapped GPIO pins + * + * @author Alexandre Abadie + */ + +#ifndef GPIO_PARAMS_H +#define GPIO_PARAMS_H + +#include "board.h" +#include "saul/periph.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief GPIO configuration + */ +static const saul_gpio_params_t saul_gpio_params[] = +{ + { + .name = "BTN0 (SW0)", + .pin = BTN0_PIN, + .mode = BTN0_MODE, + .flags = SAUL_GPIO_INVERTED, + }, + { + .name = "LED0 (Yellow)", + .pin = LED0_PIN, + .mode = LED0_MODE, + .flags = (SAUL_GPIO_INVERTED | SAUL_GPIO_INIT_CLEAR), + }, +}; + +#ifdef __cplusplus +} +#endif + +#endif /* GPIO_PARAMS_H */ +/** @} */ diff --git a/boards/atmega256rfr2-xpro/include/periph_conf.h b/boards/atmega256rfr2-xpro/include/periph_conf.h new file mode 100644 index 0000000000..5c65b2290c --- /dev/null +++ b/boards/atmega256rfr2-xpro/include/periph_conf.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2019 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup boards_atmega256rfr2-xpro + * @{ + * + * @file + * @brief Peripheral MCU configuration for the Atmega256RFR2 Xplained Pro + * + * @author Alexandre Abadie + */ + +#ifndef PERIPH_CONF_H +#define PERIPH_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Clock configuration + * @{ + */ +#ifndef CLOCK_CORECLOCK +/* Using 8MHz internal oscillator as default clock source */ +#define CLOCK_CORECLOCK (8000000UL) +#endif +/** @} */ + +#ifdef __cplusplus +} +#endif + +#include "periph_conf_atmega_common.h" + +#endif /* PERIPH_CONF_H */ diff --git a/boards/atmega256rfr2-xpro/led_init.c b/boards/atmega256rfr2-xpro/led_init.c new file mode 100644 index 0000000000..f68937e951 --- /dev/null +++ b/boards/atmega256rfr2-xpro/led_init.c @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2019 Inria + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup boards_atmega256rfr2-xpro + * @{ + * + * @file + * @brief Board specific implementation for the Atmega256RFR2 Xplained Pro + * + * @author Alexandre Abadie + * + * @} + */ + +#include "board.h" + +void led_init(void) +{ + LED0_ENABLE_PORT; + LED0_OFF; +} diff --git a/examples/default/Makefile b/examples/default/Makefile index 528f80d563..fb5d2fb6f8 100644 --- a/examples/default/Makefile +++ b/examples/default/Makefile @@ -34,7 +34,7 @@ USEMODULE += ps # include and auto-initialize all available sensors USEMODULE += saul_default -BOARD_PROVIDES_NETIF := acd52832 airfy-beacon b-l072z-lrwan1 cc2538dk fox \ +BOARD_PROVIDES_NETIF := acd52832 airfy-beacon atmega256rfr2-xpro b-l072z-lrwan1 cc2538dk fox \ hamilton iotlab-m3 iotlab-a8-m3 lobaro-lorabox lsn50 mulle microbit msba2 \ microduino-corerf native nrf51dk nrf51dongle nrf52dk nrf52840dk nrf52840-mdk nrf6310 \ nucleo-f767zi openmote-b openmote-cc2538 pba-d-01-kw2x remote-pa remote-reva \ diff --git a/makefiles/tools/avrdude.inc.mk b/makefiles/tools/avrdude.inc.mk index cac9aeeac4..3a218889aa 100644 --- a/makefiles/tools/avrdude.inc.mk +++ b/makefiles/tools/avrdude.inc.mk @@ -2,7 +2,8 @@ FLASHER = avrdude DIST_PATH = $(RIOTBOARD)/$(BOARD)/dist DEBUGSERVER_PORT = 4242 DEBUGSERVER = $(DIST_PATH)/debug_srv.sh -DEBUGSERVER_FLAGS = "-g -j usb :$(DEBUGSERVER_PORT)" +DEBUGSERVER_INTERFACE ?= +DEBUGSERVER_FLAGS = "-g -j usb $(DEBUGSERVER_INTERFACE) :$(DEBUGSERVER_PORT)" DEBUGGER_FLAGS = "-x $(RIOTBOARD)/$(BOARD)/dist/gdb.conf $(ELFFILE)" DEBUGGER = $(DIST_PATH)/debug.sh $(DEBUGSERVER_FLAGS) $(DIST_PATH) $(DEBUGSERVER_PORT) diff --git a/tests/libfixmath_unittests/Makefile b/tests/libfixmath_unittests/Makefile index d7670a148d..cda7ef5588 100644 --- a/tests/libfixmath_unittests/Makefile +++ b/tests/libfixmath_unittests/Makefile @@ -2,7 +2,8 @@ include ../Makefile.tests_common BOARD_BLACKLIST := arduino-duemilanove arduino-leonardo \ arduino-mega2560 arduino-nano arduino-uno \ - atmega328p mega-xplained microduino-corerf waspmote-pro + atmega328p atmega256rfr2-xpro mega-xplained \ + microduino-corerf waspmote-pro # arduino-mega2560: builds locally but breaks travis (possibly because of # differences in the toolchain) # The MSP boards don't feature round(), exp(), and log(), which are used in the unittests diff --git a/tests/pkg_libb2/Makefile.ci b/tests/pkg_libb2/Makefile.ci index 8746e758e2..898f99323e 100644 --- a/tests/pkg_libb2/Makefile.ci +++ b/tests/pkg_libb2/Makefile.ci @@ -3,6 +3,7 @@ BOARD_INSUFFICIENT_MEMORY := \ arduino-leonardo \ arduino-nano \ arduino-uno \ + atmega256rfr2-xpro \ atmega328p \ chronos \ mega-xplained \ diff --git a/tests/pkg_relic/Makefile b/tests/pkg_relic/Makefile index 726e3e0a92..0d13d8887e 100644 --- a/tests/pkg_relic/Makefile +++ b/tests/pkg_relic/Makefile @@ -6,6 +6,7 @@ BOARD_BLACKLIST := arduino-duemilanove \ arduino-mega2560 \ arduino-nano \ arduino-uno \ + atmega256rfr2-xpro \ atmega328p \ chronos \ f4vi1 \ diff --git a/tests/pkg_tweetnacl/Makefile.ci b/tests/pkg_tweetnacl/Makefile.ci index 90279652a7..ee2dd63316 100644 --- a/tests/pkg_tweetnacl/Makefile.ci +++ b/tests/pkg_tweetnacl/Makefile.ci @@ -4,6 +4,7 @@ BOARD_INSUFFICIENT_MEMORY := \ arduino-mega2560 \ arduino-nano \ arduino-uno \ + atmega256rfr2-xpro \ atmega328p \ mega-xplained \ microduino-corerf \ diff --git a/tests/pthread_cooperation/Makefile.ci b/tests/pthread_cooperation/Makefile.ci index e032327134..0ec3ff3842 100644 --- a/tests/pthread_cooperation/Makefile.ci +++ b/tests/pthread_cooperation/Makefile.ci @@ -4,6 +4,7 @@ BOARD_INSUFFICIENT_MEMORY := \ arduino-mega2560 \ arduino-nano \ arduino-uno \ + atmega256rfr2-xpro \ atmega328p \ hifive1 \ hifive1b \ diff --git a/tests/sys_crypto/Makefile b/tests/sys_crypto/Makefile index f679a834db..75616a82cc 100644 --- a/tests/sys_crypto/Makefile +++ b/tests/sys_crypto/Makefile @@ -6,6 +6,7 @@ BOARD_BLACKLIST += arduino-leonardo BOARD_BLACKLIST += arduino-mega2560 BOARD_BLACKLIST += arduino-nano BOARD_BLACKLIST += arduino-uno +BOARD_BLACKLIST += atmega256rfr2-xpro BOARD_BLACKLIST += atmega328p BOARD_BLACKLIST += chronos BOARD_BLACKLIST += mega-xplained diff --git a/tests/unittests/Makefile.ci b/tests/unittests/Makefile.ci index 20d478fe33..d2e0dc0391 100644 --- a/tests/unittests/Makefile.ci +++ b/tests/unittests/Makefile.ci @@ -9,6 +9,7 @@ BOARD_INSUFFICIENT_MEMORY := \ arduino-mkrzero \ arduino-nano \ arduino-uno \ + atmega256rfr2-xpro \ atmega328p \ arduino-zero \ b-l072z-lrwan1 \