Browse Source

Merge pull request #6516 from antmerlino/arduino-cleanup

Changes arduino-common to arduino-atmega-common.
patch-1
Francisco Acosta 6 years ago committed by GitHub
parent
commit
79a4acee43
  1. 2
      boards/arduino-atmega-common/Makefile
  2. 0
      boards/arduino-atmega-common/Makefile.dep
  3. 0
      boards/arduino-atmega-common/Makefile.features
  4. 29
      boards/arduino-atmega-common/Makefile.include
  5. 9
      boards/arduino-atmega-common/board.c
  6. 0
      boards/arduino-atmega-common/dist/debug.sh
  7. 0
      boards/arduino-atmega-common/dist/debug_srv.sh
  8. 0
      boards/arduino-atmega-common/dist/gdb.conf
  9. 56
      boards/arduino-atmega-common/include/arduino_board.h
  10. 40
      boards/arduino-atmega-common/include/arduino_pinmap.h
  11. 21
      boards/arduino-atmega-common/include/board.h
  12. 2
      boards/arduino-atmega-common/include/gpio_params.h
  13. 53
      boards/arduino-atmega-common/include/periph_conf.h
  14. 47
      boards/arduino-common/Makefile.include
  15. 74
      boards/arduino-common/include/arduino_pinmap.h
  16. 89
      boards/arduino-common/include/periph_conf.h
  17. 2
      boards/arduino-duemilanove/Makefile
  18. 2
      boards/arduino-duemilanove/Makefile.features
  19. 22
      boards/arduino-duemilanove/Makefile.include
  20. 2
      boards/arduino-mega2560/Makefile
  21. 11
      boards/arduino-mega2560/Makefile.features
  22. 55
      boards/arduino-mega2560/Makefile.include
  23. 81
      boards/arduino-mega2560/board.c
  24. 8
      boards/arduino-mega2560/dist/debug.sh
  25. 7
      boards/arduino-mega2560/dist/debug_srv.sh
  26. 1
      boards/arduino-mega2560/dist/gdb.conf
  27. 86
      boards/arduino-mega2560/include/board.h
  28. 2
      boards/arduino-uno/Makefile
  29. 2
      boards/arduino-uno/Makefile.features
  30. 22
      boards/arduino-uno/Makefile.include
  31. 4
      boards/arduino-zero/Makefile.include
  32. 9
      boards/waspmote-pro/Makefile.include
  33. 21
      cpu/atmega_common/Makefile.include

2
boards/arduino-common/Makefile → boards/arduino-atmega-common/Makefile

@ -1,3 +1,3 @@
MODULE = arduino-common
MODULE = arduino-atmega-common
include $(RIOTBASE)/Makefile.base

0
boards/arduino-common/Makefile.dep → boards/arduino-atmega-common/Makefile.dep

0
boards/arduino-common/Makefile.features → boards/arduino-atmega-common/Makefile.features

29
boards/arduino-atmega-common/Makefile.include

@ -0,0 +1,29 @@
# include optional dependencies
include $(RIOTBOARD)/arduino-atmega-common/Makefile.dep
# define port used to flash the board
OS = $(shell uname)
ifeq ($(OS),Linux)
PORT = $(PORT_LINUX)
else ifeq ($(OS),Darwin)
PORT ?= $(PORT_DARWIN)
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)
export PROGRAMMER_FLAGS = -P $(PORT) -b $(PROGRAMMER_SPEED)
export OFLAGS += -j .text -j .data -O ihex
export FFLAGS += -c $(PROGRAMMER) $(PROGRAMMER_FLAGS) -F -D -U flash:w:bin/$(BOARD)/$(PROJECT)$(APPLICATION).hex

9
boards/arduino-common/board.c → boards/arduino-atmega-common/board.c

