From 4751892ce970c9e8b53bb56fda26d25cfd50af6f Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Mon, 4 Nov 2019 14:00:56 +0100 Subject: [PATCH] boards/atmega256rfr2-xpro: initial support --- boards/atmega256rfr2-xpro/Makefile | 5 ++ boards/atmega256rfr2-xpro/Makefile.dep | 7 ++ boards/atmega256rfr2-xpro/Makefile.features | 7 ++ boards/atmega256rfr2-xpro/Makefile.include | 14 +++ boards/atmega256rfr2-xpro/doc.txt | 29 +++++++ boards/atmega256rfr2-xpro/include/board.h | 87 +++++++++++++++++++ .../atmega256rfr2-xpro/include/gpio_params.h | 53 +++++++++++ .../atmega256rfr2-xpro/include/periph_conf.h | 42 +++++++++ boards/atmega256rfr2-xpro/led_init.c | 27 ++++++ 9 files changed, 271 insertions(+) create mode 100644 boards/atmega256rfr2-xpro/Makefile create mode 100644 boards/atmega256rfr2-xpro/Makefile.dep create mode 100644 boards/atmega256rfr2-xpro/Makefile.features create mode 100644 boards/atmega256rfr2-xpro/Makefile.include create mode 100644 boards/atmega256rfr2-xpro/doc.txt create mode 100644 boards/atmega256rfr2-xpro/include/board.h create mode 100644 boards/atmega256rfr2-xpro/include/gpio_params.h create mode 100644 boards/atmega256rfr2-xpro/include/periph_conf.h create mode 100644 boards/atmega256rfr2-xpro/led_init.c 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..ae118a9a52 --- /dev/null +++ b/boards/atmega256rfr2-xpro/Makefile.include @@ -0,0 +1,14 @@ +# 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 + +include $(RIOTMAKE)/tools/avrdude.inc.mk +include $(RIOTBOARD)/common/atmega/Makefile.include 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; +}