From d98105047c42c34d8d0b84d001b1a41a4043b363 Mon Sep 17 00:00:00 2001 From: Francisco Acosta Date: Tue, 15 May 2018 02:38:49 +0200 Subject: [PATCH] cpu/atmega*: remove unnecessary code (already factored out) cpu.c and startup.c were redundant in most platforms, except for atmega256rfr2. The common code is now in cpu/atmega_common/cpu.c and cpu/atmega_common/startup.c. cpu_conf.h is also removed as it's now in cpu/atmega_common/include thus shared by all atmega based platforms. --- cpu/atmega1281/Makefile.include | 9 +- cpu/atmega1281/cpu.c | 30 ------ cpu/atmega1281/include/cpu_conf.h | 51 ---------- cpu/atmega1281/startup.c | 72 -------------- cpu/atmega1284p/Makefile.include | 6 +- cpu/atmega1284p/cpu.c | 32 ------- cpu/atmega1284p/startup.c | 74 --------------- cpu/atmega2560/Makefile.include | 9 +- cpu/atmega2560/cpu.c | 30 ------ cpu/atmega2560/include/cpu_conf.h | 50 ---------- cpu/atmega2560/startup.c | 73 -------------- cpu/atmega256rfr2/Makefile.include | 8 +- cpu/atmega256rfr2/cpu.c | 137 --------------------------- cpu/atmega256rfr2/include/cpu_conf.h | 52 ---------- cpu/atmega256rfr2/startup.c | 72 -------------- cpu/atmega328p/Makefile.include | 5 +- cpu/atmega328p/cpu.c | 30 ------ cpu/atmega328p/include/cpu_conf.h | 50 ---------- cpu/atmega328p/startup.c | 72 -------------- cpu/atmega_common/Makefile | 4 +- 20 files changed, 9 insertions(+), 857 deletions(-) delete mode 100644 cpu/atmega1281/cpu.c delete mode 100644 cpu/atmega1281/include/cpu_conf.h delete mode 100644 cpu/atmega1281/startup.c delete mode 100644 cpu/atmega1284p/cpu.c delete mode 100644 cpu/atmega1284p/startup.c delete mode 100644 cpu/atmega2560/cpu.c delete mode 100644 cpu/atmega2560/include/cpu_conf.h delete mode 100644 cpu/atmega2560/startup.c delete mode 100644 cpu/atmega256rfr2/cpu.c delete mode 100644 cpu/atmega256rfr2/include/cpu_conf.h delete mode 100644 cpu/atmega256rfr2/startup.c delete mode 100644 cpu/atmega328p/cpu.c delete mode 100644 cpu/atmega328p/include/cpu_conf.h delete mode 100644 cpu/atmega328p/startup.c diff --git a/cpu/atmega1281/Makefile.include b/cpu/atmega1281/Makefile.include index 6647a8d43794..ec13e73aeaa9 100644 --- a/cpu/atmega1281/Makefile.include +++ b/cpu/atmega1281/Makefile.include @@ -1,12 +1,5 @@ # 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/ - -# explicitly tell the linker to link the syscalls and startup code. -# Without this the interrupt vectors will not be linked correctly! -export UNDEF += $(BINDIR)/cpu/startup.o - # CPU depends on the atmega common module, so include it -include $(ATMEGA_COMMON)Makefile.include +include $(RIOTCPU)/atmega_common/Makefile.include diff --git a/cpu/atmega1281/cpu.c b/cpu/atmega1281/cpu.c deleted file mode 100644 index 2d184cf544db..000000000000 --- a/cpu/atmega1281/cpu.c +++ /dev/null @@ -1,30 +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. - */ - -/** - * @ingroup cpu_atmega1281 - * @{ - * - * @file - * @brief Implementation of the CPU initialization - * - * @author Hinnerk van Bruinehsen - * @} - */ - -#include "cpu.h" -#include "periph/init.h" - -/** - * @brief Initialize the CPU, set IRQ priorities - */ -void cpu_init(void) -{ - /* trigger static peripheral initialization */ - periph_init(); -} diff --git a/cpu/atmega1281/include/cpu_conf.h b/cpu/atmega1281/include/cpu_conf.h deleted file mode 100644 index 438cbc70ed63..000000000000 --- a/cpu/atmega1281/include/cpu_conf.h +++ /dev/null @@ -1,51 +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. - */ - -/** - * @{ - * - * @file - * @brief Implementation specific CPU configuration options - * - * @author Hauke Petersen - * @author Hinnerk van Bruinehsen - */ - -#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 successfully even with pretty small stacks. - * @{ - */ -#define THREAD_EXTRA_STACKSIZE_PRINTF (128) - -#ifndef THREAD_STACKSIZE_DEFAULT -# define THREAD_STACKSIZE_DEFAULT (256) -#endif - -#ifndef THREAD_STACKSIZE_IDLE -# define THREAD_STACKSIZE_IDLE (128) -#endif -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* CPU_CONF_H */ -/** @} */ diff --git a/cpu/atmega1281/startup.c b/cpu/atmega1281/startup.c deleted file mode 100644 index c6521055ef58..000000000000 --- a/cpu/atmega1281/startup.c +++ /dev/null @@ -1,72 +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. - */ - -/** - * @ingroup cpu_atmega1281 - * @{ - * - * @file - * @brief Startup code and interrupt vector definition - * - * @author Hinnerk van Bruinehsen - * - * @} - */ - -#include -#include -#include - -/* 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/cpu/atmega1284p/Makefile.include b/cpu/atmega1284p/Makefile.include index b46d4e871c8f..653f58a4a9f7 100644 --- a/cpu/atmega1284p/Makefile.include +++ b/cpu/atmega1284p/Makefile.include @@ -1,8 +1,6 @@ # 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 +include $(RIOTCPU)/atmega_common/Makefile.include + diff --git a/cpu/atmega1284p/cpu.c b/cpu/atmega1284p/cpu.c deleted file mode 100644 index 1597edb175da..000000000000 --- a/cpu/atmega1284p/cpu.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen - * 2018 Matthew Blue - * - * 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_atmega1284p - * @{ - * - * @file - * @brief Implementation of the CPU initialization - * - * @author Hinnerk van Bruinehsen - * @author Matthew Blue - * @} - */ - -#include "cpu.h" -#include "periph/init.h" - -/** - * @brief Initialize the CPU, set IRQ priorities - */ -void cpu_init(void) -{ - /* trigger static peripheral initialization */ - periph_init(); -} diff --git a/cpu/atmega1284p/startup.c b/cpu/atmega1284p/startup.c deleted file mode 100644 index 7c4d8a56d7c0..000000000000 --- a/cpu/atmega1284p/startup.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen - * 2018 Matthew Blue - * - * 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_atmega1284p - * @{ - * - * @file - * @brief Startup code and interrupt vector definition - * - * @author Hinnerk van Bruinehsen - * @author Matthew Blue - * - * @} - */ - -#include -#include -#include - -/* 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/cpu/atmega2560/Makefile.include b/cpu/atmega2560/Makefile.include index 6647a8d43794..ec13e73aeaa9 100644 --- a/cpu/atmega2560/Makefile.include +++ b/cpu/atmega2560/Makefile.include @@ -1,12 +1,5 @@ # 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/ - -# explicitly tell the linker to link the syscalls and startup code. -# Without this the interrupt vectors will not be linked correctly! -export UNDEF += $(BINDIR)/cpu/startup.o - # CPU depends on the atmega common module, so include it -include $(ATMEGA_COMMON)Makefile.include +include $(RIOTCPU)/atmega_common/Makefile.include diff --git a/cpu/atmega2560/cpu.c b/cpu/atmega2560/cpu.c deleted file mode 100644 index 8ea4e28b5f0f..000000000000 --- a/cpu/atmega2560/cpu.c +++ /dev/null @@ -1,30 +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. - */ - -/** - * @ingroup cpu_atmega2560 - * @{ - * - * @file - * @brief Implementation of the CPU initialization - * - * @author Hinnerk van Bruinehsen - * @} - */ - -#include "cpu.h" -#include "periph/init.h" - -/** - * @brief Initialize the CPU, set IRQ priorities - */ -void cpu_init(void) -{ - /* trigger static peripheral initialization */ - periph_init(); -} diff --git a/cpu/atmega2560/include/cpu_conf.h b/cpu/atmega2560/include/cpu_conf.h deleted file mode 100644 index 1e7f0eac9a05..000000000000 --- a/cpu/atmega2560/include/cpu_conf.h +++ /dev/null @@ -1,50 +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. - */ - -/** - * @ingroup cpu_atmega2560 - * @{ - * - * @file - * @brief Implementation specific CPU configuration options - * - * @author Hauke Petersen - * @author Hinnerk van Bruinehsen - */ - -#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 successfully 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) -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* CPU_CONF_H */ -/** @} */ diff --git a/cpu/atmega2560/startup.c b/cpu/atmega2560/startup.c deleted file mode 100644 index b53d18f2dc2e..000000000000 --- a/cpu/atmega2560/startup.c +++ /dev/null @@ -1,73 +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. - */ - -/** - * @ingroup cpu_atmega2560 - * @{ - * - * @file - * @brief Startup code and interrupt vector definition - * - * @author Hinnerk van Bruinehsen - * - * @} - */ - -#include -#include -#include - -/* 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__((section(".init7"))); -void init8_ovr(void) __attribute__((section(".init8"))); - - -__attribute__((used,naked)) void init7_ovr(void) -{ - __asm__("call reset_handler"); -} - -__attribute__((used,naked)) 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 - */ -__attribute__((used)) void reset_handler(void) -{ - /* initialize the board and startup the kernel */ - board_init(); - /* startup the kernel */ - kernel_init(); -} diff --git a/cpu/atmega256rfr2/Makefile.include b/cpu/atmega256rfr2/Makefile.include index 4e3aa39e06ff..f0142de518c5 100644 --- a/cpu/atmega256rfr2/Makefile.include +++ b/cpu/atmega256rfr2/Makefile.include @@ -1,14 +1,8 @@ # 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/ - -# explicitly tell the linker to link the syscalls and startup code. -# Without this the interrupt vectors will not be linked correctly! -export UNDEF += $(BINDIR)/cpu/startup.o #include periph module USEMODULE += periph # CPU depends on the atmega common module, so include it -include $(ATMEGA_COMMON)Makefile.include +include $(RIOTCPU)/atmega_common/Makefile.include diff --git a/cpu/atmega256rfr2/cpu.c b/cpu/atmega256rfr2/cpu.c deleted file mode 100644 index fa3b7d4e33b9..000000000000 --- a/cpu/atmega256rfr2/cpu.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2017 RWTH Aachen, Josua Arndt - * - * 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_atmega256rfr2 - * @{ - * - * @file - * @brief Implementation of the CPU initialization - * - * @author Steffen Robertz - * @author Josua Arndt - * @} - */ - -#include -#include -#include -#include "cpu.h" -#include "board.h" -#include "periph/init.h" - -#define ENABLE_DEBUG (0) -#include "debug.h" - -/* -* Since this MCU does not feature a software reset, the watchdog timer -* is being used. It will be set to the shortest time and then force a -* reset. Therefore the MCUSR register needs to be resetted as fast as -* possible. In this case in the bootloader already. In order to regain -* information about the reset cause, the MCUSR is copied to r2 beforehand. -* When a software reset was triggered, r3 will contain 0xAA. In order to -* prevent changes to the values from the .init section, r2 and r3 are saved -* in the .init0 section -*/ -uint8_t mcusr_mirror __attribute__((section(".noinit"))); -uint8_t soft_rst __attribute__((section(".noinit"))); -void get_mcusr(void) __attribute__((naked)) __attribute__((section(".init0"))); -void get_mcusr(void) -{ - /* save the reset flags passed from the bootloader */ - __asm__ __volatile__("mov %0, r2\n" : "=r" (mcusr_mirror) :); - __asm__ __volatile__("mov %0, r3\n" : "=r" (soft_rst) :); -} - -void _reset_cause(void) -{ - if (mcusr_mirror & (1 << PORF)) { - DEBUG("Power-on reset.\n"); - } - if (mcusr_mirror & (1 << EXTRF)) { - DEBUG("External reset!\n"); - } - if (mcusr_mirror & (1 << BORF)) { - DEBUG("Brownout reset!\n"); - } - if (mcusr_mirror & (1 << WDRF)) { - if (soft_rst & 0xAA) { - DEBUG("Software reset!\n"); - } else { - DEBUG("Watchdog reset!\n"); - } - } - if (mcusr_mirror & (1 << JTRF)) { - DEBUG("JTAG reset!\n"); - } -} - -void cpu_init(void) -{ - _reset_cause(); - - wdt_reset(); /* should not be nececessary as done in bootloader */ - wdt_disable(); /* but when used without bootloader this is needed */ - - /* Set system clock Prescaler */ - CLKPR = (1 << CLKPCE); /* enable a change to CLKPR */ - /* set the Division factor to 1 results in divisor 2 for internal Oscillator - * So FCPU = 8MHz - * - * Attention! - * The CPU can not be used with the external xtal oscillator if the core - * should be put in sleep while the transceiver is in rx mode. - * - * It seems the as teh peripheral clock divider is set to 1 and this all - * clocks of the timer, etc run with 16MHz increasing power consumption. - * */ - CLKPR = 0; - - /* Initialize peripherals for which modules are included in the makefile.*/ - /* spi_init */ - /* rtc_init */ - /* hwrng_init */ - periph_init(); -} - -/* This is a vector which is aliased to __vector_default, - * the vector executed when an ISR fires with no accompanying - * ISR handler. This may be used along with the ISR() macro to - * create a catch-all for undefined but used ISRs for debugging - * purposes. - * SCIRQS – Symbol Counter Interrupt Status Register - * BATMON – Battery Monitor Control and Status Register - * IRQ_STATUS /1 – Transceiver Interrupt Status Register - * EIFR – External Interrupt Flag Register - * PCIFR – Pin Change Interrupt Flag Register - */ -ISR(BADISR_vect){ - - _reset_cause(); - - printf_P(PSTR("FATAL ERROR: BADISR_vect called, unprocessed Interrupt.\n" - "STOP Execution.\n")); - - printf("IRQ_STATUS %#02x\nIRQ_STATUS1 %#02x\n", - (unsigned int)IRQ_STATUS, (unsigned int)IRQ_STATUS1 ); - - printf("SCIRQS %#02x\nBATMON %#02x\n", (unsigned int)SCIRQS, (unsigned int)BATMON ); - - printf("EIFR %#02x\nPCIFR %#02x\n", (unsigned int)EIFR, (unsigned int)PCIFR ); - - /* White LED light is used to signal ERROR. */ - LED_PORT |= (LED2_MASK | LED1_MASK | LED0_MASK); - - while (1) {} -} - -ISR(BAT_LOW_vect, ISR_BLOCK){ - __enter_isr(); - DEBUG("BAT_LOW \n"); - __exit_isr(); -} diff --git a/cpu/atmega256rfr2/include/cpu_conf.h b/cpu/atmega256rfr2/include/cpu_conf.h deleted file mode 100644 index e7eb3c681e11..000000000000 --- a/cpu/atmega256rfr2/include/cpu_conf.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2017 RWTH Aachen, Josua Arndt - * - * 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_atmega256rfr2 - * @{ - * - * @file - * @brief Implementation specific CPU configuration options - * - * @author Josua Arndt - * @author Steffen Robertz - */ - -#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 - * @{ - */ - -/* keep THREAD_STACKSIZE_IDLE > THREAD_EXTRA_STACKSIZE_PRINTF - * to avoid not printing of debug in interrupts - */ -#define THREAD_EXTRA_STACKSIZE_PRINTF (128) - -#ifndef THREAD_STACKSIZE_DEFAULT -#define THREAD_STACKSIZE_DEFAULT (512) -#endif - -#define THREAD_STACKSIZE_IDLE (129) -#ifdef __cplusplus -} -#endif - -#endif /* CPU_CONF_H */ -/** @} */ diff --git a/cpu/atmega256rfr2/startup.c b/cpu/atmega256rfr2/startup.c deleted file mode 100644 index 98b8cbadbf5c..000000000000 --- a/cpu/atmega256rfr2/startup.c +++ /dev/null @@ -1,72 +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. - */ - -/** - * @ingroup cpu_atmega256rfr2 - * @{ - * - * @file - * @brief Startup code and interrupt vector definition - * - * @author Hinnerk van Bruinehsen - * @author Josua Arndt - * @author Steffen Robertz - * @} - */ - -#include -#include -#include - -/* 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__((section(".init7"))); -void init8_ovr(void) __attribute__((section(".init8"))); - -__attribute__((used, naked)) void init7_ovr(void) -{ - __asm__ ("call reset_handler"); -} - -__attribute__((used, naked)) 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 - */ -__attribute__((used)) void reset_handler(void) -{ - /* initialize the board and startup the kernel */ - board_init(); - /* startup the kernel */ - kernel_init(); -} diff --git a/cpu/atmega328p/Makefile.include b/cpu/atmega328p/Makefile.include index b46d4e871c8f..1f813286cbf4 100644 --- a/cpu/atmega328p/Makefile.include +++ b/cpu/atmega328p/Makefile.include @@ -1,8 +1,5 @@ # 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 +include $(RIOTCPU)/atmega_common/Makefile.include \ No newline at end of file diff --git a/cpu/atmega328p/cpu.c b/cpu/atmega328p/cpu.c deleted file mode 100644 index ed865bd42a56..000000000000 --- a/cpu/atmega328p/cpu.c +++ /dev/null @@ -1,30 +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. - */ - -/** - * @ingroup cpu_atmega328p - * @{ - * - * @file - * @brief Implementation of the CPU initialization - * - * @author Hinnerk van Bruinehsen - * @} - */ - -#include "cpu.h" -#include "periph/init.h" - -/** - * @brief Initialize the CPU, set IRQ priorities - */ -void cpu_init(void) -{ - /* trigger static peripheral initialization */ - periph_init(); -} diff --git a/cpu/atmega328p/include/cpu_conf.h b/cpu/atmega328p/include/cpu_conf.h deleted file mode 100644 index 91ac74da4d81..000000000000 --- a/cpu/atmega328p/include/cpu_conf.h +++ /dev/null @@ -1,50 +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. - */ - -/** - * @ingroup cpu_atmega328p - * @{ - * - * @file - * @brief Implementation specific CPU configuration options - * - * @author Hauke Petersen - * @author Hinnerk van Bruinehsen - */ - -#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 successfully 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) -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* CPU_CONF_H */ -/** @} */ diff --git a/cpu/atmega328p/startup.c b/cpu/atmega328p/startup.c deleted file mode 100644 index 4601dcc43027..000000000000 --- a/cpu/atmega328p/startup.c +++ /dev/null @@ -1,72 +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. - */ - -/** - * @ingroup cpu_atmega328p - * @{ - * - * @file - * @brief Startup code and interrupt vector definition - * - * @author Hinnerk van Bruinehsen - * - * @} - */ - -#include -#include -#include - -/* 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/cpu/atmega_common/Makefile b/cpu/atmega_common/Makefile index 387e91627c45..8f1257b6783d 100644 --- a/cpu/atmega_common/Makefile +++ b/cpu/atmega_common/Makefile @@ -1,5 +1,7 @@ -# define the module that is build +# define the module that is build (not strictly necessary) MODULE = atmega_common + # add a list of subdirectories, that should also be build DIRS = periph + include $(RIOTBASE)/Makefile.base