From 722b342df3aa733f99c84e3d7e12d08b15ead978 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Mon, 8 Feb 2016 18:55:43 +0100 Subject: [PATCH] cpu/sam21_common: unified CPUID implementation --- cpu/sam21_common/periph/cpuid.c | 37 +++++++++++++++++++++++++++++++ cpu/samd21/periph/cpuid.c | 39 --------------------------------- cpu/saml21/periph/cpuid.c | 39 --------------------------------- 3 files changed, 37 insertions(+), 78 deletions(-) create mode 100644 cpu/sam21_common/periph/cpuid.c delete mode 100644 cpu/samd21/periph/cpuid.c delete mode 100644 cpu/saml21/periph/cpuid.c diff --git a/cpu/sam21_common/periph/cpuid.c b/cpu/sam21_common/periph/cpuid.c new file mode 100644 index 0000000000..6c40d267d1 --- /dev/null +++ b/cpu/sam21_common/periph/cpuid.c @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2014-2016 Freie Universität Berlin + * + * 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. + */ + +/** + * @addtogroup cpu_sam21_common + * @{ + * + * @file + * @brief Low-level CPUID driver implementation + * + * @author Troels Hoffmeyer + * @author Hauke Petersen + * + * @} + */ + +#include +#include + +#include "periph/cpuid.h" + +#define WORD0 (*(volatile uint32_t *)0x0080A00C) +#define WORD1 (*(volatile uint32_t *)0x0080A040) +#define WORD2 (*(volatile uint32_t *)0x0080A044) +#define WORD3 (*(volatile uint32_t *)0x0080A048) + + +void cpuid_get(void *id) +{ + uint32_t addr[] = { WORD0, WORD1, WORD2, WORD3 }; + memcpy(id, (void *)addr, CPUID_LEN); +} diff --git a/cpu/samd21/periph/cpuid.c b/cpu/samd21/periph/cpuid.c deleted file mode 100644 index b52d77ad44..0000000000 --- a/cpu/samd21/periph/cpuid.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2014-2016 Freie Universität Berlin - * - * 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. - */ - -/** - * @addtogroup cpu_samd21 - * @{ - * - * @file - * @brief Low-level CPUID driver implementation - * - * @author Troels Hoffmeyer - * - * @} - */ - -#include -#include - -#include "periph/cpuid.h" - -#define SAMD21_CPUID_WORD0 (*(volatile uint32_t *)0x0080A00C) -#define SAMD21_CPUID_WORD1 (*(volatile uint32_t *)0x0080A040) -#define SAMD21_CPUID_WORD2 (*(volatile uint32_t *)0x0080A044) -#define SAMD21_CPUID_WORD3 (*(volatile uint32_t *)0x0080A048) - - -void cpuid_get(void *id) -{ - uint32_t source_address[] = { SAMD21_CPUID_WORD0, - SAMD21_CPUID_WORD1, - SAMD21_CPUID_WORD2, - SAMD21_CPUID_WORD3}; - memcpy(id, (void*) source_address, CPUID_LEN); -} diff --git a/cpu/saml21/periph/cpuid.c b/cpu/saml21/periph/cpuid.c deleted file mode 100644 index c69b99cbff..0000000000 --- a/cpu/saml21/periph/cpuid.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2014-2016 Freie Universität Berlin - * - * 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. - */ - -/** - * @addtogroup cpu_saml21 - * @{ - * - * @file - * @brief Low-level CPUID driver implementation - * - * @author Troels Hoffmeyer - * - * @} - */ - -#include -#include - -#include "periph/cpuid.h" - -#define SAML21_CPUID_WORD0 (*(volatile uint32_t *)0x0080A00C) -#define SAML21_CPUID_WORD1 (*(volatile uint32_t *)0x0080A040) -#define SAML21_CPUID_WORD2 (*(volatile uint32_t *)0x0080A044) -#define SAML21_CPUID_WORD3 (*(volatile uint32_t *)0x0080A048) - - -void cpuid_get(void *id) -{ - uint32_t source_address[] = { SAML21_CPUID_WORD0, - SAML21_CPUID_WORD1, - SAML21_CPUID_WORD2, - SAML21_CPUID_WORD3}; - memcpy(id, (void*) source_address, CPUID_LEN); -}