mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
cpu/atmega_common: move periph/cpuid.c to common code
Both atmega128rfa1 and atmega256rfr2 implement it.
This commit is contained in:
parent
7d78e32b15
commit
b1ef68abf7
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
include $(RIOTMAKE)/periph.mk
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
include $(RIOTMAKE)/periph.mk
|
@ -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 <steffen.robertz@rwth-aachen.de>
|
||||
* @author Josua Arndt <jarndt@ias.rwth-aachen.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#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<CPUID_LEN; i++)
|
||||
{
|
||||
DEBUG(" %02x ", addr[i] );
|
||||
}
|
||||
DEBUG("\n" );
|
||||
#endif
|
||||
|
||||
memcpy( id , addr, CPUID_LEN);
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup cpu_atmega128rfa1
|
||||
* @ingroup cpu_atmega_common
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
@ -55,7 +55,7 @@ void cpuid_get(void *id)
|
||||
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 */
|
||||
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 */
|
||||
@ -63,14 +63,5 @@ void cpuid_get(void *id)
|
||||
usr_sign_1, /* user signature 1 */
|
||||
};
|
||||
|
||||
#if defined(ENABLE_DEBUG)
|
||||
DEBUG("CPUID: " );
|
||||
for (uint8_t i=0; i<CPUID_LEN; i++)
|
||||
{
|
||||
DEBUG(" %02x ", addr[i] );
|
||||
}
|
||||
DEBUG("\n" );
|
||||
#endif
|
||||
|
||||
memcpy( id , addr, CPUID_LEN);
|
||||
memcpy(id, addr, CPUID_LEN);
|
||||
}
|
@ -17,12 +17,6 @@ USEMODULE += atmega_common
|
||||
# export the peripheral drivers to be linked into the final binary
|
||||
USEMODULE += atmega_common_periph
|
||||
|
||||
# Export the peripheral drivers to be linked into the final binary, for now
|
||||
# only atmega126rfr2 has periph drivers
|
||||
ifeq ($(CPU), atmega256rfr2)
|
||||
USEMODULE += periph
|
||||
endif
|
||||
|
||||
# the atmel port uses stdio_uart
|
||||
USEMODULE += stdio_uart
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user