@ -9,7 +9,7 @@
*/
/**
* @ingroup boards_arduino-common
* @ingroup boards_arduino-atmega-common
* @{
*
* @file
@ -29,6 +29,7 @@
#include "board.h"
#include "cpu.h"
#include "uart_stdio.h"
#include "periph/gpio.h"
void led_init(void);
void SystemInit(void);
@ -46,9 +47,9 @@ void board_init(void)
/* initialize the CPU */
cpu_init();
/* initialize the board LED (connected to pin PB5) */
DDRB |= (1 << DDB5);
PORTB &= ~(1 << 5);
/* initialize the board LED */
gpio_init(LED0_PIN, GPIO_OUT);
LED0_OFF;
irq_enable();
}

0
boards/arduino-common/dist/debug.sh → boards/arduino-atmega-common/dist/debug.sh vendored

0
boards/arduino-common/dist/debug_srv.sh → boards/arduino-atmega-common/dist/debug_srv.sh vendored

0
boards/arduino-common/dist/gdb.conf → boards/arduino-atmega-common/dist/gdb.conf vendored

56
boards/arduino-common/include/arduino_board.h → boards/arduino-atmega-common/include/arduino_board.h

@ -7,7 +7,7 @@
*/
/**
* @ingroup boards_arduino-common
* @ingroup boards_arduino-atmega-common
* @{
*
* @file
@ -54,7 +54,59 @@ static const gpio_t arduino_pinmap[] = {
ARDUINO_PIN_16,
ARDUINO_PIN_17,
ARDUINO_PIN_18,
ARDUINO_PIN_19
ARDUINO_PIN_19,
#ifdef CPU_ATMEGA2560
ARDUINO_PIN_20,
ARDUINO_PIN_21,
ARDUINO_PIN_22,
ARDUINO_PIN_23,
ARDUINO_PIN_24,
ARDUINO_PIN_25,
ARDUINO_PIN_26,
ARDUINO_PIN_27,
ARDUINO_PIN_28,
ARDUINO_PIN_29,
ARDUINO_PIN_30,
ARDUINO_PIN_31,
ARDUINO_PIN_32,
ARDUINO_PIN_33,
ARDUINO_PIN_34,
ARDUINO_PIN_35,
ARDUINO_PIN_36,
ARDUINO_PIN_37,
ARDUINO_PIN_38,
ARDUINO_PIN_39,
ARDUINO_PIN_40,
ARDUINO_PIN_41,
ARDUINO_PIN_42,
ARDUINO_PIN_43,
ARDUINO_PIN_44,
ARDUINO_PIN_45,
ARDUINO_PIN_46,
ARDUINO_PIN_47,
ARDUINO_PIN_48,
ARDUINO_PIN_49,
ARDUINO_PIN_50,
ARDUINO_PIN_51,
ARDUINO_PIN_52,
ARDUINO_PIN_53,
ARDUINO_PIN_54,
ARDUINO_PIN_55,
ARDUINO_PIN_56,
ARDUINO_PIN_57,
ARDUINO_PIN_58,
ARDUINO_PIN_59,
ARDUINO_PIN_60,
ARDUINO_PIN_61,
ARDUINO_PIN_62,
ARDUINO_PIN_63,
ARDUINO_PIN_64,
ARDUINO_PIN_65,
ARDUINO_PIN_66,
ARDUINO_PIN_67,
ARDUINO_PIN_68,
ARDUINO_PIN_69
#endif
};
#ifdef __cplusplus

40
boards/arduino-mega2560/include/arduino_pinmap.h → boards/arduino-atmega-common/include/arduino_pinmap.h

@ -1,5 +1,6 @@
/*
* 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
@ -7,7 +8,7 @@
*/
/**
* @ingroup boards_arduino-mega2560
* @ingroup boards_arduino-atmega-common
* @{
*
* @file
@ -18,6 +19,7 @@
*
* @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
@ -32,6 +34,40 @@ extern "C" {
*
* @note ISCP pins are not mapped.
*/
/* Digital pins */
#ifdef CPU_ATMEGA328P
#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
#endif
#ifdef CPU_ATMEGA2560
#define ARDUINO_PIN_0 GPIO_PIN(PORT_E, 0)
#define ARDUINO_PIN_1 GPIO_PIN(PORT_E, 1)
#define ARDUINO_PIN_2 GPIO_PIN(PORT_E, 4)
@ -118,6 +154,8 @@ extern "C" {
#define ARDUINO_PIN_A13 ARDUINO_PIN_67
#define ARDUINO_PIN_A14 ARDUINO_PIN_68
#define ARDUINO_PIN_A15 ARDUINO_PIN_69
#endif
/** @ */
#ifdef __cplusplus

21
boards/arduino-common/include/board.h → boards/arduino-atmega-common/include/board.h

@ -8,7 +8,7 @@
*/
/**
* @defgroup boards_arduino-common Arduino common
* @defgroup boards_arduino-atmega-common Arduino common
* @ingroup boards
* @brief Board specific files for the arduino Uno and
* @brief Duemilanove boards.
@ -44,9 +44,15 @@ extern "C" {
* @brief LED pin definitions and handlers
* @{
*/
#ifdef CPU_ATMEGA328P
#define LED0_PIN GPIO_PIN(1, 5)
#define LED0_MASK (1 << DDB5)
#endif
#ifdef CPU_ATMEGA2560
#define LED0_PIN GPIO_PIN(1, 7)
#define LED0_MASK (1 << DDB7)
#endif
#define LED0_ON (PORTB |= LED0_MASK)
#define LED0_OFF (PORTB &= ~LED0_MASK)
@ -58,6 +64,7 @@ extern "C" {
** Setup to use PC5 which is pin change interrupt 13 (PCINT13)
** This emulates a software triggered interrupt
***/
#ifdef CPU_ATMEGA328P
#define AVR_CONTEXT_SWAP_INIT do { \
DDRC |= (1 << PC5); \
PCICR |= (1 << PCIE1); \
@ -65,7 +72,17 @@ extern "C" {
} while (0)
#define AVR_CONTEXT_SWAP_INTERRUPT_VECT PCINT1_vect
#define AVR_CONTEXT_SWAP_TRIGGER PORTC ^= (1 << PC5)
#endif
#ifdef CPU_ATMEGA2560
#define AVR_CONTEXT_SWAP_INIT do { \
DDRJ |= (1 << PJ6); \
PCICR |= (1 << PCIE1); \
PCMSK1 |= (1 << PCINT15); \
} while (0)
#define AVR_CONTEXT_SWAP_INTERRUPT_VECT PCINT1_vect
#define AVR_CONTEXT_SWAP_TRIGGER PORTJ ^= (1 << PJ6)
#endif
/**
* @brief xtimer configuration values

2
boards/arduino-common/include/gpio_params.h → boards/arduino-atmega-common/include/gpio_params.h

@ -7,7 +7,7 @@
*/
/**
* @ingroup boards_arduino-common
* @ingroup boards_arduino-atmega-common
* @{
*
* @file

53
boards/arduino-mega2560/include/periph_conf.h → boards/arduino-atmega-common/include/periph_conf.h

@ -1,6 +1,6 @@
/*
* Copyright (C) 2014-2016 Freie Universität Berlin
* 2014 Hinnerk van Bruinehsen
* 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
@ -8,13 +8,15 @@
*/
/**
* @ingroup boards_arduino-mega2560
* @ingroup boards_arduino-atmega-common
* @{
*
* @file
* @brief Peripheral MCU configuration for the Arduino Mega 2560 board
* @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>
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/
@ -35,11 +37,27 @@ extern "C" {
/**
* @name Timer configuration
*
* arduino uno and arduino duemilanove:
* The timer driver only supports the 16-bit timer (Timer1)
* so this is the only one we can use here.
*
* arduino mega2560:
* The timer driver only supports the four 16-bit timers (Timer1, Timer3,
* Timer4, Timer5), so those are the only onces we can use here.
*
* @{
*/
#ifdef CPU_ATMEGA328P
#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
#endif
#ifdef CPU_ATMEGA2560
#define TIMER_NUMOF (2U)
#define TIMER_0 MEGA_TIMER1
@ -55,6 +73,9 @@ extern "C" {
#define TIMER_1_ISRA TIMER4_COMPA_vect
#define TIMER_1_ISRB TIMER4_COMPB_vect
#define TIMER_1_ISRC TIMER4_COMPC_vect
#endif
/** @} */
/**
@ -66,6 +87,14 @@ extern "C" {
*
* @{
*/
#ifdef CPU_ATMEGA328P
#define UART_NUMOF (1U)
#define UART_0 MEGA_UART0
#define UART_0_ISR USART_RX_vect
#endif
#ifdef CPU_ATMEGA2560
#define UART_NUMOF (4U)
#define UART_0 MEGA_UART0
@ -79,6 +108,7 @@ extern "C" {
#define UART_3 MEGA_UART3
#define UART_3_ISR USART3_RX_vect
#endif
/** @} */
/**
@ -87,7 +117,13 @@ extern "C" {
* 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:
* The fixed pins for arduino uno and duemilanove 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
*
* The fixed pins for arduino mega2560 are:
* MOSI - PB2 (Arduino pin 51)
* MISO - PB3 (Arduino pin 50)
* SCK - PB1 (Arduino pin 52)
@ -96,7 +132,14 @@ extern "C" {
* @{
*/
#define SPI_NUMOF 1 /* set to 0 to disable SPI */
#ifdef CPU_ATMEGA328P
#define MEGA_PRR PRR /* Power Reduction Register is PRR */
#endif
#ifdef CPU_ATMEGA2560
#define MEGA_PRR PRR0 /* Power Reduction Register is PRR0 */
#endif
/** @} */
#ifdef __cplusplus

47
boards/arduino-common/Makefile.include

@ -1,47 +0,0 @@
# define the cpu used by the arduino uno and duemilanove boards
export CPU = atmega328p
# include optional dependencies
include $(RIOTBOARD)/arduino-common/Makefile.dep
# 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

74
boards/arduino-common/include/arduino_pinmap.h

@ -1,74 +0,0 @@
/*
* 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 */
/** @} */

89
boards/arduino-common/include/periph_conf.h

@ -1,89 +0,0 @@
/*
* 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)
/** @} */
/**
* @name 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
/** @} */
/**
* @name 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
/** @} */
/**
* @name 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 MEGA_PRR PRR /* Power Reduction Register is PRR */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* PERIPH_CONF_H */

2
boards/arduino-duemilanove/Makefile

@ -1,5 +1,5 @@
MODULE = board
DIRS = $(RIOTBOARD)/arduino-common
DIRS = $(RIOTBOARD)/arduino-atmega-common
include $(RIOTBASE)/Makefile.base

2
boards/arduino-duemilanove/Makefile.features

@ -1 +1 @@
include $(RIOTBOARD)/arduino-common/Makefile.features
include $(RIOTBOARD)/arduino-atmega-common/Makefile.features

22
boards/arduino-duemilanove/Makefile.include

@ -1,10 +1,20 @@
USEMODULE += arduino-common
# define the cpu used by the ardudino duemilanove board
export CPU = atmega328p
# add arduino-common include path
INCLUDES += -I$(RIOTBOARD)/arduino-common/include
USEMODULE += arduino-atmega-common
# add arduino-atmega-common include path
INCLUDES += -I$(RIOTBOARD)/arduino-atmega-common/include
#export needed for flash rule
export LINUX_PORT = /dev/ttyUSB0
export PROGRAMMER_SPEED = 57600
export PORT_LINUX ?= /dev/ttyUSB0
export PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
export PROGRAMMER_SPEED ?= 57600
export FFLAGS += -p m328p
# 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
include $(RIOTBOARD)/arduino-common/Makefile.include
include $(RIOTBOARD)/arduino-atmega-common/Makefile.include

2
boards/arduino-mega2560/Makefile

@ -1,3 +1,5 @@
MODULE = board
DIRS = $(RIOTBOARD)/arduino-atmega-common
include $(RIOTBASE)/Makefile.base

11
boards/arduino-mega2560/Makefile.features

@ -1,10 +1 @@
# 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
include $(RIOTBOARD)/arduino-atmega-common/Makefile.features

55
boards/arduino-mega2560/Makefile.include

@ -1,53 +1,20 @@
# define the cpu used by the arduino mega2560 board
export CPU = atmega2560
export TERMPROG = $(RIOTBASE)/dist/tools/pyterm/pyterm
export TERMFLAGS = -b 9600 -p $(PORT)
USEMODULE += arduino-atmega-common
#define the flash-tool and default port depending on the host operating system
OS = $(shell uname)
ifeq ($(OS),Linux)
PORT ?= /dev/ttyACM0
FLASHER = avrdude
else ifeq ($(OS),Darwin)
PORT ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
FLASHER = avrdude
else
$(info CAUTION: No flash tool for your host system found!)
# TODO: fix for building under windows
endif
export FLASHER
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)
# add arduino-atmega-common include path
INCLUDES += -I$(RIOTBOARD)/arduino-atmega-common/include
#export needed for flash rule
export PORT_LINUX ?= /dev/ttyACM0
export PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
export PROGRAMMER_SPEED ?= 115200
export FFLAGS += -p m2560
# PROGRAMMER defaults to stk500v2 which is the internal flasher via USB. Can be
# overridden for debugging (which requires changes that require to use an ISP)
export PROGRAMMER ?= stk500v2
ifeq ($(PROGRAMMER), stk500v2)
export PROGRAMMER_FLAGS = -P $(PORT) -b 115200
endif
# define build specific options
export CFLAGS_CPU = -mmcu=atmega2560 $(CFLAGS_FPU)
export CFLAGS_LINK = -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) -e reset_handler
export OFLAGS += -j .text -j .data -O ihex
export FFLAGS += -p m2560 -c $(PROGRAMMER) $(PROGRAMMER_FLAGS) -F -D -U flash:w:bin/$(BOARD)/$(PROJECT)$(APPLICATION).hex
ifeq ($(LTO),1)
# avr-gcc <4.8.3 has a bug when using LTO which causes a warning to be printed always:
# '_vector_25' appears to be a misspelled signal handler [enabled by default]
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59396
export LINKFLAGS += -Wno-error
endif
include $(RIOTBOARD)/arduino-atmega-common/Makefile.include

81
boards/arduino-mega2560/board.c

@ -1,81 +0,0 @@
/*
* Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen
* 2015 Kaspar Schleiser <kaspar@schleiser.de>
*
* 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-mega2560
* @{
*
* @file
* @brief Board specific implementations for the Arduino Mega 2560 board
*
* @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
* @author Kaspar Schleiser <kaspar@schleiser.de>
*
* @}
*/
#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 PB7) */
DDRB |= (1 << DDB7);
PORTB &= ~(1 << 7);
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;
}

