Merge pull request #9866 from kYc0o/cpu/atmega/reuse_common

cpu/atmega*: factorise common code into atmega_common
This commit is contained in:
ZetaR60 2018-11-04 16:45:18 -05:00 committed by GitHub
commit 8130874a1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
58 changed files with 217 additions and 723 deletions

View File

@ -59,6 +59,20 @@ extern "C" {
#define LED0_TOGGLE (PORTB ^= LED0_MASK)
/** @} */
/**
* @name Usage of LED to turn on when a kernel panic occurs.
* @{
*/
#define LED_PANIC LED0_ON
/** @} */
/**
* @name CPU clock scale for arduino boards
*
*/
#define CPU_ATMEGA_CLK_SCALE_INIT CPU_ATMEGA_CLK_SCALE_DIV1
/** @} */
/**
* @name xtimer configuration values
* @{

View File

@ -73,6 +73,13 @@ extern "C" {
#define LED2_TOGGLE (LED_PORT ^= LED2_MASK)
/** @} */
/**
* @name White LED light is used to signal ERROR.
* @{
*/
#define LED_PANIC (LED_PORT |= LED2_MASK | LED1_MASK | LED0_MASK)
/** @} */
/**
* @name xtimer configuration values
* @{
@ -83,6 +90,40 @@ extern "C" {
#define XTIMER_HZ (125000UL)
/** @} */
/**
* @name Indicate Watchdog cleared in bootloader an
*
* AVR CPUs need to reset the Watchdog as fast as possible.
* This flag indicates that the watchdog is reseted in the bootloader
* and that the MCUSR value is stored in register 2 (r2)
* @{
*/
#define BOOTLOADER_CLEARS_WATCHDOG_AND_PASSES_MCUSR 1
/** @} */
/**
* @name Indicate Watchdog cleared in bootloader an
*
* AVR CPUs need to reset the Watchdog as fast as possible.
* This flag indicates that the watchdog is reseted in the bootloader
* and that the MCUSR value is stored in register 2 (r2)
* @{
*/
#define BOOTLOADER_CLEARS_WATCHDOG_AND_PASSES_MCUSR 1
/** @} */
/**
* @name CPU clock scale for jiminy-megarfr256rfr2
*
* 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.
*/
#define CPU_ATMEGA_CLK_SCALE_INIT CPU_ATMEGA_CLK_SCALE_DIV1
/** @} */
/**
* @brief Initialize board specific hardware, including clock, LEDs and std-IO
*/

View File

@ -90,6 +90,13 @@ extern "C" {
#define LED3_TOGGLE PORTB ^= LED3_PIN
/** @} */
/**
* @name Usage of LED to turn on when a kernel panic occurs.
* @{
*/
#define LED_PANIC LED1_ON
/** @} */
/**
* @name Button pin configuration
* @{
@ -111,6 +118,13 @@ extern "C" {
#define FILTER_OUTPUT GPIO_PIN(PORT_A, 7)
/** @} */
/**
* @name CPU clock scale for mega-xplained
*
*/
#define CPU_ATMEGA_CLK_SCALE_INIT CPU_ATMEGA_CLK_SCALE_DIV1
/** @} */
/**
* @brief Initialize board specific hardware, including clock, LEDs and std-IO
*/

View File

@ -78,6 +78,13 @@ extern "C" {
#define LED_RED_TOGGLE LED0_TOGGLE
/** @} */
/**
* @name Usage of LED to turn on when a kernel panic occurs.
* @{
*/
#define LED_PANIC LED_RED_ON
/** @} */
/**
* @name Macros for controlling the on-board MUXes.
* @{
@ -143,6 +150,13 @@ extern "C" {
MUX_USB_XBEE_ON
/** @} */
/**
* @name CPU clock scale for waspmote-pro
*
*/
#define CPU_ATMEGA_CLK_SCALE_INIT CPU_ATMEGA_CLK_SCALE_DIV1
/** @} */
/**
* @name xtimer configuration values
* @{

View File

@ -1,5 +1,7 @@
# define the module that is build
MODULE = cpu
# add a list of subdirectories, that should also be build
DIRS = $(ATMEGA_COMMON)
DIRS = $(RIOTCPU)/atmega_common/
include $(RIOTBASE)/Makefile.base

View File

@ -1,15 +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
RAM_LEN = 8K
ROM_LEN = 128K
# CPU depends on the atmega common module, so include it
include $(ATMEGA_COMMON)Makefile.include
include $(RIOTCPU)/atmega_common/Makefile.include

View File

@ -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 <h.v.bruinehsen@fu-berlin.de>
* @}
*/
#include "cpu.h"
#include "periph/init.h"
/**
* @brief Initialize the CPU, set IRQ priorities
*/
void cpu_init(void)
{
/* trigger static peripheral initialization */
periph_init();
}

View File

@ -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 <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 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 */
/** @} */

View File

@ -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 <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();
}

View File

@ -1,6 +1,7 @@
# define the module that is build
MODULE = cpu
# add a list of subdirectories, that should also be build
DIRS = $(ATMEGA_COMMON)
DIRS = $(RIOTCPU)/atmega_common/
include $(RIOTBASE)/Makefile.base

View File

@ -1,11 +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/
RAM_LEN = 16K
ROM_LEN = 128K
# CPU depends on the atmega common module, so include it
include $(ATMEGA_COMMON)Makefile.include
include $(RIOTCPU)/atmega_common/Makefile.include

View File

@ -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 <h.v.bruinehsen@fu-berlin.de>
* @author Matthew Blue <matthew.blue.neuro@gmail.com>
* @}
*/
#include "cpu.h"
#include "periph/init.h"
/**
* @brief Initialize the CPU, set IRQ priorities
*/
void cpu_init(void)
{
/* trigger static peripheral initialization */
periph_init();
}

View File

@ -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 <h.v.bruinehsen@fu-berlin.de>
* @author Matthew Blue <matthew.blue.neuro@gmail.com>
*
* @}
*/
#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();
}

