From 85fcba0ce92caabd4e9a5e28c980c483f433a82e Mon Sep 17 00:00:00 2001 From: Gerson Fernando Budke Date: Mon, 11 Jan 2021 20:18:40 -0300 Subject: [PATCH] boards/common: Introduce Atmel xmega common Add atxmega common board definitions. This works is a port from @josar with few modifications. Signed-off-by: Gerson Fernando Budke --- boards/common/atxmega/Makefile | 3 + boards/common/atxmega/Makefile.features | 1 + boards/common/atxmega/Makefile.include | 38 +++++++ boards/common/atxmega/board.c | 38 +++++++ boards/common/atxmega/doc.txt | 5 + .../atxmega/include/periph_conf_common.h | 100 ++++++++++++++++++ 6 files changed, 185 insertions(+) create mode 100644 boards/common/atxmega/Makefile create mode 100644 boards/common/atxmega/Makefile.features create mode 100644 boards/common/atxmega/Makefile.include create mode 100644 boards/common/atxmega/board.c create mode 100644 boards/common/atxmega/doc.txt create mode 100644 boards/common/atxmega/include/periph_conf_common.h diff --git a/boards/common/atxmega/Makefile b/boards/common/atxmega/Makefile new file mode 100644 index 0000000000..ed318b9cf8 --- /dev/null +++ b/boards/common/atxmega/Makefile @@ -0,0 +1,3 @@ +MODULE = boards_common_atxmega + +include $(RIOTBASE)/Makefile.base diff --git a/boards/common/atxmega/Makefile.features b/boards/common/atxmega/Makefile.features new file mode 100644 index 0000000000..c0e6270d49 --- /dev/null +++ b/boards/common/atxmega/Makefile.features @@ -0,0 +1 @@ +CPU = atxmega diff --git a/boards/common/atxmega/Makefile.include b/boards/common/atxmega/Makefile.include new file mode 100644 index 0000000000..a6371859e2 --- /dev/null +++ b/boards/common/atxmega/Makefile.include @@ -0,0 +1,38 @@ +INCLUDES += -I$(RIOTBOARD)/common/atxmega/include + +# Use JTAG as default protocol for debugging +DEBUGPROTO ?= -x +FLASHFILE ?= $(ELFFILE) + +# Use avrdude programmer with Atmel ICE as default flash/debug system +PROGRAMMER ?= avrdude +AVRDUDE_PROGRAMMER ?= atmelice + +ifneq (,$(filter flash%,$(MAKECMDGOALS))) + FFLAGS_EXTRA ?= -e +endif + +# If avrdude specific programmer is not set, set it based on the bootloader used +ifeq (,$(AVRDUDE_PROGRAMMER)) + FLASHFILE ?= $(BINFILE) + + ifeq (stk500v2,$(BOOTLOADER)) + AVRDUDE_PROGRAMMER = stk500v2 + BOOTLOADER_SIZE ?= 4K + # Disable auto erase; erasing the flash is done implicitly by the bootloader + # and explicit erase is not supported + FFLAGS_EXTRA += -D + endif + + ifeq (avr109,$(BOOTLOADER)) + AVRDUDE_PROGRAMMER = avr109 + BOOTLOADER_SIZE ?= 4K + endif + + ifneq (,$(BOOTLOADER_BAUD)) + FFLAGS_EXTRA += -b $(BOOTLOADER_BAUD) + endif +endif + +BOOTLOADER_SIZE ?= 0 +ROM_RESERVED ?= $(BOOTLOADER_SIZE) diff --git a/boards/common/atxmega/board.c b/boards/common/atxmega/board.c new file mode 100644 index 0000000000..e2db598884 --- /dev/null +++ b/boards/common/atxmega/board.c @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2021 Gerson Fernando Budke + * + * 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_common + * @{ + * + * @file + * @brief Common implementations for ATxmega boards + * + * @author Gerson Fernando Budke + * + * @} + */ + +#include "board.h" +#include "cpu.h" + +#ifdef LED_PORT +void __attribute__((weak)) led_init(void) +{ + LED_PORT.DIR = LED_PORT_MASK; + LED_PORT.OUT = LED_PORT_MASK; +} +#endif + +void __attribute__((weak)) board_init(void) +{ + cpu_init(); +#ifdef LED_PORT + led_init(); +#endif +} diff --git a/boards/common/atxmega/doc.txt b/boards/common/atxmega/doc.txt new file mode 100644 index 0000000000..73b19e8380 --- /dev/null +++ b/boards/common/atxmega/doc.txt @@ -0,0 +1,5 @@ +/** +@defgroup boards_common_atxmega ATxmega common +@ingroup boards +@brief Shared files and configuration for ATxmega-based boards + */ \ No newline at end of file diff --git a/boards/common/atxmega/include/periph_conf_common.h b/boards/common/atxmega/include/periph_conf_common.h new file mode 100644 index 0000000000..95f54717ea --- /dev/null +++ b/boards/common/atxmega/include/periph_conf_common.h @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2021 Gerson Fernando Budke + * + * 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_common_atxmega + * @{ + * + * @file + * @brief Common configuration of MCU periphery for ATxmega boards + * + * @author Gerson Fernando Budke + */ + +#ifndef PERIPH_CONF_COMMON_H +#define PERIPH_CONF_COMMON_H + +#include "periph_cpu.h" +#include "macros/units.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Clock configuration + * @{ + */ +#ifndef CLOCK_CORECLOCK +#define CLOCK_CORECLOCK MHZ(32) +#endif /* CLOCK_CORECLOCK */ +/** @} */ + +/** + * @name ADC Configuration + * + * @{ + */ +#ifndef ADC_NUMOF +#define ADC_NUMOF (0U) +#endif /* ADC_NUMOF */ +/** @} */ + +/** + * @name I2C configuration + * @{ + */ +#ifndef I2C_NUMOF +#define I2C_NUMOF (0U) +#endif /* I2C_NUMOF */ +/** @} */ + +/** + * @name PWM configuration + * + * @{ + */ +#ifndef PWM_NUMOF +#define PWM_NUMOF (0U) +#endif /* PWM_NUMOF */ +/** @} */ + +/** + * @name SPI configuration + * + * The SS pin must be configured as output for the SPI device to work as + * master correctly, though we do not use it for now (as we handle the chip + * select externally for now) + * + * @{ + */ +#ifndef SPI_NUMOF +#define SPI_NUMOF (0U) +#endif /* SPI_NUMOF */ +/** @} */ + +/** + * @name UART configuration + * + * The UART devices have fixed pin mappings, so all we need to do, is to specify + * which devices we would like to use and their corresponding RX interrupts. See + * the reference manual for the fixed pin mapping. + * + * @{ + */ +#ifndef UART_NUMOF +#define UART_NUMOF (0U) +#endif /* UART_NUMOF */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* PERIPH_CONF_COMMON_H */ +/** @} */