8
boards/arduino-mega2560/dist/debug.sh vendored

@ -1,8 +0,0 @@
#!/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

7
boards/arduino-mega2560/dist/debug_srv.sh vendored

@ -1,7 +0,0 @@
#!/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

1
boards/arduino-mega2560/dist/gdb.conf vendored

@ -1 +0,0 @@
set $pc=0x00

86
boards/arduino-mega2560/include/board.h

@ -1,86 +0,0 @@
/*
* 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.
*/
/**
* @defgroup boards_arduino-mega2560 Arduino Mega 2560
* @ingroup boards
* @brief Board specific files for the Arduino Mega 2560 board.
* @{
*
* @file
* @brief Board specific definitions for the Arduino Mega 2560 board.
*
* @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
*/
#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, 7)
#define LED0_MASK (1 << DDB7)
#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 { \
DDRJ |= (1 << PJ6); \
PCICR |= (1 << PCIE1); \
PCMSK1 |= (1 << PCINT15); \
} while (0)
#define AVR_CONTEXT_SWAP_INTERRUPT_VECT PCINT1_vect
#define AVR_CONTEXT_SWAP_TRIGGER PORTJ ^= (1 << PJ6)
/**
* @brief xtimer configuration values
* @{
*/
#define XTIMER_WIDTH (16)
#define XTIMER_SHIFT (2)
#define XTIMER_HZ (250000UL)
#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 */
/** @} */