View File

@ -1,5 +1,7 @@
# define the module that is build
MODULE = cpu
# add a list of subdirectories, that should also be build
DIRS = $(ATMEGA_COMMON)
DIRS = $(RIOTCPU)/atmega_common/
include $(RIOTBASE)/Makefile.base

View File

@ -1,15 +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
RAM_LEN = 8K
ROM_LEN = 256K
# CPU depends on the atmega common module, so include it
include $(ATMEGA_COMMON)Makefile.include
include $(RIOTCPU)/atmega_common/Makefile.include

View File

@ -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 <h.v.bruinehsen@fu-berlin.de>
* @}
*/
#include "cpu.h"
#include "periph/init.h"
/**
* @brief Initialize the CPU, set IRQ priorities
*/
void cpu_init(void)
{
/* trigger static peripheral initialization */
periph_init();
}

View File

@ -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 <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 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 */
/** @} */

View File

@ -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 <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__((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();
}

View File

@ -1,5 +1,7 @@
# define the module that is build
MODULE = cpu
# add a list of subdirectories, that should also be build
DIRS = periph $(ATMEGA_COMMON)
DIRS = periph $(RIOTCPU)/atmega_common/
include $(RIOTBASE)/Makefile.base

View File

@ -1,11 +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
#include periph module
USEMODULE += periph
@ -14,4 +8,4 @@ RAM_LEN = 32K
ROM_LEN = 256K
# CPU depends on the atmega common module, so include it
include $(ATMEGA_COMMON)Makefile.include
include $(RIOTCPU)/atmega_common/Makefile.include

View File

@ -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 <jarndt@ias.rwth-aachen.de>
* @author Steffen Robertz <steffen.robertz@rwth-aachen.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
* @{
*/
/* 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 */
/** @} */

View File

@ -1,6 +1,7 @@
# define the module that is build
MODULE = cpu
# add a list of subdirectories, that should also be build
DIRS = $(ATMEGA_COMMON)
DIRS = $(RIOTCPU)/atmega_common/
include $(RIOTBASE)/Makefile.base

View File

@ -1,11 +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/
RAM_LEN = 2K
ROM_LEN = 32K
# CPU depends on the atmega common module, so include it
include $(ATMEGA_COMMON)Makefile.include
include $(RIOTCPU)/atmega_common/Makefile.include

View File

@ -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 <h.v.bruinehsen@fu-berlin.de>
* @}
*/
#include "cpu.h"
#include "periph/init.h"
/**
* @brief Initialize the CPU, set IRQ priorities
*/
void cpu_init(void)
{
/* trigger static peripheral initialization */
periph_init();
}

View File

@ -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 <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 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 */
/** @} */

View File

@ -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 <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();
}

