From b1ef68abf781da05a6bde877b3922a1e1d55b3c6 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Sat, 28 Sep 2019 00:42:25 +0200 Subject: [PATCH] cpu/atmega_common: move periph/cpuid.c to common code Both atmega128rfa1 and atmega256rfr2 implement it. --- cpu/atmega128rfa1/Makefile | 2 +- cpu/atmega128rfa1/Makefile.include | 3 - cpu/atmega128rfa1/periph/Makefile | 1 - cpu/atmega256rfr2/Makefile | 2 +- cpu/atmega256rfr2/Makefile.include | 3 - cpu/atmega256rfr2/periph/Makefile | 1 - cpu/atmega256rfr2/periph/cpuid.c | 76 ------------------- .../periph/cpuid.c | 15 +--- makefiles/arch/atmega.inc.mk | 6 -- 9 files changed, 5 insertions(+), 104 deletions(-) delete mode 100644 cpu/atmega128rfa1/periph/Makefile delete mode 100644 cpu/atmega256rfr2/periph/Makefile delete mode 100644 cpu/atmega256rfr2/periph/cpuid.c rename cpu/{atmega128rfa1 => atmega_common}/periph/cpuid.c (86%) diff --git a/cpu/atmega128rfa1/Makefile b/cpu/atmega128rfa1/Makefile index bfe7b40097..8b5bf236d3 100644 --- a/cpu/atmega128rfa1/Makefile +++ b/cpu/atmega128rfa1/Makefile @@ -2,6 +2,6 @@ MODULE = cpu # add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/atmega_common/ +DIRS = $(RIOTCPU)/atmega_common/ include $(RIOTBASE)/Makefile.base diff --git a/cpu/atmega128rfa1/Makefile.include b/cpu/atmega128rfa1/Makefile.include index beb154850e..93564e8080 100644 --- a/cpu/atmega128rfa1/Makefile.include +++ b/cpu/atmega128rfa1/Makefile.include @@ -1,9 +1,6 @@ # tell the build system that the CPU depends on the atmega common files USEMODULE += atmega_common -#include periph module -USEMODULE += periph - RAM_LEN = 16K ROM_LEN = 128K diff --git a/cpu/atmega128rfa1/periph/Makefile b/cpu/atmega128rfa1/periph/Makefile deleted file mode 100644 index a36df249ac..0000000000 --- a/cpu/atmega128rfa1/periph/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(RIOTMAKE)/periph.mk diff --git a/cpu/atmega256rfr2/Makefile b/cpu/atmega256rfr2/Makefile index bfe7b40097..8b5bf236d3 100644 --- a/cpu/atmega256rfr2/Makefile +++ b/cpu/atmega256rfr2/Makefile @@ -2,6 +2,6 @@ MODULE = cpu # add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/atmega_common/ +DIRS = $(RIOTCPU)/atmega_common/ include $(RIOTBASE)/Makefile.base diff --git a/cpu/atmega256rfr2/Makefile.include b/cpu/atmega256rfr2/Makefile.include index d573da94db..43c5888c1d 100644 --- a/cpu/atmega256rfr2/Makefile.include +++ b/cpu/atmega256rfr2/Makefile.include @@ -1,9 +1,6 @@ # tell the build system that the CPU depends on the atmega common files USEMODULE += atmega_common -#include periph module -USEMODULE += periph - RAM_LEN = 32K ROM_LEN = 256K diff --git a/cpu/atmega256rfr2/periph/Makefile b/cpu/atmega256rfr2/periph/Makefile deleted file mode 100644 index a36df249ac..0000000000 --- a/cpu/atmega256rfr2/periph/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(RIOTMAKE)/periph.mk diff --git a/cpu/atmega256rfr2/periph/cpuid.c b/cpu/atmega256rfr2/periph/cpuid.c deleted file mode 100644 index 2fa936bea3..0000000000 --- a/cpu/atmega256rfr2/periph/cpuid.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2018 RWTH Aachen, Josua Arndt, Steffen Robertz - * - * 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 Low-level CPUID driver implementation - * - * @author Steffen Robertz - * @author Josua Arndt - * - * @} - */ -#include -#include -#include - -#include "periph/cpuid.h" - -#include "atmega_regs_common.h" -#include "avr/boot.h" - -#define ENABLE_DEBUG (0) -#include "debug.h" - -/** - * @brief CPU_ID build from MCU register - * - * CPIUD is taken from MCU Control Register and Signature bytes. - * CPUID: 1e a8 02 1f 94 03 ff ff - * CPUID: 1e a8 02 1f 94 92 XX XX - * MEGA62/128/256_RFR2 [MANUAL] p.505 - * MEGA62/128/256_RFR2 [MANUAL] p.138 - * MEGA62/128/256_RFR2 [MANUAL] p.492 - * - * usr_sign_0/1 are configurable values on flash page 1. - */ -void cpuid_get(void *id) -{ - uint8_t signature_0 = boot_signature_byte_get(0x00); - uint8_t signature_1 = boot_signature_byte_get(0x02); - uint8_t signature_2 = boot_signature_byte_get(0x04); - - uint8_t usr_sign_0 = boot_signature_byte_get(0x0100); - uint8_t usr_sign_1 = boot_signature_byte_get(0x0102); - - uint8_t addr[CPUID_LEN] = { - signature_0, /* 0x1E Atmel manufacturer ID */ - signature_1, /* 0xA8 Part Number high byte */ - signature_2, /* 0x02 Part Number low byte */ - MAN_ID_0, /* 0x1F Atmel JEDEC manufacturer ID */ - PART_NUM, /* 0x94 PART_NUM Identification */ - VERSION_NUM, /* 0x02 VERSION_NUM Identification */ -/* last two bytes can be set to flash page 1. for differentiation of different boards */ - usr_sign_0, /* user signature 0 */ - usr_sign_1, /* user signature 1 */ - }; - -#if defined(ENABLE_DEBUG) - DEBUG("CPUID: " ); - for (uint8_t i=0; i