2
boards/arduino-uno/Makefile

@ -1,5 +1,5 @@
MODULE = board
DIRS = $(RIOTBOARD)/arduino-common
DIRS = $(RIOTBOARD)/arduino-atmega-common
include $(RIOTBASE)/Makefile.base

2
boards/arduino-uno/Makefile.features

@ -1 +1 @@
include $(RIOTBOARD)/arduino-common/Makefile.features
include $(RIOTBOARD)/arduino-atmega-common/Makefile.features

22
boards/arduino-uno/Makefile.include

@ -1,10 +1,20 @@
USEMODULE += arduino-common
# define the cpu used by the arduino uno board
export CPU = atmega328p
# add arduino-common include path
INCLUDES += -I$(RIOTBOARD)/arduino-common/include
USEMODULE += arduino-atmega-common
# add arduino-atmega-common include path
INCLUDES += -I$(RIOTBOARD)/arduino-atmega-common/include
# export needed for flash rule
export LINUX_PORT = /dev/ttyACM0
export PROGRAMMER_SPEED = 115200
export PORT_LINUX ?= /dev/ttyACM0
export PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
export PROGRAMMER_SPEED ?= 115200
export FFLAGS += -p m328p
# 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
include $(RIOTBOARD)/arduino-common/Makefile.include
include $(RIOTBOARD)/arduino-atmega-common/Makefile.include