View File

@ -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

View File

@ -1,5 +1,7 @@
/*
* Copyright (C) 2017 RWTH Aachen, Josua Arndt
* Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen
* 2017 RWTH Aachen, Josua Arndt
* 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
@ -7,45 +9,68 @@
*/
/**
* @ingroup cpu_atmega256rfr2
* @ingroup cpu_atmega_common
* @{
*
* @file
* @brief Implementation of the CPU initialization
*
* @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
* @author Steffen Robertz <steffen.robertz@rwth-aachen.de>
* @author Josua Arndt <jarndt@ias.rwth-aachen.de>
* @author Matthew Blue <matthew.blue.neuro@gmail.com>
* @author Francisco Acosta <francisco.acosta@inria.fr>
* @}
*/
#include <avr/io.h>
#include <avr/wdt.h>
#include <avr/pgmspace.h>
#include "cpu.h"
#include "board.h"
#include "periph/init.h"
#include "panic.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
/*
* Since this MCU does not feature a software reset, the watchdog timer
* Since atmega MCUs do 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
* possible.
* Which means in the bootloader or in the following init0 if no bootloader is used.
* Bootloader resets watchdog and pass MCUSR in r2 (e.g. Optiboot) in order to pass
* information about the reset cause to the application.
* When no Bootloader is used the watchdog will be disabled in the init0 section.
* When a software reset was triggered, r3 will contain 0xAA.
* In order to prevent changes to the values from the .init section, MCUSR 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 soft reset flag set in reset routine */
__asm__ __volatile__("mov %0, r3\n" : "=r" (soft_rst) :);
#ifdef BOOTLOADER_CLEARS_WATCHDOG_AND_PASSES_MCUSR
/* 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) :);
#else
/* save the reset flags */
#ifdef MCUCSR
mcusr_mirror = MCUCSR;
MCUSR = 0;
#else
mcusr_mirror = MCUSR;
MCUSR = 0;
#endif
wdt_disable();
#endif
}
void _reset_cause(void)
@ -66,9 +91,11 @@ void _reset_cause(void)
DEBUG("Watchdog reset!\n");
}
}
#if !defined (CPU_ATMEGA328P)
if (mcusr_mirror & (1 << JTRF)) {
DEBUG("JTAG reset!\n");
}
#endif
}
void cpu_init(void)
@ -78,20 +105,6 @@ void cpu_init(void)
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 */
@ -110,28 +123,32 @@ void cpu_init(void)
* EIFR External Interrupt Flag Register
* PCIFR Pin Change Interrupt Flag Register
*/
ISR(BADISR_vect){
ISR(BADISR_vect)
{
_reset_cause();
printf_P(PSTR("FATAL ERROR: BADISR_vect called, unprocessed Interrupt.\n"
"STOP Execution.\n"));
#if defined (CPU_ATMEGA256RFR2)
printf("IRQ_STATUS %#02x\nIRQ_STATUS1 %#02x\n",
(unsigned int)IRQ_STATUS, (unsigned int)IRQ_STATUS1 );
(unsigned int)IRQ_STATUS, (unsigned int)IRQ_STATUS1);
printf("SCIRQS %#02x\nBATMON %#02x\n", (unsigned int)SCIRQS, (unsigned int)BATMON );
printf("SCIRQS %#02x\nBATMON %#02x\n", (unsigned int)SCIRQS, (unsigned int)BATMON);
printf("EIFR %#02x\nPCIFR %#02x\n", (unsigned int)EIFR, (unsigned int)PCIFR );
printf("EIFR %#02x\nPCIFR %#02x\n", (unsigned int)EIFR, (unsigned int)PCIFR);
#endif
#ifdef LED_PANIC
/* Use LED light to signal ERROR. */
LED_PANIC;
#endif
/* White LED light is used to signal ERROR. */
LED_PORT |= (LED2_MASK | LED1_MASK | LED0_MASK);
while (1) {}
core_panic(PANIC_GENERAL_ERROR, PSTR("FATAL ERROR: BADISR_vect called, unprocessed Interrupt.\n"
"STOP Execution.\n"));
}
ISR(BAT_LOW_vect, ISR_BLOCK){
#if defined (CPU_ATMEGA256RFR2)
ISR(BAT_LOW_vect, ISR_BLOCK)
{
__enter_isr();
DEBUG("BAT_LOW \n");
DEBUG("BAT_LOW\n");
__exit_isr();
}
#endif

View File

@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen
* 2017 RWTH Aachen, Josua Arndt
* 2018 Matthew Blue
*
* This file is subject to the terms and conditions of the GNU Lesser
@ -8,7 +9,7 @@
*/
/**
* @ingroup cpu_atmega1284p
* @ingroup cpu_atmega_common
* @{
*
* @file
@ -16,6 +17,8 @@
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
* @author Josua Arndt <jarndt@ias.rwth-aachen.de>
* @author Steffen Robertz <steffen.robertz@rwth-aachen.de>
* @author Matthew Blue <matthew.blue.neuro@gmail.com>
*/
@ -28,19 +31,23 @@
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)
/**
* @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.
* @{
*/
#ifndef THREAD_STACKSIZE_DEFAULT
#define THREAD_STACKSIZE_DEFAULT (256)
#define THREAD_STACKSIZE_DEFAULT (512)
#endif
/* keep THREAD_STACKSIZE_IDLE > THREAD_EXTRA_STACKSIZE_PRINTF
* to avoid not printing of debug in interrupts
*/
#define THREAD_STACKSIZE_IDLE (128)
/** @} */
@ -48,5 +55,6 @@ extern "C" {
}
#endif
#endif /* CPU_CONF_H */
/** @} */

