diff --git a/boards/arduino-common/Makefile b/boards/arduino-common/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..233ad5878bf695219b4758fc5d96847ea88415da --- /dev/null +++ b/boards/arduino-common/Makefile @@ -0,0 +1,3 @@ +MODULE = arduino-common + +include $(RIOTBASE)/Makefile.base diff --git a/boards/arduino-common/Makefile.features b/boards/arduino-common/Makefile.features new file mode 100644 index 0000000000000000000000000000000000000000..8131d940b21417109116d8b7af0b9593be92f616 --- /dev/null +++ b/boards/arduino-common/Makefile.features @@ -0,0 +1,10 @@ +# Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_gpio +FEATURES_PROVIDED += periph_spi +FEATURES_PROVIDED += periph_timer +FEATURES_PROVIDED += periph_uart + +# Various other features (if any) + +# The board MPU family (used for grouping by the CI system) +FEATURES_MCU_GROUP = avr8 diff --git a/boards/arduino-common/Makefile.include b/boards/arduino-common/Makefile.include new file mode 100644 index 0000000000000000000000000000000000000000..3b357838c7d2e7eed3c9fa4a3197a480f98c2e9c --- /dev/null +++ b/boards/arduino-common/Makefile.include @@ -0,0 +1,44 @@ +# define the cpu used by the arduino uno and duemilanove boards +export CPU = atmega328p + +#Ā define port used to flash the board +OS = $(shell uname) +ifeq ($(OS),Linux) + PORT = $(LINUX_PORT) +else ifeq ($(OS),Darwin) + PORT ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) +else + $(info CAUTION: No flash tool for your host system found!) + # TODO: fix for building under windows +endif + +export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm +export TERMFLAGS = -b 9600 -p $(PORT) +export FLASHER = avrdude +export PORT +export DIST_PATH = $(RIOTBOARD)/$(BOARD)/dist +export DEBUGSERVER_PORT = 4242 +export DEBUGSERVER = $(DIST_PATH)/debug_srv.sh +export DEBUGSERVER_FLAGS = "-g -j usb :$(DEBUGSERVER_PORT)" +export DEBUGGER_FLAGS = "-x $(RIOTBOARD)/$(BOARD)/dist/gdb.conf $(ELFFILE)" +export DEBUGGER = $(DIST_PATH)/debug.sh $(DEBUGSERVER_FLAGS) $(DIST_PATH) $(DEBUGSERVER_PORT) + +# PROGRAMMER defaults to arduino which is the internal flasher via USB. Can be +# overridden for debugging (which requires changes that require to use an ISP) +export PROGRAMMER ?= arduino + +ifeq ($(PROGRAMMER), arduino) + export PROGRAMMER_FLAGS = -P $(PORT) -b $(PROGRAMMER_SPEED) +endif + +# define build specific options +export CFLAGS_CPU = -mmcu=atmega328p $(CFLAGS_FPU) +export CFLAGS_LINK = -ffunction-sections -fdata-sections -fno-builtin -fshort-enums +export CFLAGS_DBG = -ggdb -g3 +export CFLAGS_OPT ?= -Os + +export CFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT) +export ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) +export LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) -static -lgcc -e reset_handler +export OFLAGS += -j .text -j .data -O ihex +export FFLAGS += -p atmega328p -c $(PROGRAMMER) $(PROGRAMMER_FLAGS) -F -D -U flash:w:bin/$(BOARD)/$(PROJECT)$(APPLICATION).hex diff --git a/boards/arduino-common/board.c b/boards/arduino-common/board.c new file mode 100644 index 0000000000000000000000000000000000000000..abca37ac28cc72c6b5a1038ab547a3d2d09d14da --- /dev/null +++ b/boards/arduino-common/board.c @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2014 Freie UniversitƤt Berlin, Hinnerk van Bruinehsen + * 2015 Kaspar Schleiser <kaspar@schleiser.de> + * 2016 Laurent Navet <laurent.navet@gmail.com> + * + * 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_arduino-common + * @{ + * + * @file + * @brief Board specific implementations for the arduino Uno + * @brief and Duemilanove boards. + * + * @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de> + * @author Kaspar Schleiser <kaspar@schleiser.de> + * @author Laurent Navet <laurent.navet@gmail.com> + * + * @} + */ + +#include <stdio.h> +#include <avr/io.h> + +#include "board.h" +#include "cpu.h" +#include "uart_stdio.h" + +void led_init(void); +void SystemInit(void); +static int uart_putchar(char c, FILE *stream); +static int uart_getchar(FILE *stream); + +static FILE uart_stdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE); +static FILE uart_stdin = FDEV_SETUP_STREAM(NULL, uart_getchar, _FDEV_SETUP_READ); + +void board_init(void) +{ + /* initialize stdio via USART_0 */ + SystemInit(); + + /* initialize the CPU */ + cpu_init(); + + /* initialize the board LED (connected to pin PB5) */ + DDRB |= (1 << DDB5); + PORTB &= ~(1 << 5); + + irq_enable(); +} + +/** + * @brief Initialize the System, initialize IO via UART_0 + */ +void SystemInit(void) +{ + /* initialize UART_0 for use as stdout */ + uart_stdio_init(); + + stdout = &uart_stdout; + stdin = &uart_stdin; + + /* Flush stdout */ + puts("\f"); +} + +static int uart_putchar(char c, FILE *stream) +{ + (void) stream; + uart_stdio_write(&c, 1); + return 0; +} + +int uart_getchar(FILE *stream) +{ + (void) stream; + char c; + uart_stdio_read(&c, 1); + return (int)c; +} diff --git a/boards/arduino-common/dist/debug.sh b/boards/arduino-common/dist/debug.sh new file mode 100755 index 0000000000000000000000000000000000000000..0b10852f20c0dacf071b40d8a98ccce09e7722ac --- /dev/null +++ b/boards/arduino-common/dist/debug.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +sleep 2 +setsid -w avarice $1 & +#sleep 2 && $2/avr-gdb-wrapper -ex "target remote localhost:$3" $4 +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/arduino-common/dist/debug_srv.sh b/boards/arduino-common/dist/debug_srv.sh new file mode 100755 index 0000000000000000000000000000000000000000..8e7de053ab36eb5fa12252d3a8184fc7d89be82f --- /dev/null +++ b/boards/arduino-common/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/arduino-common/dist/gdb.conf b/boards/arduino-common/dist/gdb.conf new file mode 100644 index 0000000000000000000000000000000000000000..ca68eb344c3f4a9e6f7eeecd2331c36110ac4c10 --- /dev/null +++ b/boards/arduino-common/dist/gdb.conf @@ -0,0 +1 @@ +set $pc=0x00 diff --git a/boards/arduino-common/include/arduino_board.h b/boards/arduino-common/include/arduino_board.h new file mode 100644 index 0000000000000000000000000000000000000000..e589511d3679249d9b279e8af904a2a58530022f --- /dev/null +++ b/boards/arduino-common/include/arduino_board.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2016 Freie UniversitƤt Berlin + * + * 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_arduino-common + * @{ + * + * @file + * @brief Board specific configuration for the Arduino API + * + * @author Hauke Petersen <hauke.petersen@fu-berlin.de> + * @author Laurent Navet <laurent.navet@gmail.com> + */ + +#ifndef ARDUINO_BOARD_H +#define ARDUINO_BOARD_H + +#include "arduino_pinmap.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief The on-board LED is connected to pin 13 on this board + */ +#define ARDUINO_LED (13) + +/** + * @brief Look-up table for the Arduino's digital pins + */ +static const gpio_t arduino_pinmap[] = { + ARDUINO_PIN_0, + ARDUINO_PIN_1, + ARDUINO_PIN_2, + ARDUINO_PIN_3, + ARDUINO_PIN_4, + ARDUINO_PIN_5, + ARDUINO_PIN_6, + ARDUINO_PIN_7, + ARDUINO_PIN_8, + ARDUINO_PIN_9, + ARDUINO_PIN_10, + ARDUINO_PIN_11, + ARDUINO_PIN_12, + ARDUINO_PIN_13, + ARDUINO_PIN_14, + ARDUINO_PIN_15, + ARDUINO_PIN_16, + ARDUINO_PIN_17, + ARDUINO_PIN_18, + ARDUINO_PIN_19 +}; + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_BOARD_H */ +/** @} */ diff --git a/boards/arduino-common/include/arduino_pinmap.h b/boards/arduino-common/include/arduino_pinmap.h new file mode 100644 index 0000000000000000000000000000000000000000..67e40677140e83f4adbb278af0ff68f3b0ca919c --- /dev/null +++ b/boards/arduino-common/include/arduino_pinmap.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2015 Freie UniversitƤt Berlin + * 2016 Laurent Navet <laurent.navet@gmail.com> + * + * 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_arduino-common + * @{ + * + * @file + * @brief Mapping from MCU pins to Arduino pins + * + * You can use the defines in this file for simplified interaction with the + * Arduino specific pin numbers. + * + * @author Hauke Petersen <hauke.petersen@fu-berlin.de> + * @author Daniel Nordahl <nordahl.d@gmail.com> + * @author Laurent Navet <laurent.navet@gmail.com> + */ + +#ifndef ARDUINO_PINMAP_H +#define ARDUINO_PINMAP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Mapping of MCU pins to Arduino pins + * + * @note ISCP pins are not mapped. + */ + +/* Digital pins */ +#define ARDUINO_PIN_0 GPIO_PIN(PORT_D, 0) +#define ARDUINO_PIN_1 GPIO_PIN(PORT_D, 1) +#define ARDUINO_PIN_2 GPIO_PIN(PORT_D, 2) +#define ARDUINO_PIN_3 GPIO_PIN(PORT_D, 3) +#define ARDUINO_PIN_4 GPIO_PIN(PORT_D, 4) +#define ARDUINO_PIN_5 GPIO_PIN(PORT_D, 5) +#define ARDUINO_PIN_6 GPIO_PIN(PORT_D, 6) +#define ARDUINO_PIN_7 GPIO_PIN(PORT_D, 7) +#define ARDUINO_PIN_8 GPIO_PIN(PORT_B, 0) +#define ARDUINO_PIN_9 GPIO_PIN(PORT_B, 1) +#define ARDUINO_PIN_10 GPIO_PIN(PORT_B, 2) +#define ARDUINO_PIN_11 GPIO_PIN(PORT_B, 3) +#define ARDUINO_PIN_12 GPIO_PIN(PORT_B, 4) +#define ARDUINO_PIN_13 GPIO_PIN(PORT_B, 5) +/* Analog pins */ +#define ARDUINO_PIN_14 GPIO_PIN(PORT_C, 0) +#define ARDUINO_PIN_15 GPIO_PIN(PORT_C, 1) +#define ARDUINO_PIN_16 GPIO_PIN(PORT_C, 2) +#define ARDUINO_PIN_17 GPIO_PIN(PORT_C, 3) +#define ARDUINO_PIN_18 GPIO_PIN(PORT_C, 4) +#define ARDUINO_PIN_19 GPIO_PIN(PORT_C, 5) +/* Analog input */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +/** @ */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_PINMAP_H */ +/** @} */ diff --git a/boards/arduino-common/include/board.h b/boards/arduino-common/include/board.h new file mode 100644 index 0000000000000000000000000000000000000000..fe84d1d2863fcb582e551a44948717cc0dc89aca --- /dev/null +++ b/boards/arduino-common/include/board.h @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2014 Freie UniversitƤt Berlin, Hinnerk van Bruinehsen + * 2016 Laurent Navet <laurent.navet@gmail.com> + * + * 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. + */ + +/** + * @defgroup boards_arduino-common Arduino common + * @ingroup boards + * @brief Board specific files for the arduino Uno and + * @brief Duemilanove boards. + * @{ + * + * @file + * @brief Board specific definitions for the arduino Uno and + * @brief Duemilanove boards. + * + * @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de> + * @author Laurent Navet <laurent.navet@gmail.com> + */ + +#ifndef BOARD_H_ +#define BOARD_H_ + +#include "cpu.h" +#include "arduino_pinmap.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief As the CPU is too slow to handle 115200 baud, we set the default + * baudrate to 9600 for this board + * @{ + */ +#define UART_STDIO_BAUDRATE (9600U) +/** @} */ + +/** + * @brief LED pin definitions and handlers + * @{ + */ +#define LED0_PIN GPIO_PIN(1, 5) + +#define LED0_MASK (1 << DDB5) + +#define LED0_ON (PORTB |= LED0_MASK) +#define LED0_OFF (PORTB &= ~LED0_MASK) +#define LED0_TOGGLE (PORTB ^= LED0_MASK) +/** @} */ + +/** + ** Context swap defines + ** Setup to use PJ6 which is pin change interrupt 15 (PCINT15) + ** This emulates a software triggered interrupt + ***/ +#define AVR_CONTEXT_SWAP_INIT do { \ + DDRC |= (1 << PC6); \ + PCICR |= (1 << PCIE1); \ + PCMSK1 |= (1 << PCINT14); \ +} while (0) +#define AVR_CONTEXT_SWAP_INTERRUPT_VECT PCINT1_vect +#define AVR_CONTEXT_SWAP_TRIGGER PORTC ^= (1 << PC6) + + +/** + * @brief xtimer configuration values + * @{ + */ +#define XTIMER_WIDTH (16) +#define XTIMER_SHIFT (2) +#define XTIMER_BACKOFF (40) +/** @} */ + +/** + * @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/arduino-common/include/periph_conf.h b/boards/arduino-common/include/periph_conf.h new file mode 100644 index 0000000000000000000000000000000000000000..750fb69cdf42178dd5daf7ec226af914f7389385 --- /dev/null +++ b/boards/arduino-common/include/periph_conf.h @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2014 Freie UniversitƤt Berlin, Hinnerk van Bruinehsen + * 2016 Laurent Navet <laurent.navet@gmail.com> + * + * 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_arduino-common + * @{ + * + * @file + * @brief Peripheral MCU configuration for the arduino Uno and + * @brief Dumilanove boards. + * + * @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de> + * @author Laurent Navet <laurent.navet@gmail.com> + */ + +#ifndef PERIPH_CONF_H_ +#define PERIPH_CONF_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Clock configuration + * @{ + */ +#define CLOCK_CORECLOCK (16000000L) +/** @} */ + +/** + * @brief Timer configuration + * + * The timer driver only supports the 16-bit timer (Timer1) + * so this is the only one we can use here. + * + * @{ + */ +#define TIMER_NUMOF (2U) + +#define TIMER_0 MEGA_TIMER1 +#define TIMER_0_MASK &TIMSK1 +#define TIMER_0_FLAG &TIFR1 +#define TIMER_0_ISRA TIMER1_COMPA_vect +#define TIMER_0_ISRB TIMER1_COMPB_vect +/** @} */ + +/** + * @brief UART configuration + * + * Uno has only one UART, look in atmega_common + * This is where magic happens + * + * @{ + */ +#define UART_NUMOF (1U) + +#define UART_0 MEGA_UART0 +#define UART_0_ISR USART_RX_vect +/** @} */ + +/** + * @brief SPI configuration + * + * The atmega2560 has only one hardware SPI with fixed pin configuration, so all + * we can do here, is to enable or disable it... + * + * The fixed pins used, are: + * MOSI - PB3 (Arduino pin 11) + * MISO - PB4 (Arduino pin 12) + * SCK - PB5 (Arduino pin 13) + * SS - PB2 (Arduino pin 10) -> this pin is configured as output, but not used + * + * @{ + */ +#define SPI_NUMOF 1 /* set to 0 to disable SPI */ +#define SPI_0_EN 1 /* remove once SPI rework is done */ +#define MEGA_PRR PRR /* Power Reduction Register is PRR */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* PERIPH_CONF_H_ */ diff --git a/boards/arduino-duemilanove/Makefile b/boards/arduino-duemilanove/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..070aba9f1a0091cb63bcf628e5594bbd1a703618 --- /dev/null +++ b/boards/arduino-duemilanove/Makefile @@ -0,0 +1,5 @@ +MODULE = board + +DIRS = $(RIOTBOARD)/arduino-common + +include $(RIOTBASE)/Makefile.base diff --git a/boards/arduino-duemilanove/Makefile.features b/boards/arduino-duemilanove/Makefile.features new file mode 100644 index 0000000000000000000000000000000000000000..da28e25dba0175a52f37eae3d32c83ee76bccd58 --- /dev/null +++ b/boards/arduino-duemilanove/Makefile.features @@ -0,0 +1 @@ +include $(RIOTBOARD)/arduino-common/Makefile.features diff --git a/boards/arduino-duemilanove/Makefile.include b/boards/arduino-duemilanove/Makefile.include new file mode 100644 index 0000000000000000000000000000000000000000..e8e3236dbc0642c7fdbd0d9afd6d3080e33b090e --- /dev/null +++ b/boards/arduino-duemilanove/Makefile.include @@ -0,0 +1,10 @@ +USEMODULE += arduino-common + +# add arduino-common include path +INCLUDES += -I$(RIOTBOARD)/arduino-common/include + +#export needed for flash rule +export LINUX_PORT = /dev/ttyUSB0 +export PROGRAMMER_SPEED = 57600 + +include $(RIOTBOARD)/arduino-common/Makefile.include diff --git a/boards/arduino-uno/Makefile b/boards/arduino-uno/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..070aba9f1a0091cb63bcf628e5594bbd1a703618 --- /dev/null +++ b/boards/arduino-uno/Makefile @@ -0,0 +1,5 @@ +MODULE = board + +DIRS = $(RIOTBOARD)/arduino-common + +include $(RIOTBASE)/Makefile.base diff --git a/boards/arduino-uno/Makefile.features b/boards/arduino-uno/Makefile.features new file mode 100644 index 0000000000000000000000000000000000000000..da28e25dba0175a52f37eae3d32c83ee76bccd58 --- /dev/null +++ b/boards/arduino-uno/Makefile.features @@ -0,0 +1 @@ +include $(RIOTBOARD)/arduino-common/Makefile.features diff --git a/boards/arduino-uno/Makefile.include b/boards/arduino-uno/Makefile.include new file mode 100644 index 0000000000000000000000000000000000000000..f2d017c519a56dfb255c2bce9de8c9dee2a67cb7 --- /dev/null +++ b/boards/arduino-uno/Makefile.include @@ -0,0 +1,10 @@ +USEMODULE += arduino-common + +# add arduino-common include path +INCLUDES += -I$(RIOTBOARD)/arduino-common/include + +# export needed for flash rule +export LINUX_PORT = /dev/ttyACM0 +export PROGRAMMER_SPEED = 115200 + +include $(RIOTBOARD)/arduino-common/Makefile.include diff --git a/cpu/atmega328p/Makefile b/cpu/atmega328p/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..81f110b68d093c93e2626885a5e8ba9af9b229fc --- /dev/null +++ b/cpu/atmega328p/Makefile @@ -0,0 +1,6 @@ +# define the module that is build +MODULE = cpu +# add a list of subdirectories, that should also be build +DIRS = $(ATMEGA_COMMON) + +include $(RIOTBASE)/Makefile.base diff --git a/cpu/atmega328p/Makefile.include b/cpu/atmega328p/Makefile.include new file mode 100644 index 0000000000000000000000000000000000000000..a952b7caeff17fef7a5eb622688eed8e5294cadd --- /dev/null +++ b/cpu/atmega328p/Makefile.include @@ -0,0 +1,11 @@ +# this CPU implementation is using the new core/CPU interface +export CFLAGS += -DCOREIF_NG=1 + +# tell the build system that the CPU depends on the atmega common files +USEMODULE += atmega_common + +# define path to atmega common module, which is needed for this CPU +export ATMEGA_COMMON = $(RIOTCPU)/atmega_common/ + +# CPU depends on the atmega common module, so include it +include $(ATMEGA_COMMON)Makefile.include diff --git a/cpu/atmega328p/cpu.c b/cpu/atmega328p/cpu.c new file mode 100644 index 0000000000000000000000000000000000000000..3de168ab4f3610d5ec88d3b68b057085d93ba9a5 --- /dev/null +++ b/cpu/atmega328p/cpu.c @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2014 Freie UniversitƤt Berlin, Hinnerk van Bruinehsen + * + * 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 cpu_atmega328p + * @{ + * + * @file + * @brief Implementation of the CPU initialization + * + * @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de> + * @} + */ + +#include "cpu.h" + +/** + * @brief Initialize the CPU, set IRQ priorities + */ +void cpu_init(void) +{ + /* Right now we need to do nothing here */ + ; +} diff --git a/cpu/atmega328p/doc.txt b/cpu/atmega328p/doc.txt new file mode 100644 index 0000000000000000000000000000000000000000..87c16cdbe49f0ff28fbc5e093b58dc5eb9f83088 --- /dev/null +++ b/cpu/atmega328p/doc.txt @@ -0,0 +1,10 @@ +/** + * @defgroup cpu_atmega328p Atmel ATmega328p + * @ingroup cpu + * @brief Implementation of Atmel's ATmega328p MCU + */ + +/** + * @defgroup cpu_atmega328p_definitions Atmel ATmega328p Definitions + * @ingroup cpu_atmega328p + */ diff --git a/cpu/atmega328p/include/cpu_conf.h b/cpu/atmega328p/include/cpu_conf.h new file mode 100644 index 0000000000000000000000000000000000000000..fd6b7a337442c38979ea68764a1ee16131f2e2e0 --- /dev/null +++ b/cpu/atmega328p/include/cpu_conf.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2014 Freie UniversitƤt Berlin, Hinnerk van Bruinehsen + * + * 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 cpu_atmega328p + * @{ + * + * @file + * @brief Implementation specific CPU configuration options + * + * @author Hauke Petersen <hauke.petersen@fu-berlin.de> + * @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de> + */ + +#ifndef CPU_CONF_H +#define CPU_CONF_H + +#include "atmega_regs_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Kernel configuration + * + * Since printf seems to get memory allocated by the linker/avr-libc the stack + * size tested sucessfully even with pretty small stacks.k + * @{ + */ +#define THREAD_EXTRA_STACKSIZE_PRINTF (128) + +#ifndef THREAD_STACKSIZE_DEFAULT +#define THREAD_STACKSIZE_DEFAULT (256) +#endif + +#define THREAD_STACKSIZE_IDLE (128) +#define ISR_STACKSIZE (0) +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* CPU_CONF_H */ +/** @} */ diff --git a/cpu/atmega328p/include/periph_cpu.h b/cpu/atmega328p/include/periph_cpu.h new file mode 100644 index 0000000000000000000000000000000000000000..e7f67a2af9a34ac3c967321c46901317852001d5 --- /dev/null +++ b/cpu/atmega328p/include/periph_cpu.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2015 HAW Hamburg + * 2016 Freie UniversitƤt Berlin + * + * 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 cpu_atmega328p + * @{ + * + * @file + * @brief CPU specific definitions for internal peripheral handling + * + * @author RenĆ© Herthel <rene-herthel@outlook.de> + * @author Hauke Petersen <hauke.petersen@fu-berlin.de> + */ + +#ifndef PERIPH_CPU_H_ +#define PERIPH_CPU_H_ + +#include "periph_cpu_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Define a CPU specific GPIO pin generator macro + */ +#define GPIO_PIN(x, y) ((x << 4) | y) + +/** + * @brief Available ports on the ATmega328p family + */ +enum { + PORT_B = 1, /**< port B */ + PORT_C = 2, /**< port C */ + PORT_D = 3 /**< port D */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* PERIPH_CPU_H_ */ +/** @} */ diff --git a/cpu/atmega328p/lpm_arch.c b/cpu/atmega328p/lpm_arch.c new file mode 100644 index 0000000000000000000000000000000000000000..8c8ed7b9904f6adab986b58a3db2152d87ae39dd --- /dev/null +++ b/cpu/atmega328p/lpm_arch.c @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2014 Freie UniversitƤt Berlin, Hinnerk van Bruinehsen + * + * 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 cpu_atmega328p + * @{ + * + * @file + * @brief Implementation of the kernels power management interface + * + * @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de> + * + * @} + */ + +#include "arch/lpm_arch.h" + +void lpm_arch_init(void) +{ + /* TODO */ +} + +enum lpm_mode lpm_arch_set(enum lpm_mode target) +{ + (void) target; + /* TODO */ + return 0; +} + +enum lpm_mode lpm_arch_get(void) +{ + /* TODO */ + return 0; +} + +void lpm_arch_awake(void) +{ + /* TODO */ +} + +void lpm_arch_begin_awake(void) +{ + /* TODO */ +} + +void lpm_arch_end_awake(void) +{ + /* TODO */ +} diff --git a/cpu/atmega328p/reboot_arch.c b/cpu/atmega328p/reboot_arch.c new file mode 100644 index 0000000000000000000000000000000000000000..802e5926321dc4e860088603e6b312821687c9ab --- /dev/null +++ b/cpu/atmega328p/reboot_arch.c @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de> + * 2014 Freie UniversitƤt Berlin, Hinnerk van Bruinehsen + * + * 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 cpu_atmega328p + * @{ + * + * @file + * @brief Implementation of the kernels reboot interface + * + * @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de> + * @author Kaspar Schleiser <kaspar@schleiser.de> + * + * @} + */ + +#include <avr/wdt.h> + +#include "cpu.h" + +void reboot(void) +{ + /* + * Since the AVR doesn't support a real software reset, we set the Watchdog + * Timer on a 250ms timeout. Consider this a kludge. + */ + wdt_enable(WDTO_250MS); + while(1); +} diff --git a/cpu/atmega328p/startup.c b/cpu/atmega328p/startup.c new file mode 100644 index 0000000000000000000000000000000000000000..4601dcc43027191a25bf2cb64ae89fc185579c10 --- /dev/null +++ b/cpu/atmega328p/startup.c @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2014 Freie UniversitƤt Berlin, Hinnerk van Bruinehsen + * + * 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 cpu_atmega328p + * @{ + * + * @file + * @brief Startup code and interrupt vector definition + * + * @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de> + * + * @} + */ + +#include <stdint.h> +#include <avr/interrupt.h> +#include <avr/io.h> + +/* For Catchall-Loop */ +#include "board.h" + + +/** + * @brief functions for initializing the board, std-lib and kernel + */ +extern void board_init(void); +extern void kernel_init(void); +extern void __libc_init_array(void); + +/** + * @brief This pair of functions hook circumvent the call to main + * + * avr-libc normally uses the .init9 section for a call to main. This call + * seems to be not replaceable without hacking inside the library. We + * circumvent the call to main by using section .init7 to call the function + * reset_handler which therefore is the real entry point and section .init8 + * which should never be reached but just in case jumps to exit. + * This way there should be no way to call main directly. + */ +void init7_ovr(void) __attribute__((naked)) __attribute__((section(".init7"))); +void init8_ovr(void) __attribute__((naked)) __attribute__((section(".init8"))); + + +void init7_ovr(void) +{ + __asm__("call reset_handler"); +} + +void init8_ovr(void) +{ + __asm__("jmp exit"); +} +/** + * @brief This function is the entry point after a system reset + * + * After a system reset, the following steps are necessary and carried out: + * 1. initialize the board (sync clock, setup std-IO) + * 2. initialize and start RIOTs kernel + */ +void reset_handler(void) +{ + /* initialize the board and startup the kernel */ + board_init(); + /* startup the kernel */ + kernel_init(); +} diff --git a/sys/pipe/pipe_dynamic.c b/sys/pipe/pipe_dynamic.c index b6165de24365ae6634b77850092fce92066287de..b6ecd2982dcccbabc5552db757cc4f905697c02b 100644 --- a/sys/pipe/pipe_dynamic.c +++ b/sys/pipe/pipe_dynamic.c @@ -25,7 +25,7 @@ * @} */ -#if defined(MCU_ATMEGA2560) || defined(MCU_ATMEGA1281) +#if defined(MCU_ATMEGA2560) || defined(MCU_ATMEGA1281) || defined(MCU_ATMEGA328P) #include <stdlib.h> #else #include <malloc.h> diff --git a/tests/coap/Makefile b/tests/coap/Makefile index d958921835e16b71cbf27202000f7e9d9487b6c3..411bfc6f99394c3d9eb937a75aa9cbac2c5c6cbc 100644 --- a/tests/coap/Makefile +++ b/tests/coap/Makefile @@ -3,7 +3,7 @@ include ../Makefile.tests_common # msp430 and avr have problems with int width and libcoaps usage of :x notation in structs BOARD_BLACKLIST := arduino-mega2560 chronos msb-430 msb-430h telosb wsn430-v1_3b \ - wsn430-v1_4 z1 waspmote-pro + wsn430-v1_4 z1 waspmote-pro arduino-uno arduino-duemilanove BOARD_INSUFFICIENT_MEMORY := chronos msb-430 msb-430h nucleo-f334 \ stm32f0discovery telosb weio wsn430-v1_3b wsn430-v1_4 z1 diff --git a/tests/libfixmath_unittests/Makefile b/tests/libfixmath_unittests/Makefile index 38c3685ebcd1b81a9b0249afdac38042136a13dc..4325714e0eaa8bd062507dea1c3659c349e82fd2 100644 --- a/tests/libfixmath_unittests/Makefile +++ b/tests/libfixmath_unittests/Makefile @@ -1,7 +1,7 @@ APPLICATION = libfixmath_unittests include ../Makefile.tests_common -BOARD_BLACKLIST := arduino-mega2560 waspmote-pro +BOARD_BLACKLIST := arduino-mega2560 waspmote-pro arduino-uno arduino-duemilanove # arduino-mega2560: builds locally but breaks travis (possibly because of # differences in the toolchain) diff --git a/tests/lwip/Makefile b/tests/lwip/Makefile index c004c6202fa412461cfbc9befc408141dae36125..e078b9fcdbcfe89322141e1d6d48d40c56649018 100644 --- a/tests/lwip/Makefile +++ b/tests/lwip/Makefile @@ -4,7 +4,8 @@ BOARD ?= iotlab-m3 RIOTBASE ?= $(CURDIR)/../.. -BOARD_BLACKLIST := arduino-mega2560 msb-430h telosb waspmote-pro z1 +BOARD_BLACKLIST := arduino-mega2560 msb-430h telosb waspmote-pro z1 arduino-uno \ + arduino-duemilanove BOARD_INSUFFICIENT_MEMORY := airfy-beacon arduino-mega2560 msb-430h nrf6310 \ nucleo-f334 pca10005 stm32f0discovery telosb \ weio yunjia-nrf51822 z1 diff --git a/tests/nhdp/Makefile b/tests/nhdp/Makefile index f7418293ba5d8854d7aa6dba2499c3c16a1d100e..5cc0db1905780a1f7daeac0423d66f87723b9da2 100644 --- a/tests/nhdp/Makefile +++ b/tests/nhdp/Makefile @@ -2,7 +2,8 @@ APPLICATION = nhdp include ../Makefile.tests_common BOARD_BLACKLIST := arduino-mega2560 chronos msb-430 msb-430h telosb \ - wsn430-v1_3b wsn430-v1_4 z1 waspmote-pro + wsn430-v1_3b wsn430-v1_4 z1 waspmote-pro arduino-uno \ + arduino-duemilanove BOARD_INSUFFICIENT_MEMORY := nucleo-f334 stm32f0discovery weio USEMODULE += gnrc_ipv6 diff --git a/tests/pthread/Makefile b/tests/pthread/Makefile index c1abd565a8d243362d60a7984f5153cc1acefb83..2e2c8e2c1c84c2cf29abab63850c7b23ce57dd60 100644 --- a/tests/pthread/Makefile +++ b/tests/pthread/Makefile @@ -1,8 +1,8 @@ APPLICATION = pthread include ../Makefile.tests_common -BOARD_BLACKLIST := arduino-mega2560 waspmote-pro -# arduino-mega2560: unknown type name: clockid_t +BOARD_BLACKLIST := arduino-mega2560 waspmote-pro arduino-uno arduino-duemilanove +# arduino mega2560 uno duemilanove : unknown type name: clockid_t USEMODULE += posix USEMODULE += pthread diff --git a/tests/pthread_barrier/Makefile b/tests/pthread_barrier/Makefile index ed332b7a626c2ee7a0a652ec2cfce5e4d601d32c..25724bd0cee8cccb85f87fa90d6519cb2e3ff897 100644 --- a/tests/pthread_barrier/Makefile +++ b/tests/pthread_barrier/Makefile @@ -2,8 +2,8 @@ APPLICATION = pthread_barrier include ../Makefile.tests_common -BOARD_BLACKLIST := arduino-mega2560 waspmote-pro -# arduino-mega2560: unknown type name: clockid_t +BOARD_BLACKLIST := arduino-mega2560 waspmote-pro arduino-uno arduino-duemilanove +# arduino mega2560 uno duemilanove: unknown type name: clockid_t # exclude boards with insufficient memory BOARD_INSUFFICIENT_MEMORY := stm32f0discovery diff --git a/tests/pthread_cleanup/Makefile b/tests/pthread_cleanup/Makefile index beb03d294c3d83136e2465f4505f6578a3f5577e..dc485fd43c6da6c312ec585aa602f305d8a8008f 100644 --- a/tests/pthread_cleanup/Makefile +++ b/tests/pthread_cleanup/Makefile @@ -1,8 +1,8 @@ APPLICATION = pthread_cleanup include ../Makefile.tests_common -BOARD_BLACKLIST := arduino-mega2560 waspmote-pro -# arduino-mega2560: unknown type name: clockid_t +BOARD_BLACKLIST := arduino-mega2560 waspmote-pro arduino-uno arduino-duemilanove +# arduino mega2560 uno duemilanove : unknown type name: clockid_t USEMODULE += pthread diff --git a/tests/pthread_condition_variable/Makefile b/tests/pthread_condition_variable/Makefile index 902190c834527521dcb8ec66170d76f988222875..a21acd800ae75cfad9d1b7e389e3efbfc6410fa8 100644 --- a/tests/pthread_condition_variable/Makefile +++ b/tests/pthread_condition_variable/Makefile @@ -1,8 +1,8 @@ APPLICATION = condition_variable include ../Makefile.tests_common -BOARD_BLACKLIST := arduino-mega2560 waspmote-pro -# arduino-mega2560: unknown type name: clockid_t +BOARD_BLACKLIST := arduino-mega2560 waspmote-pro arduino-uno arduino-duemilanove +# arduino mega2560 uno duemilanove: unknown type name: clockid_t BOARD_INSUFFICIENT_MEMORY := stm32f0discovery diff --git a/tests/pthread_cooperation/Makefile b/tests/pthread_cooperation/Makefile index ab53757820ca584fe25e470b952e4aee99d85024..dc249777d3bf27843f36ee6c79d2f459abedfa06 100644 --- a/tests/pthread_cooperation/Makefile +++ b/tests/pthread_cooperation/Makefile @@ -1,8 +1,8 @@ APPLICATION = pthread_cooperation include ../Makefile.tests_common -BOARD_BLACKLIST := arduino-mega2560 waspmote-pro -# arduino-mega2560: unknown type name: clockid_t +BOARD_BLACKLIST := arduino-mega2560 waspmote-pro arduino-uno arduino-duemilanove +# arduino mega2560 uno duemilanove: unknown type name: clockid_t USEMODULE += posix USEMODULE += pthread diff --git a/tests/pthread_rwlock/Makefile b/tests/pthread_rwlock/Makefile index e6b7bd20cf6f93bc9517ae3f3f0a9eb2811c11f0..0f6c422e040cf6aee59f507715c450748fb7c8a6 100644 --- a/tests/pthread_rwlock/Makefile +++ b/tests/pthread_rwlock/Makefile @@ -1,8 +1,8 @@ APPLICATION = pthread_rwlock include ../Makefile.tests_common -BOARD_BLACKLIST := arduino-mega2560 waspmote-pro -# arduino-mega2560: unknown type name: clockid_t +BOARD_BLACKLIST := arduino-mega2560 waspmote-pro arduino-uno arduino-duemilanove +# arduino mega2560 uno duemilanove: unknown type name: clockid_t USEMODULE += pthread USEMODULE += xtimer diff --git a/tests/pthread_tls/Makefile b/tests/pthread_tls/Makefile index 8575ea74d48c31de95678697ab3c37bbe55fe48f..0fe7b4e5a836c8c6ead77a158a74aedac2ba981d 100644 --- a/tests/pthread_tls/Makefile +++ b/tests/pthread_tls/Makefile @@ -1,8 +1,8 @@ APPLICATION = pthread_tls include ../Makefile.tests_common -BOARD_BLACKLIST := arduino-mega2560 waspmote-pro -# arduino-mega2560: unknown type name: clockid_t +BOARD_BLACKLIST := arduino-mega2560 waspmote-pro arduino-uno arduino-duemilanove +# arduino mega2560 uno duemilanove: unknown type name: clockid_t USEMODULE += posix USEMODULE += pthread diff --git a/tests/unittests/Makefile b/tests/unittests/Makefile index e87ff2aaa80a52c80c1fdcb54f58051be26a7448..df128865080a748ec053cd3e8a99b78289f35779 100644 --- a/tests/unittests/Makefile +++ b/tests/unittests/Makefile @@ -6,7 +6,8 @@ BOARD_INSUFFICIENT_MEMORY := airfy-beacon cc2650stk chronos msb-430 msb-430h pca telosb wsn430-v1_3b wsn430-v1_4 z1 nucleo-f103 \ nucleo-f334 yunjia-nrf51822 samr21-xpro \ arduino-mega2560 airfy-beacon nrf51dongle nrf6310 \ - weio waspmote-pro nucleo-f072 + weio waspmote-pro nucleo-f072 arduino-uno \ + arduino-duemilanove USEMODULE += embunit @@ -27,7 +28,7 @@ ARM_CORTEX_M_BOARDS := airfy-beacon arduino-due cc2538dk ek-lm4f120xl f4vi1 fox yunjia-nrf51822 DISABLE_TEST_FOR_ARM_CORTEX_M := tests-relic -AVR_BOARDS := arduino-mega2560 waspmote-pro +AVR_BOARDS := arduino-mega2560 waspmote-pro arduino-uno arduino-duemilanove DISABLE_TEST_FOR_AVR := tests-relic MSP430_BOARDS := chronos msb-430 msb-430h telosb wsn430-v1_3b wsn430-v1_4 z1