4
boards/arduino-zero/Makefile.include

@ -3,8 +3,8 @@ export CPU = samd21
export CPU_MODEL = samd21g18a
# set default port depending on operating system
PORT_LINUX ?= /dev/ttyACM0
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
export PORT_LINUX ?= /dev/ttyACM0
export PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*)))
# setup serial terminal
include $(RIOTBOARD)/Makefile.include.serial

9
boards/waspmote-pro/Makefile.include

@ -43,14 +43,5 @@ ifeq ($(PROGRAMMER), stk500v1)
export PROGRAMMER_FLAGS = -P $(PORT) -b 115200
endif
# define build specific options
export CFLAGS_CPU = -mmcu=atmega1281 $(CFLAGS_FPU)
export CFLAGS_LINK = -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) -e reset_handler
export OFLAGS += -j .text -j .data -O ihex
export FFLAGS += -p m1281 -c $(PROGRAMMER) $(PROGRAMMER_FLAGS) -F -U flash:w:bin/$(BOARD)/$(PROJECT)$(APPLICATION).hex

21
cpu/atmega_common/Makefile.include

@ -1,14 +1,14 @@
# Target architecture for the build. Use avr if you are unsure.
export TARGET_ARCH ?= avr
# define build specific options
CFLAGS_LINK = -ffunction-sections -fdata-sections
export CFLAGS_CPU = -mmcu=$(CPU) $(CFLAGS_FPU)
export CFLAGS_LINK = -ffunction-sections -fdata-sections -fno-builtin -fshort-enums
export CFLAGS_DBG ?= -ggdb -g3
export CFLAGS_OPT ?= -Os
# export compiler flags
export CFLAGS += $(CFLAGS_LINK)
# export linker flags
export LINKFLAGS += -Wl,--gc-sections -static -lgcc
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 -Wl,--gc-sections
# export the peripheral drivers to be linked into the final binary
export USEMODULE += periph
@ -19,3 +19,10 @@ export USEMODULE += uart_stdio
# include module specific includes
export INCLUDES += -I$(RIOTCPU)/atmega_common/include -isystem$(RIOTCPU)/atmega_common/avr-libc-extra
ifeq ($(LTO),1)
# avr-gcc <4.8.3 has a bug when using LTO which causes a warning to be printed always:
# '_vector_25' appears to be a misspelled signal handler [enabled by default]
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59396
export LINKFLAGS += -Wno-error
endif

Loading…
Cancel
Save