View File

@ -30,14 +30,12 @@
void pm_reboot(void)
{
#if defined(CPU_ATMEGA256RFR2)
/* clear MCU Status Register Interrupt flags */
MCUSR = 0x00;
/* Softreset recognition feature, "r3" will be read out in .init0
* to be able to distinguish WDT reset and WDT software reset
*/
__asm__ __volatile__("mov r3, %0\n" :: "r" (0xAA));
#endif /* CPU_ATMEGA256RFR2 */
/*
* Since the AVR doesn't support a real software reset, we set the Watchdog

View File

@ -7,7 +7,7 @@
*/
/**
* @ingroup cpu_atmega256rfr2
* @ingroup cpu_atmega_common
* @{
*
* @file

View File

@ -11,7 +11,7 @@ BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-mega2560 arduino-uno \
chronos hifive1 msb-430 msb-430h nucleo-f030r8 \
nucleo-l053r8 nucleo-f031k6 nucleo-f042k6 \
nucleo-f303k8 nucleo-f334r8 nucleo-l031k6 \
stm32f0discovery telosb waspmote-pro \
mega-xplained stm32f0discovery telosb waspmote-pro \
wsn430-v1_3b wsn430-v1_4 z1
# Enable GNRC networking

View File

@ -4,7 +4,8 @@ APPLICATION = ipc_pingpong
# If no BOARD is found in the environment, use this default:
BOARD ?= native
BOARD_INSUFFICIENT_MEMORY := nucleo-f031k6
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno nucleo-f031k6 \
# This has to be the absolute path to the RIOT base directory:
RIOTBASE ?= $(CURDIR)/../..

View File

@ -1,5 +1,7 @@
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno
# Modules that will have an impact on the size of the TCB (thread_t):
#
# disabled by default, enable on demand:

View File

@ -1,5 +1,7 @@
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno
# include and auto-initialize all available sensors
USEMODULE += saul_default
# include driver for bmx055 sensor

View File

@ -3,7 +3,7 @@ include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-mega2560 arduino-uno \
msb-430 msb-430h nucleo-f334r8 nucleo-l053r8 \
nucleo-f031k6 nucleo-f042k6 nucleo-f303k8 \
nucleo-l031k6 stm32f0discovery telosb \
nucleo-l031k6 mega-xplained stm32f0discovery telosb \
waspmote-pro wsn430-v1_3b wsn430-v1_4 z1
USEMODULE += auto_init_gnrc_netif

View File

@ -1,5 +1,7 @@
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno
USEMODULE += mpu9150
USEMODULE += xtimer

View File

@ -1,5 +1,7 @@
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno
USEMODULE += nvram_spi
USEMODULE += xtimer

View File

@ -1,6 +1,6 @@
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := nucleo-f031k6
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno nucleo-f031k6
USEMODULE += pir

View File

@ -1,5 +1,7 @@
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno
USEMODULE += tsl4531x
USEMODULE += xtimer

View File

@ -2,7 +2,7 @@ include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno nucleo-f031k6 \
nucleo-f042k6 nucleo-f030r8 nucleo-f334r8 \
stm32f0discovery
stm32f0discovery waspmote-pro
USEMODULE += xbee
USEMODULE += gnrc_txtsnd

View File

@ -6,10 +6,10 @@ include ../Makefile.tests_common
BOARD_BLACKLIST := msb-430 msb-430h pic32-clicker pic32-wifire \
telosb wsn430-v1_3b wsn430-v1_4 z1
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno \
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-mega2560 arduino-uno \
msb-430 msb-430h nucleo-l031k6 nucleo-f031k6 \
nucleo-f042k6 nucleo-l053r8 stm32f0discovery \
telosb wsn430-v1_3b wsn430-v1_4 z1
telosb waspmote-pro wsn430-v1_3b wsn430-v1_4 z1
USEPKG += emb6

View File

@ -1,6 +1,7 @@
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := nucleo-f031k6 nucleo-f042k6
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno nucleo-f031k6 \
nucleo-f042k6
USEMODULE += evtimer

View File

@ -1,6 +1,7 @@
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := nucleo-f031k6 nucleo-f042k6
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno nucleo-f031k6 \
nucleo-f042k6
USEMODULE += evtimer

View File

@ -1,8 +1,8 @@
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno \
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-mega2560 arduino-uno \
chronos nucleo-f031k6 nucleo-f042k6 nucleo-l031k6 \
telosb wsn430-v1_3b wsn430-v1_4
telosb waspmote-pro wsn430-v1_3b wsn430-v1_4
USEMODULE += gnrc_ipv6
USEMODULE += gnrc_ipv6_nib

View File

@ -1,7 +1,8 @@
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno \
chronos nucleo-f031k6 nucleo-f042k6 nucleo-l031k6
chronos nucleo-f031k6 nucleo-f042k6 nucleo-l031k6 \
waspmote-pro
USEMODULE += gnrc_sock_check_reuse
USEMODULE += gnrc_sock_udp

View File

@ -1,6 +1,6 @@
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := nucleo-f031k6
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno nucleo-f031k6
USEMODULE += auto_init
USEMODULE += xtimer

View File

@ -1,7 +1,7 @@
APPLICATION = isr_yield_higher
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := nucleo-f031k6
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno nucleo-f031k6
USEMODULE += xtimer

View File

@ -1,6 +1,6 @@
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := nucleo-f031k6
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno nucleo-f031k6
TEST_ON_CI_WHITELIST += all

View File

@ -3,6 +3,8 @@ include ../Makefile.tests_common
FEATURES_REQUIRED += periph_eeprom
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno
USEMODULE += shell
USEMODULE += shell_commands # provides reboot command

View File

@ -2,7 +2,7 @@ include ../Makefile.tests_common
#malloc.h not found
BOARD_BLACKLIST := jiminy-mega256rfr2 mega-xplained
BOARD_INSUFFICIENT_MEMORY := nucleo-f031k6
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno nucleo-f031k6
USEMODULE += pipe

View File

@ -1,6 +1,6 @@
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := nucleo-f031k6
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno nucleo-f031k6
TEST_ON_CI_WHITELIST += all

View File

@ -2,6 +2,8 @@ include ../Makefile.tests_common
DISABLE_MODULE += auto_init
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno
USEMODULE += shell
USEMODULE += timex

View File

@ -1,6 +1,6 @@
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := nucleo-f031k6
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno nucleo-f031k6
DISABLE_MODULE += auto_init

View File

@ -1,6 +1,6 @@
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := nucleo-f031k6
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno nucleo-f031k6
USEMODULE += core_thread_flags
USEMODULE += xtimer

View File

@ -2,6 +2,8 @@ include ../Makefile.tests_common
DISABLE_MODULE += auto_init
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno
TEST_ON_CI_WHITELIST += all
include $(RIOTBASE)/Makefile.include

View File

@ -1,6 +1,6 @@
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := nucleo-f031k6
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno nucleo-f031k6
USEMODULE += xtimer

View File

@ -1,6 +1,6 @@
include ../Makefile.tests_common
BOARD_INSUFFICIENT_MEMORY := nucleo-f031k6
BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-uno nucleo-f031k6
USEMODULE += xtimer