From 4d68dd5aeaa9c386a7f75e2dedd310a058c4f28b Mon Sep 17 00:00:00 2001 From: Gerson Fernando Budke Date: Sat, 2 Jan 2021 11:30:51 -0300 Subject: [PATCH 1/4] cpu/atmega_common: Extract clock definitions Refactor clock definitions from cpu.h to clock.h. Signed-off-by: Gerson Fernando Budke --- cpu/atmega_common/include/cpu.h | 32 +---------- cpu/atmega_common/include/cpu_clock.h | 78 +++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 31 deletions(-) create mode 100644 cpu/atmega_common/include/cpu_clock.h diff --git a/cpu/atmega_common/include/cpu.h b/cpu/atmega_common/include/cpu.h index aed9667f02..b933251759 100644 --- a/cpu/atmega_common/include/cpu.h +++ b/cpu/atmega_common/include/cpu.h @@ -35,6 +35,7 @@ #include #include "cpu_conf.h" +#include "cpu_clock.h" #include "sched.h" #include "thread.h" @@ -168,37 +169,6 @@ static inline void __attribute__((always_inline)) cpu_print_last_instruction(voi printf("Stack Pointer: 0x%04x\n", ptr); } -/** - * @brief ATmega system clock prescaler settings - * - * Some CPUs may not support the highest prescaler settings - */ -enum { - CPU_ATMEGA_CLK_SCALE_DIV1 = 0, - CPU_ATMEGA_CLK_SCALE_DIV2 = 1, - CPU_ATMEGA_CLK_SCALE_DIV4 = 2, - CPU_ATMEGA_CLK_SCALE_DIV8 = 3, - CPU_ATMEGA_CLK_SCALE_DIV16 = 4, - CPU_ATMEGA_CLK_SCALE_DIV32 = 5, - CPU_ATMEGA_CLK_SCALE_DIV64 = 6, - CPU_ATMEGA_CLK_SCALE_DIV128 = 7, - CPU_ATMEGA_CLK_SCALE_DIV256 = 8, - CPU_ATMEGA_CLK_SCALE_DIV512 = 9, -}; - -/** - * @brief Initializes system clock prescaler - */ -static inline void atmega_set_prescaler(uint8_t clk_scale) -{ - /* Enable clock change */ - /* Must be assignment to set all other bits to zero, see datasheet */ - CLKPR = (1 << CLKPCE); - - /* Write clock within 4 cycles */ - CLKPR = clk_scale; -} - /** * @brief Initializes avrlibc stdio */ diff --git a/cpu/atmega_common/include/cpu_clock.h b/cpu/atmega_common/include/cpu_clock.h new file mode 100644 index 0000000000..797f6107ea --- /dev/null +++ b/cpu/atmega_common/include/cpu_clock.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2015 Kaspar Schleiser + * 2014 Freie Universität Berlin, Hinnerk van Bruinehsen + * 2018 RWTH Aachen, Josua Arndt + * 2021 Gerson Fernando Budke + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup cpu_atmega_common + * @brief Common clock support for ATmega family based micro-controllers + * @{ + * + * @file + * @brief Basic definitions for the ATmega common clock + * + * When ever you want to do something hardware related, that is accessing MCUs registers directly, + * just include this file. It will then make sure that the MCU specific headers are included. + * + * @author Stefan Pfeiffer + * @author Hauke Petersen + * @author Hinnerk van Bruinehsen + * @author Kaspar Schleiser + * @author Josua Arndt + * @author Gerson Fernando Budke + * + */ + +#ifndef CPU_CLOCK_H +#define CPU_CLOCK_H + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** + * @brief ATmega system clock prescaler settings + * + * Some CPUs may not support the highest prescaler settings + */ +enum { + CPU_ATMEGA_CLK_SCALE_DIV1 = 0, + CPU_ATMEGA_CLK_SCALE_DIV2 = 1, + CPU_ATMEGA_CLK_SCALE_DIV4 = 2, + CPU_ATMEGA_CLK_SCALE_DIV8 = 3, + CPU_ATMEGA_CLK_SCALE_DIV16 = 4, + CPU_ATMEGA_CLK_SCALE_DIV32 = 5, + CPU_ATMEGA_CLK_SCALE_DIV64 = 6, + CPU_ATMEGA_CLK_SCALE_DIV128 = 7, + CPU_ATMEGA_CLK_SCALE_DIV256 = 8, + CPU_ATMEGA_CLK_SCALE_DIV512 = 9, +}; + +/** + * @brief Initializes system clock prescaler + */ +static inline void atmega_set_prescaler(uint8_t clk_scale) +{ + /* Enable clock change */ + /* Must be assignment to set all other bits to zero, see datasheet */ + CLKPR = (1 << CLKPCE); + + /* Write clock within 4 cycles */ + CLKPR = clk_scale; +} + +#ifdef __cplusplus +} +#endif + +#endif /* CPU_CLOCK_H */ +/** @} */ From a0028a9ff8008a1f6539119e62282ceaaafcf778 Mon Sep 17 00:00:00 2001 From: Gerson Fernando Budke Date: Sat, 2 Jan 2021 11:36:29 -0300 Subject: [PATCH 2/4] cpu/atmega_common: Split cpu.c into atmega_cpu/cpu.c Split cpu.c file into cpu.c and atmega_cpu.c files. This extract mega specific code from common code. Signed-off-by: Gerson Fernando Budke --- cpu/atmega_common/atmega_cpu.c | 104 ++++++++++++++++++++++++++++++++ cpu/atmega_common/cpu.c | 68 +-------------------- cpu/atmega_common/include/cpu.h | 5 ++ 3 files changed, 110 insertions(+), 67 deletions(-) create mode 100644 cpu/atmega_common/atmega_cpu.c diff --git a/cpu/atmega_common/atmega_cpu.c b/cpu/atmega_common/atmega_cpu.c new file mode 100644 index 0000000000..d4fcf5c5d4 --- /dev/null +++ b/cpu/atmega_common/atmega_cpu.c @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen + * 2017 RWTH Aachen, Josua Arndt + * 2018 Matthew Blue + * 2021 Gerson Fernando Budke + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup cpu_atmega_common + * @{ + * + * @file + * @brief Implementation of the CPU initialization + * + * @author Hinnerk van Bruinehsen + * @author Steffen Robertz + * @author Josua Arndt + * @author Matthew Blue + * @author Francisco Acosta + * @author Gerson Fernando Budke + * + * @} + */ + +#include + +#include "cpu.h" +#include "panic.h" + +#define ENABLE_DEBUG 0 +#include "debug.h" + +extern uint8_t mcusr_mirror; +extern uint8_t soft_rst; + +void atmega_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 !defined (CPU_ATMEGA328P) + if (mcusr_mirror & (1 << JTRF)) { + DEBUG("JTAG reset!\n"); + } +#endif +} + +/* 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) +{ + atmega_reset_cause(); + +#if defined (CPU_ATMEGA256RFR2) + 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); +#endif +#ifdef LED_PANIC + /* Use LED light to signal ERROR. */ + LED_PANIC; +#endif + + core_panic(PANIC_GENERAL_ERROR, PSTR("FATAL ERROR: BADISR_vect called, unprocessed Interrupt.\n" + "STOP Execution.\n")); +} + +#if defined(CPU_ATMEGA128RFA1) || defined (CPU_ATMEGA256RFR2) +ISR(BAT_LOW_vect, ISR_BLOCK) +{ + atmega_enter_isr(); + DEBUG("BAT_LOW\n"); + atmega_exit_isr(); +} +#endif diff --git a/cpu/atmega_common/cpu.c b/cpu/atmega_common/cpu.c index d629ea56e8..592d9658e0 100644 --- a/cpu/atmega_common/cpu.c +++ b/cpu/atmega_common/cpu.c @@ -76,34 +76,9 @@ void get_mcusr(void) #endif } -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 !defined (CPU_ATMEGA328P) - if (mcusr_mirror & (1 << JTRF)) { - DEBUG("JTAG reset!\n"); - } -#endif -} - void cpu_init(void) { - _reset_cause(); + atmega_reset_cause(); wdt_reset(); /* should not be nececessary as done in bootloader */ wdt_disable(); /* but when used without bootloader this is needed */ @@ -140,44 +115,3 @@ void heap_stats(void) printf("heap: %d (used %d, free %d) [bytes]\n", heap_size, heap_size - free, free); } - -/* 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(); - -#if defined (CPU_ATMEGA256RFR2) - 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); -#endif -#ifdef LED_PANIC - /* Use LED light to signal ERROR. */ - LED_PANIC; -#endif - - core_panic(PANIC_GENERAL_ERROR, PSTR("FATAL ERROR: BADISR_vect called, unprocessed Interrupt.\n" - "STOP Execution.\n")); -} - -#if defined(CPU_ATMEGA128RFA1) || defined (CPU_ATMEGA256RFR2) -ISR(BAT_LOW_vect, ISR_BLOCK) -{ - atmega_enter_isr(); - DEBUG("BAT_LOW\n"); - atmega_exit_isr(); -} -#endif diff --git a/cpu/atmega_common/include/cpu.h b/cpu/atmega_common/include/cpu.h index b933251759..7f6214d421 100644 --- a/cpu/atmega_common/include/cpu.h +++ b/cpu/atmega_common/include/cpu.h @@ -174,6 +174,11 @@ static inline void __attribute__((always_inline)) cpu_print_last_instruction(voi */ void atmega_stdio_init(void); +/** + * @brief Print reset cause + */ +void atmega_reset_cause(void); + #ifdef __cplusplus } #endif From 4cbd311196273cd88b8c144ba89b341d472c9247 Mon Sep 17 00:00:00 2001 From: Gerson Fernando Budke Date: Sat, 2 Jan 2021 12:36:20 -0300 Subject: [PATCH 3/4] cpu: Refact atmega_common into avr8_common Split atmega_common code into avr8_common folder. This moves common avr8 code to be used for all avr8 variants: tiny, mega and xmega. Signed-off-by: Gerson Fernando Budke --- cpu/atmega_common/Kconfig | 22 ++------------- cpu/atmega_common/Makefile | 2 +- cpu/atmega_common/Makefile.dep | 18 +----------- cpu/atmega_common/Makefile.features | 8 ++++-- cpu/atmega_common/Makefile.include | 7 ++--- cpu/avr8_common/Kconfig | 28 +++++++++++++++++++ cpu/avr8_common/Makefile | 7 +++++ cpu/avr8_common/Makefile.dep | 20 +++++++++++++ cpu/avr8_common/Makefile.features | 3 ++ cpu/avr8_common/Makefile.include | 6 ++++ .../cpu.c => avr8_common/avr8_cpu.c} | 0 .../avr_libc_extra/Makefile | 0 .../avr_libc_extra/avr8_stdio.c} | 0 .../avr_libc_extra/include/errno.h | 0 .../avr_libc_extra/include/inttypes.h | 0 .../avr_libc_extra/include/sys/time.h | 0 .../avr_libc_extra/include/sys/types.h | 0 .../avr_libc_extra/include/unistd.h | 0 .../avr_libc_extra/include/vendor/sys/stat.h | 0 .../avr_libc_extra/include/vendor/time.h | 0 .../avr_libc_extra/posix_unistd.c | 0 cpu/avr8_common/doc.txt | 5 ++++ .../include/architecture_arch.h | 0 .../include/atomic_utils_arch.h | 0 .../include/c11_atomics_compat_cpu.hpp | 0 .../include/cpu.h | 0 .../include/irq_arch.h | 0 cpu/{atmega_common => avr8_common}/startup.c | 0 .../thread_arch.c | 0 29 files changed, 81 insertions(+), 45 deletions(-) create mode 100644 cpu/avr8_common/Kconfig create mode 100644 cpu/avr8_common/Makefile create mode 100644 cpu/avr8_common/Makefile.dep create mode 100644 cpu/avr8_common/Makefile.features create mode 100644 cpu/avr8_common/Makefile.include rename cpu/{atmega_common/cpu.c => avr8_common/avr8_cpu.c} (100%) rename cpu/{atmega_common => avr8_common}/avr_libc_extra/Makefile (100%) rename cpu/{atmega_common/avr_libc_extra/atmega_stdio.c => avr8_common/avr_libc_extra/avr8_stdio.c} (100%) rename cpu/{atmega_common => avr8_common}/avr_libc_extra/include/errno.h (100%) rename cpu/{atmega_common => avr8_common}/avr_libc_extra/include/inttypes.h (100%) rename cpu/{atmega_common => avr8_common}/avr_libc_extra/include/sys/time.h (100%) rename cpu/{atmega_common => avr8_common}/avr_libc_extra/include/sys/types.h (100%) rename cpu/{atmega_common => avr8_common}/avr_libc_extra/include/unistd.h (100%) rename cpu/{atmega_common => avr8_common}/avr_libc_extra/include/vendor/sys/stat.h (100%) rename cpu/{atmega_common => avr8_common}/avr_libc_extra/include/vendor/time.h (100%) rename cpu/{atmega_common => avr8_common}/avr_libc_extra/posix_unistd.c (100%) create mode 100644 cpu/avr8_common/doc.txt rename cpu/{atmega_common => avr8_common}/include/architecture_arch.h (100%) rename cpu/{atmega_common => avr8_common}/include/atomic_utils_arch.h (100%) rename cpu/{atmega_common => avr8_common}/include/c11_atomics_compat_cpu.hpp (100%) rename cpu/{atmega_common => avr8_common}/include/cpu.h (100%) rename cpu/{atmega_common => avr8_common}/include/irq_arch.h (100%) rename cpu/{atmega_common => avr8_common}/startup.c (100%) rename cpu/{atmega_common => avr8_common}/thread_arch.c (100%) diff --git a/cpu/atmega_common/Kconfig b/cpu/atmega_common/Kconfig index fca23e122b..0d9261b538 100644 --- a/cpu/atmega_common/Kconfig +++ b/cpu/atmega_common/Kconfig @@ -4,15 +4,6 @@ # General Public License v2.1. See the file LICENSE in the top level # directory for more details. # -config CPU_ARCH_AVR8 - bool - select HAS_ARCH_8BIT - select HAS_ARCH_AVR8 - -config CPU_CORE_AVR - bool - select CPU_ARCH_AVR8 - config CPU_COMMON_ATMEGA bool select CPU_CORE_AVR @@ -34,21 +25,10 @@ config CPU_FAM_ATMEGA128 select CPU_CORE_AVR ## Common CPU symbols -config CPU_ARCH - default "avr8" if CPU_ARCH_AVR8 - -config CPU_CORE - default "avr" if CPU_CORE_AVR - config CPU_FAM default "atmega128" if CPU_FAM_ATMEGA128 ## Declaration of specific features -config HAS_ARCH_AVR8 - bool - help - Indicates that the current architecture is Atmel AVR8. - config HAS_ATMEGA_PCINT0 bool help @@ -72,3 +52,5 @@ config HAS_ATMEGA_PCINT3 config ERROR_MODULES_CONFLICT default "On ATmega, the RTC and RTT use to the same hardware timer." if MODULE_PERIPH_RTC && MODULE_PERIPH_RTT depends on CPU_COMMON_ATMEGA + +source "$(RIOTCPU)/avr8_common/Kconfig" diff --git a/cpu/atmega_common/Makefile b/cpu/atmega_common/Makefile index 41d51c7b31..78d22b6460 100644 --- a/cpu/atmega_common/Makefile +++ b/cpu/atmega_common/Makefile @@ -2,6 +2,6 @@ MODULE = atmega_common # add a list of subdirectories, that should also be build -DIRS = periph avr_libc_extra +DIRS = periph $(RIOTCPU)/avr8_common/ include $(RIOTBASE)/Makefile.base diff --git a/cpu/atmega_common/Makefile.dep b/cpu/atmega_common/Makefile.dep index 64fc150a79..ed89302b43 100644 --- a/cpu/atmega_common/Makefile.dep +++ b/cpu/atmega_common/Makefile.dep @@ -1,22 +1,9 @@ -# avr libc needs some RIOT-specific support code -USEMODULE += avr_libc_extra - # tell the build system to build the atmega common files USEMODULE += atmega_common # peripheral drivers are linked into the final binary USEMODULE += atmega_common_periph -# The AVR-libc provides no thread safe malloc implementation and has no hooks -# to inject. Use malloc_thread_safe to link calls to malloc to safe wrappers -# instead. -USEMODULE += malloc_thread_safe - -# the atmel port uses stdio_uart by default -ifeq (,$(filter stdio_% slipdev_stdio,$(USEMODULE))) - USEMODULE += stdio_uart -endif - # expand atmega_pcint module ifneq (,$(filter atmega_pcint,$(USEMODULE))) USEMODULE += atmega_pcint0 @@ -42,7 +29,4 @@ ifneq (,$(filter atmega_pcint3,$(USEMODULE))) FEATURES_REQUIRED += atmega_pcint3 endif -# static C++ constructors need guards for thread safe initialization -ifneq (,$(filter cpp,$(FEATURES_USED))) - USEMODULE += cxx_ctor_guards -endif +include $(RIOTCPU)/avr8_common/Makefile.dep diff --git a/cpu/atmega_common/Makefile.features b/cpu/atmega_common/Makefile.features index 489c684bf3..a2d93c21ae 100644 --- a/cpu/atmega_common/Makefile.features +++ b/cpu/atmega_common/Makefile.features @@ -1,7 +1,9 @@ -FEATURES_PROVIDED += arch_8bit -FEATURES_PROVIDED += arch_avr8 +include $(RIOTCPU)/avr8_common/Makefile.features + +# common feature are defined in avr8_common/Makefile.features +# Only add Additional features + FEATURES_PROVIDED += atmega_pcint0 -FEATURES_PROVIDED += cpp FEATURES_PROVIDED += periph_cpuid FEATURES_PROVIDED += periph_eeprom FEATURES_PROVIDED += periph_gpio periph_gpio_irq diff --git a/cpu/atmega_common/Makefile.include b/cpu/atmega_common/Makefile.include index b51f67520c..f7ca50d429 100644 --- a/cpu/atmega_common/Makefile.include +++ b/cpu/atmega_common/Makefile.include @@ -1,9 +1,8 @@ # include module specific includes -INCLUDES += -I$(RIOTCPU)/atmega_common/include \ - -isystem$(RIOTCPU)/atmega_common/avr_libc_extra/include \ - -isystem$(RIOTCPU)/atmega_common/avr_libc_extra/include/vendor +INCLUDES += -I$(RIOTCPU)/atmega_common/include PSEUDOMODULES += atmega_pcint PSEUDOMODULES += atmega_pcint% -include $(RIOTMAKE)/arch/atmega.inc.mk +# CPU depends on the avr8 common module, so include it +include $(RIOTCPU)/avr8_common/Makefile.include diff --git a/cpu/avr8_common/Kconfig b/cpu/avr8_common/Kconfig new file mode 100644 index 0000000000..334b69b788 --- /dev/null +++ b/cpu/avr8_common/Kconfig @@ -0,0 +1,28 @@ +# Copyright (c) 2020 HAW Hamburg +# 2021 Gerson Fernando Budke +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. +# +config CPU_ARCH_AVR8 + bool + select HAS_ARCH_8BIT + select HAS_ARCH_AVR8 + +config CPU_CORE_AVR + bool + select CPU_ARCH_AVR8 + +## Common CPU symbols +config CPU_ARCH + default "avr8" if CPU_ARCH_AVR8 + +config CPU_CORE + default "avr" if CPU_CORE_AVR + +## Declaration of specific features +config HAS_ARCH_AVR8 + bool + help + Indicates that the current architecture is Atmel AVR8. diff --git a/cpu/avr8_common/Makefile b/cpu/avr8_common/Makefile new file mode 100644 index 0000000000..4b36b1f63a --- /dev/null +++ b/cpu/avr8_common/Makefile @@ -0,0 +1,7 @@ +# define the module that is build (not strictly necessary) +MODULE = avr8_common + +# add a list of subdirectories, that should also be build +DIRS = avr_libc_extra + +include $(RIOTBASE)/Makefile.base diff --git a/cpu/avr8_common/Makefile.dep b/cpu/avr8_common/Makefile.dep new file mode 100644 index 0000000000..86d551f3c5 --- /dev/null +++ b/cpu/avr8_common/Makefile.dep @@ -0,0 +1,20 @@ +# avr libc needs some RIOT-specific support code +USEMODULE += avr_libc_extra + +# tell the build system to build the avr8 common files +USEMODULE += avr8_common + +# The AVR-libc provides no thread safe malloc implementation and has no hooks +# to inject. Use malloc_thread_safe to link calls to malloc to safe wrappers +# instead. +USEMODULE += malloc_thread_safe + +# the atmel port uses stdio_uart by default +ifeq (,$(filter stdio_% slipdev_stdio,$(USEMODULE))) + USEMODULE += stdio_uart +endif + +# static C++ constructors need guards for thread safe initialization +ifneq (,$(filter cpp,$(FEATURES_USED))) + USEMODULE += cxx_ctor_guards +endif diff --git a/cpu/avr8_common/Makefile.features b/cpu/avr8_common/Makefile.features new file mode 100644 index 0000000000..1c5acda5cd --- /dev/null +++ b/cpu/avr8_common/Makefile.features @@ -0,0 +1,3 @@ +FEATURES_PROVIDED += arch_8bit +FEATURES_PROVIDED += arch_avr8 +FEATURES_PROVIDED += cpp diff --git a/cpu/avr8_common/Makefile.include b/cpu/avr8_common/Makefile.include new file mode 100644 index 0000000000..73ea0cc84d --- /dev/null +++ b/cpu/avr8_common/Makefile.include @@ -0,0 +1,6 @@ +# include module specific includes +INCLUDES += -I$(RIOTCPU)/avr8_common/include \ + -isystem$(RIOTCPU)/avr8_common/avr_libc_extra/include \ + -isystem$(RIOTCPU)/avr8_common/avr_libc_extra/include/vendor + +include $(RIOTMAKE)/arch/atmega.inc.mk diff --git a/cpu/atmega_common/cpu.c b/cpu/avr8_common/avr8_cpu.c similarity index 100% rename from cpu/atmega_common/cpu.c rename to cpu/avr8_common/avr8_cpu.c diff --git a/cpu/atmega_common/avr_libc_extra/Makefile b/cpu/avr8_common/avr_libc_extra/Makefile similarity index 100% rename from cpu/atmega_common/avr_libc_extra/Makefile rename to cpu/avr8_common/avr_libc_extra/Makefile diff --git a/cpu/atmega_common/avr_libc_extra/atmega_stdio.c b/cpu/avr8_common/avr_libc_extra/avr8_stdio.c similarity index 100% rename from cpu/atmega_common/avr_libc_extra/atmega_stdio.c rename to cpu/avr8_common/avr_libc_extra/avr8_stdio.c diff --git a/cpu/atmega_common/avr_libc_extra/include/errno.h b/cpu/avr8_common/avr_libc_extra/include/errno.h similarity index 100% rename from cpu/atmega_common/avr_libc_extra/include/errno.h rename to cpu/avr8_common/avr_libc_extra/include/errno.h diff --git a/cpu/atmega_common/avr_libc_extra/include/inttypes.h b/cpu/avr8_common/avr_libc_extra/include/inttypes.h similarity index 100% rename from cpu/atmega_common/avr_libc_extra/include/inttypes.h rename to cpu/avr8_common/avr_libc_extra/include/inttypes.h diff --git a/cpu/atmega_common/avr_libc_extra/include/sys/time.h b/cpu/avr8_common/avr_libc_extra/include/sys/time.h similarity index 100% rename from cpu/atmega_common/avr_libc_extra/include/sys/time.h rename to cpu/avr8_common/avr_libc_extra/include/sys/time.h diff --git a/cpu/atmega_common/avr_libc_extra/include/sys/types.h b/cpu/avr8_common/avr_libc_extra/include/sys/types.h similarity index 100% rename from cpu/atmega_common/avr_libc_extra/include/sys/types.h rename to cpu/avr8_common/avr_libc_extra/include/sys/types.h diff --git a/cpu/atmega_common/avr_libc_extra/include/unistd.h b/cpu/avr8_common/avr_libc_extra/include/unistd.h similarity index 100% rename from cpu/atmega_common/avr_libc_extra/include/unistd.h rename to cpu/avr8_common/avr_libc_extra/include/unistd.h diff --git a/cpu/atmega_common/avr_libc_extra/include/vendor/sys/stat.h b/cpu/avr8_common/avr_libc_extra/include/vendor/sys/stat.h similarity index 100% rename from cpu/atmega_common/avr_libc_extra/include/vendor/sys/stat.h rename to cpu/avr8_common/avr_libc_extra/include/vendor/sys/stat.h diff --git a/cpu/atmega_common/avr_libc_extra/include/vendor/time.h b/cpu/avr8_common/avr_libc_extra/include/vendor/time.h similarity index 100% rename from cpu/atmega_common/avr_libc_extra/include/vendor/time.h rename to cpu/avr8_common/avr_libc_extra/include/vendor/time.h diff --git a/cpu/atmega_common/avr_libc_extra/posix_unistd.c b/cpu/avr8_common/avr_libc_extra/posix_unistd.c similarity index 100% rename from cpu/atmega_common/avr_libc_extra/posix_unistd.c rename to cpu/avr8_common/avr_libc_extra/posix_unistd.c diff --git a/cpu/avr8_common/doc.txt b/cpu/avr8_common/doc.txt new file mode 100644 index 0000000000..e0f369e0f5 --- /dev/null +++ b/cpu/avr8_common/doc.txt @@ -0,0 +1,5 @@ +/** + * @defgroup cpu_avr8_common Atmel AVR-8 CPU: common files + * @brief AVR-8 specific code + * @ingroup cpu + */ diff --git a/cpu/atmega_common/include/architecture_arch.h b/cpu/avr8_common/include/architecture_arch.h similarity index 100% rename from cpu/atmega_common/include/architecture_arch.h rename to cpu/avr8_common/include/architecture_arch.h diff --git a/cpu/atmega_common/include/atomic_utils_arch.h b/cpu/avr8_common/include/atomic_utils_arch.h similarity index 100% rename from cpu/atmega_common/include/atomic_utils_arch.h rename to cpu/avr8_common/include/atomic_utils_arch.h diff --git a/cpu/atmega_common/include/c11_atomics_compat_cpu.hpp b/cpu/avr8_common/include/c11_atomics_compat_cpu.hpp similarity index 100% rename from cpu/atmega_common/include/c11_atomics_compat_cpu.hpp rename to cpu/avr8_common/include/c11_atomics_compat_cpu.hpp diff --git a/cpu/atmega_common/include/cpu.h b/cpu/avr8_common/include/cpu.h similarity index 100% rename from cpu/atmega_common/include/cpu.h rename to cpu/avr8_common/include/cpu.h diff --git a/cpu/atmega_common/include/irq_arch.h b/cpu/avr8_common/include/irq_arch.h similarity index 100% rename from cpu/atmega_common/include/irq_arch.h rename to cpu/avr8_common/include/irq_arch.h diff --git a/cpu/atmega_common/startup.c b/cpu/avr8_common/startup.c similarity index 100% rename from cpu/atmega_common/startup.c rename to cpu/avr8_common/startup.c diff --git a/cpu/atmega_common/thread_arch.c b/cpu/avr8_common/thread_arch.c similarity index 100% rename from cpu/atmega_common/thread_arch.c rename to cpu/avr8_common/thread_arch.c From 1426e15679d926afba9c14f83c621de24936cd85 Mon Sep 17 00:00:00 2001 From: Gerson Fernando Budke Date: Sat, 2 Jan 2021 14:40:07 -0300 Subject: [PATCH 4/4] cpu/avr8_common: Normalize method prefix name Refactor atmega_ prefix to avr8_ prefix and update copyrights. Signed-off-by: Gerson Fernando Budke --- boards/arduino-leonardo/board.c | 2 +- cpu/atmega_common/atmega_cpu.c | 8 ++-- cpu/atmega_common/periph/gpio.c | 8 ++-- cpu/atmega_common/periph/rtc.c | 4 +- cpu/atmega_common/periph/rtt.c | 12 +++--- cpu/atmega_common/periph/timer.c | 4 +- cpu/atmega_common/periph/uart.c | 14 +++---- cpu/avr8_common/avr8_cpu.c | 13 +++--- cpu/avr8_common/avr_libc_extra/avr8_stdio.c | 6 ++- cpu/avr8_common/include/architecture_arch.h | 4 +- cpu/avr8_common/include/atomic_utils_arch.h | 4 +- cpu/avr8_common/include/cpu.h | 44 +++++++++++---------- cpu/avr8_common/include/irq_arch.h | 9 +++-- cpu/avr8_common/startup.c | 4 +- cpu/avr8_common/thread_arch.c | 40 ++++++++++--------- drivers/at86rf2xx/at86rf2xx_netdev.c | 12 +++--- 16 files changed, 102 insertions(+), 86 deletions(-) diff --git a/boards/arduino-leonardo/board.c b/boards/arduino-leonardo/board.c index 32403ecaf2..9825132215 100644 --- a/boards/arduino-leonardo/board.c +++ b/boards/arduino-leonardo/board.c @@ -35,7 +35,7 @@ void board_init(void) PRR1 |= 1<DR = data[i]; } @@ -194,22 +194,22 @@ void uart_poweroff(uart_t uart) static inline void _rx_isr_handler(int num) { - atmega_enter_isr(); + avr8_enter_isr(); isr_ctx[num].rx_cb(isr_ctx[num].arg, dev[num]->DR); - atmega_exit_isr(); + avr8_exit_isr(); } static inline void _tx_isr_handler(int num) { - atmega_enter_isr(); + avr8_enter_isr(); /* entire frame in the Transmit Shift Register has been shifted out and there are no new data currently present in the transmit buffer */ - atmega_state &= ~ATMEGA_STATE_FLAG_UART_TX(num); + avr8_state &= ~AVR8_STATE_FLAG_UART_TX(num); - atmega_exit_isr(); + avr8_exit_isr(); } diff --git a/cpu/avr8_common/avr8_cpu.c b/cpu/avr8_common/avr8_cpu.c index 592d9658e0..bdcfb12ec1 100644 --- a/cpu/avr8_common/avr8_cpu.c +++ b/cpu/avr8_common/avr8_cpu.c @@ -2,6 +2,7 @@ * Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen * 2017 RWTH Aachen, Josua Arndt * 2018 Matthew Blue + * 2021 Gerson Fernando Budke * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level @@ -9,7 +10,7 @@ */ /** - * @ingroup cpu_atmega_common + * @ingroup cpu_avr8_common * @{ * * @file @@ -20,7 +21,8 @@ * @author Josua Arndt * @author Matthew Blue * @author Francisco Acosta - + * @author Gerson Fernando Budke + * * @} */ @@ -58,7 +60,8 @@ */ uint8_t mcusr_mirror __attribute__((section(".noinit"))); uint8_t soft_rst __attribute__((section(".noinit"))); -uint8_t atmega_state = 0; +uint8_t avr8_state = 0; + void get_mcusr(void) __attribute__((naked, section(".init0"), used)); void get_mcusr(void) @@ -78,14 +81,14 @@ void get_mcusr(void) void cpu_init(void) { - atmega_reset_cause(); + avr8_reset_cause(); wdt_reset(); /* should not be nececessary as done in bootloader */ wdt_disable(); /* but when used without bootloader this is needed */ /* Initialize stdio before periph_init() to allow use of DEBUG() there */ #ifdef MODULE_AVR_LIBC_EXTRA - atmega_stdio_init(); + avr8_stdio_init(); #endif /* Initialize peripherals for which modules are included in the makefile.*/ /* spi_init */ diff --git a/cpu/avr8_common/avr_libc_extra/avr8_stdio.c b/cpu/avr8_common/avr_libc_extra/avr8_stdio.c index d37158b0ad..274688d3e9 100644 --- a/cpu/avr8_common/avr_libc_extra/avr8_stdio.c +++ b/cpu/avr8_common/avr_libc_extra/avr8_stdio.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2018 Kaspar Schleiser + * 2021 Gerson Fernando Budke * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level @@ -10,9 +11,10 @@ * @{ * * @file - * @brief Implements common atmega libc stdio initialization + * @brief Implements common avr8 libc stdio initialization * * @author Kaspar Schleiser + * @author Gerson Fernando Budke * * @} */ @@ -41,7 +43,7 @@ static int _uart_getchar(FILE *stream) return (int)c; } -void atmega_stdio_init(void) +void avr8_stdio_init(void) { stdio_init(); diff --git a/cpu/avr8_common/include/architecture_arch.h b/cpu/avr8_common/include/architecture_arch.h index 701fa68df1..a4e7733fb5 100644 --- a/cpu/avr8_common/include/architecture_arch.h +++ b/cpu/avr8_common/include/architecture_arch.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2020 Otto-von-Guericke-Universität Magdeburg + * 2021 Gerson Fernando Budke * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level @@ -7,13 +8,14 @@ */ /** - * @ingroup cpu_atmega_common + * @ingroup cpu_avr8_common * @{ * * @file * @brief Architecture details * * @author Marian Buschsieweke + * @author Gerson Fernando Budke * */ diff --git a/cpu/avr8_common/include/atomic_utils_arch.h b/cpu/avr8_common/include/atomic_utils_arch.h index 6c8ab36a41..3d3212801a 100644 --- a/cpu/avr8_common/include/atomic_utils_arch.h +++ b/cpu/avr8_common/include/atomic_utils_arch.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2020 Otto-von-Guericke-Universität Magdeburg + * 2021 Gerson Fernando Budke * * This file is subject to the terms and conditions of the GNU Lesser General * Public License v2.1. See the file LICENSE in the top level directory for more @@ -7,13 +8,14 @@ */ /** - * @ingroup cpu_atmega_common + * @ingroup cpu_avr8_common * * @{ * * @file * @brief Implementation of fast atomic utility functions * @author Marian Buschsieweke + * @author Gerson Fernando Budke */ #ifndef ATOMIC_UTILS_ARCH_H diff --git a/cpu/avr8_common/include/cpu.h b/cpu/avr8_common/include/cpu.h index 7f6214d421..42cfd34354 100644 --- a/cpu/avr8_common/include/cpu.h +++ b/cpu/avr8_common/include/cpu.h @@ -2,6 +2,7 @@ * Copyright (C) 2015 Kaspar Schleiser * 2014 Freie Universität Berlin, Hinnerk van Bruinehsen * 2018 RWTH Aachen, Josua Arndt + * 2021 Gerson Fernando Budke * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level @@ -9,12 +10,12 @@ */ /** - * @ingroup cpu_atmega_common - * @brief Common implementations and headers for ATmega family based micro-controllers + * @ingroup cpu_avr8_common + * @brief Common implementations and headers for AVR-8 family based micro-controllers * @{ * * @file - * @brief Basic definitions for the ATmega common module + * @brief Basic definitions for the AVR-8 common module * * When ever you want to do something hardware related, that is accessing MCUs registers directly, * just include this file. It will then make sure that the MCU specific headers are included. @@ -24,6 +25,7 @@ * @author Hinnerk van Bruinehsen * @author Kaspar Schleiser * @author Josua Arndt + * @author Gerson Fernando Budke * */ @@ -58,10 +60,10 @@ extern "C" * @name Flags for the current state of the ATmega MCU * @{ */ -#define ATMEGA_STATE_FLAG_ISR (0x80U) /**< In ISR */ -#define ATMEGA_STATE_FLAG_UART0_TX (0x01U) /**< TX pending for UART 0 */ -#define ATMEGA_STATE_FLAG_UART1_TX (0x02U) /**< TX pending for UART 1 */ -#define ATMEGA_STATE_FLAG_UART_TX(x) (0x01U << x) /**< TX pending for UART x */ +#define AVR8_STATE_FLAG_ISR (0x80U) /**< In ISR */ +#define AVR8_STATE_FLAG_UART0_TX (0x01U) /**< TX pending for UART 0 */ +#define AVR8_STATE_FLAG_UART1_TX (0x02U) /**< TX pending for UART 1 */ +#define AVR8_STATE_FLAG_UART_TX(x) (0x01U << x) /**< TX pending for UART x */ /** @} */ /** @@ -69,7 +71,7 @@ extern "C" * * @note This variable is updated from IRQ context; access to it should * be wrapped into @ref irq_disable and @ref irq_restore or - * @ref atmega_get_state should be used. + * @ref avr8_get_state should be used. * * Contents: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -86,26 +88,26 @@ extern "C" * | TX1 | This bit is set when on UART1 TX is pending | * | TX0 | This bit is set when on UART0 TX is pending | */ -extern uint8_t atmega_state; +extern uint8_t avr8_state; /** - * @brief Atomically read the state (@ref atmega_state) + * @brief Atomically read the state (@ref avr8_state) * * This function guarantees that the read is not optimized out, not reordered * and done atomically. This does not mean that by the time return value is * processed that it still reflects the value currently stored in - * @ref atmega_state. + * @ref avr8_state. * * Using ASM rather than C11 atomics has less overhead, as not every access to * the state has to be performed atomically: Those done from ISR will not be * interrupted (no support for nested interrupts) and barriers at the begin and * end of the ISRs make sure the access takes place before IRQ context is left. */ -static inline uint8_t atmega_get_state(void) +static inline uint8_t avr8_get_state(void) { uint8_t state; __asm__ volatile( - "lds %[state], atmega_state \n\t" + "lds %[state], avr8_state \n\t" : [state] "=r" (state) : : "memory" @@ -118,13 +120,13 @@ static inline uint8_t atmega_get_state(void) /** * @brief Run this code on entering interrupt routines */ -static inline void atmega_enter_isr(void) +static inline void avr8_enter_isr(void) { /* This flag is only called from IRQ context, and nested IRQs are not * supported as of now. The flag will be unset before the IRQ context is * left, so no need to use memory barriers or atomics here */ - atmega_state |= ATMEGA_STATE_FLAG_ISR; + avr8_state |= AVR8_STATE_FLAG_ISR; } /** @@ -133,16 +135,16 @@ static inline void atmega_enter_isr(void) * @retval !=0 At least on UART device is still sending data out * @retval 0 No UART is currently sending data */ -static inline int atmega_is_uart_tx_pending(void) +static inline int avr8_is_uart_tx_pending(void) { - uint8_t state = atmega_get_state(); - return (state & (ATMEGA_STATE_FLAG_UART0_TX | ATMEGA_STATE_FLAG_UART1_TX)); + uint8_t state = avr8_get_state(); + return (state & (AVR8_STATE_FLAG_UART0_TX | AVR8_STATE_FLAG_UART1_TX)); } /** * @brief Run this code on exiting interrupt routines */ -void atmega_exit_isr(void); +void avr8_exit_isr(void); /** * @brief Initialization of the CPU @@ -172,12 +174,12 @@ static inline void __attribute__((always_inline)) cpu_print_last_instruction(voi /** * @brief Initializes avrlibc stdio */ -void atmega_stdio_init(void); +void avr8_stdio_init(void); /** * @brief Print reset cause */ -void atmega_reset_cause(void); +void avr8_reset_cause(void); #ifdef __cplusplus } diff --git a/cpu/avr8_common/include/irq_arch.h b/cpu/avr8_common/include/irq_arch.h index d4079c1ff1..5287a9c251 100644 --- a/cpu/avr8_common/include/irq_arch.h +++ b/cpu/avr8_common/include/irq_arch.h @@ -2,6 +2,7 @@ * Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen * 2018 RWTH Aachen, Josua Arndt * 2020 Otto-von-Guericke-Universität Magdeburg + * 2021 Gerson Fernando Budke * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level @@ -9,7 +10,7 @@ */ /** - * @ingroup cpu_atmega_common + * @ingroup cpu_avr8_common * @{ * * @file @@ -19,6 +20,7 @@ * @author Hinnerk van Bruinehsen * @author Josua Arndt * @author Marian Buschsieweke + * @author Gerson Fernando Budke * */ @@ -28,7 +30,6 @@ #include #include #include -#include "irq.h" #include "cpu.h" #ifdef __cplusplus @@ -98,8 +99,8 @@ __attribute__((always_inline)) static inline void irq_restore(unsigned int _stat */ __attribute__((always_inline)) static inline int irq_is_in(void) { - uint8_t state = atmega_get_state(); - return (state & ATMEGA_STATE_FLAG_ISR); + uint8_t state = avr8_get_state(); + return (state & AVR8_STATE_FLAG_ISR); } #ifdef __cplusplus diff --git a/cpu/avr8_common/startup.c b/cpu/avr8_common/startup.c index 0dbb20fbd3..da9f6263d1 100644 --- a/cpu/avr8_common/startup.c +++ b/cpu/avr8_common/startup.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen + * 2021 Gerson Fernando Budke * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level @@ -7,7 +8,7 @@ */ /** - * @ingroup cpu_atmega_common + * @ingroup cpu_avr8_common * @{ * * @file @@ -16,6 +17,7 @@ * @author Hinnerk van Bruinehsen * @author Josua Arndt * @author Steffen Robertz + * @author Gerson Fernando Budke * @} */ diff --git a/cpu/avr8_common/thread_arch.c b/cpu/avr8_common/thread_arch.c index 1960b8d22d..9ea1cd66af 100644 --- a/cpu/avr8_common/thread_arch.c +++ b/cpu/avr8_common/thread_arch.c @@ -2,6 +2,7 @@ * Copyright (C) 2014 Freie Universität Berlin, Hinnerk van Bruinehsen * 2017 Thomas Perrot * 2018 RWTH Aachen, Josua Arndt + * 2021 Gerson Fernando Budke * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level @@ -9,7 +10,7 @@ */ /** - * @ingroup cpu_atmega_common + * @ingroup cpu_avr8_common * @{ * * @file @@ -18,6 +19,7 @@ * @author Hinnerk van Bruinehsen * @author Thomas Perrot * @author Josua Arndt + * @author Gerson Fernando Budke * * @} */ @@ -30,13 +32,13 @@ #include "cpu.h" #include "board.h" -static void atmega_context_save(void); -static void atmega_context_restore(void); -static void atmega_enter_thread_mode(void); +static void avr8_context_save(void); +static void avr8_context_restore(void); +static void avr8_enter_thread_mode(void); /** * @brief Since AVR doesn't support direct manipulation of the program counter we - * model a stack like it would be left by atmega_context_save(). + * model a stack like it would be left by avr8_context_save(). * The resulting layout in memory is the following: * ---------------thread_t (not created by thread_stack_init) ---------- * local variables (a temporary value and the stackpointer) @@ -48,7 +50,7 @@ static void atmega_enter_thread_mode(void); * ----------------------------------------------------------------------- * a 16 Bit pointer to task_func * this is placed exactly at the place where the program counter would be - * stored normally and thus can be returned to when atmega_context_restore() + * stored normally and thus can be returned to when avr8_context_restore() * has been run * (Optional 17 bit (bit is set to zero) for devices with > 128kb FLASH) * ----------------------------------------------------------------------- @@ -61,7 +63,7 @@ static void atmega_enter_thread_mode(void); * r26 - r31 * ----------------------------------------------------------------------- * - * After the invocation of atmega_context_restore() the pointer to task_func is + * After the invocation of avr8_context_restore() the pointer to task_func is * on top of the stack and can be returned to. This way we can actually place * it inside of the program counter of the MCU. * if task_func returns sched_task_exit gets popped into the PC @@ -198,7 +200,7 @@ void thread_stack_print(void) void cpu_switch_context_exit(void) { sched_run(); - atmega_enter_thread_mode(); + avr8_enter_thread_mode(); } #define STACK_POINTER ((char *)AVR_STACK_POINTER_REG) @@ -210,7 +212,7 @@ extern char *__brkval; /** * @brief Set the MCU into Thread-Mode and load the initial task from the stack and run it */ -void NORETURN atmega_enter_thread_mode(void) +void NORETURN avr8_enter_thread_mode(void) { irq_enable(); @@ -226,7 +228,7 @@ void NORETURN atmega_enter_thread_mode(void) __brkval = __malloc_heap_start; } - atmega_context_restore(); + avr8_context_restore(); __asm__ volatile ("ret"); UNREACHABLE(); @@ -235,9 +237,9 @@ void NORETURN atmega_enter_thread_mode(void) void thread_yield_higher(void) { if (irq_is_in() == 0) { - atmega_context_save(); + avr8_context_save(); sched_run(); - atmega_context_restore(); + avr8_context_restore(); __asm__ volatile ("ret"); } else { @@ -245,20 +247,20 @@ void thread_yield_higher(void) } } -void atmega_exit_isr(void) +void avr8_exit_isr(void) { - atmega_state &= ~ATMEGA_STATE_FLAG_ISR; - /* Force access to atmega_state to take place */ + avr8_state &= ~AVR8_STATE_FLAG_ISR; + /* Force access to avr8_state to take place */ __asm__ volatile ("" : : : "memory"); if (sched_context_switch_request) { - atmega_context_save(); + avr8_context_save(); sched_run(); - atmega_context_restore(); + avr8_context_restore(); __asm__ volatile ("reti"); } } -__attribute__((always_inline)) static inline void atmega_context_save(void) +__attribute__((always_inline)) static inline void avr8_context_save(void) { __asm__ volatile ( "push __tmp_reg__ \n\t" @@ -313,7 +315,7 @@ __attribute__((always_inline)) static inline void atmega_context_save(void) "st x+, __tmp_reg__ \n\t"); } -__attribute__((always_inline)) static inline void atmega_context_restore(void) +__attribute__((always_inline)) static inline void avr8_context_restore(void) { __asm__ volatile ( "lds r26, sched_active_thread \n\t" diff --git a/drivers/at86rf2xx/at86rf2xx_netdev.c b/drivers/at86rf2xx/at86rf2xx_netdev.c index 1def1bbc05..fb2d372c6f 100644 --- a/drivers/at86rf2xx/at86rf2xx_netdev.c +++ b/drivers/at86rf2xx/at86rf2xx_netdev.c @@ -870,7 +870,7 @@ ISR(TRX24_TX_START_vect){ */ ISR(TRX24_RX_END_vect, ISR_BLOCK) { - atmega_enter_isr(); + avr8_enter_isr(); uint8_t status = *AT86RF2XX_REG__TRX_STATE & AT86RF2XX_TRX_STATUS_MASK__TRX_STATUS; DEBUG("TRX24_RX_END 0x%x\n", status); @@ -879,7 +879,7 @@ ISR(TRX24_RX_END_vect, ISR_BLOCK) /* Call upper layer to process received data */ netdev_trigger_event_isr(at86rfmega_dev); - atmega_exit_isr(); + avr8_exit_isr(); } /** @@ -892,12 +892,12 @@ ISR(TRX24_RX_END_vect, ISR_BLOCK) */ ISR(TRX24_XAH_AMI_vect, ISR_BLOCK) { - atmega_enter_isr(); + avr8_enter_isr(); DEBUG("TRX24_XAH_AMI\n"); ((at86rf2xx_t *)at86rfmega_dev)->irq_status |= AT86RF2XX_IRQ_STATUS_MASK__AMI; - atmega_exit_isr(); + avr8_exit_isr(); } /** @@ -909,7 +909,7 @@ ISR(TRX24_XAH_AMI_vect, ISR_BLOCK) */ ISR(TRX24_TX_END_vect, ISR_BLOCK) { - atmega_enter_isr(); + avr8_enter_isr(); at86rf2xx_t *dev = (at86rf2xx_t *) at86rfmega_dev; uint8_t status = *AT86RF2XX_REG__TRX_STATE & AT86RF2XX_TRX_STATUS_MASK__TRX_STATUS; @@ -924,7 +924,7 @@ ISR(TRX24_TX_END_vect, ISR_BLOCK) netdev_trigger_event_isr(at86rfmega_dev); } - atmega_exit_isr(); + avr8_exit_isr(); } #endif /* MODULE_AT86RFA1 || MODULE_AT86RFR2 */