diff --git a/boards/ek-lm4f120xl/Makefile.features b/boards/ek-lm4f120xl/Makefile.features index aacc4f47ac08d6c6459c48cd75c165ed8356b3ce..0ce7768d2b721867f7e5180c32840f4f18926761 100644 --- a/boards/ek-lm4f120xl/Makefile.features +++ b/boards/ek-lm4f120xl/Makefile.features @@ -1,6 +1,5 @@ # Put defined MCU peripherals here (in alphabetical order) FEATURES_PROVIDED += periph_adc -FEATURES_PROVIDED += periph_cpuid FEATURES_PROVIDED += periph_gpio FEATURES_PROVIDED += periph_timer FEATURES_PROVIDED += periph_uart diff --git a/cpu/cc2538/include/periph_cpu.h b/cpu/cc2538/include/periph_cpu.h index 2fbe199bbb8c0cbd6be6ed0a3d1cc8da5aa7f917..1c57a63be44c46fbfff5a21ebf3096ae8454f996 100644 --- a/cpu/cc2538/include/periph_cpu.h +++ b/cpu/cc2538/include/periph_cpu.h @@ -27,6 +27,10 @@ extern "C" { #endif +/** + * @brief Starting offset of CPU_ID + */ +#define CPUID_ADDR (&IEEE_ADDR_MSWORD) /** * @brief Length of the CPU_ID in octets */ diff --git a/cpu/cc2538/periph/cpuid.c b/cpu/cc2538/periph/cpuid.c deleted file mode 100644 index 500581297867797b0b70fa6909738b287daad743..0000000000000000000000000000000000000000 --- a/cpu/cc2538/periph/cpuid.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2014 Loci Controls Inc. - * - * 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_cc2538 - * @{ - * - * @file - * @brief CPU-ID driver implementation - * - * The CC2538 provides a 64-bit unique identifier, that is unique for each shipped unit. - * - * @author Ian Martin <ian@locicontrols.com> - * - * @} - */ - -#include <stdint.h> -#include <string.h> - -#include "cpu.h" -#include "periph/cpuid.h" - -void cpuid_get(void *id) -{ - uint8_t *dest = (uint8_t *)id; - - /** - * The byte-order is big-endian but the word order is little endian. - * Make some sense of it: - */ - dest[0] = IEEE_ADDR_MSWORD >> (3 * sizeof(uint8_t)); - dest[1] = IEEE_ADDR_MSWORD >> (2 * sizeof(uint8_t)); - dest[2] = IEEE_ADDR_MSWORD >> (1 * sizeof(uint8_t)); - dest[3] = IEEE_ADDR_MSWORD >> (0 * sizeof(uint8_t)); - dest[4] = IEEE_ADDR_LSWORD >> (3 * sizeof(uint8_t)); - dest[5] = IEEE_ADDR_LSWORD >> (2 * sizeof(uint8_t)); - dest[6] = IEEE_ADDR_LSWORD >> (1 * sizeof(uint8_t)); - dest[7] = IEEE_ADDR_LSWORD >> (0 * sizeof(uint8_t)); -} diff --git a/cpu/cc26x0/include/periph_cpu.h b/cpu/cc26x0/include/periph_cpu.h index 705434bc13beb939a8d6c4df494c2f3502b2cfc0..e1f337217dc174e779e44a781a35a2bf4360dc3e 100644 --- a/cpu/cc26x0/include/periph_cpu.h +++ b/cpu/cc26x0/include/periph_cpu.h @@ -25,6 +25,10 @@ extern "C" { #endif +/** + * @brief Starting offset of CPU_ID + */ +#define CPUID_ADDR (&FCFG->MAC_BLE_0) /** * @brief Length of the CPU_ID in octets */ diff --git a/cpu/cc26x0/periph/cpuid.c b/cpu/cc26x0/periph/cpuid.c deleted file mode 100644 index 343c661bfbf76e7ca8487da9668877112ddb3e4e..0000000000000000000000000000000000000000 --- a/cpu/cc26x0/periph/cpuid.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2016 Leon George - * - * 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_cc26x0 - * @{ - * - * @file - * @brief cpuid implementation for the CC26x0 - * - * @author Leon M. George <leon@georgemail.eu> - * - * @} - */ - -#include <string.h> - -#include "periph/cpuid.h" - -void cpuid_get(void *id) -{ - memcpy(id, (void *) &FCFG->MAC_BLE_0, CPUID_LEN); -} diff --git a/cpu/ezr32wg/include/periph_cpu.h b/cpu/ezr32wg/include/periph_cpu.h index f8a783de3fa4af6289fa3ce1671c445e058e74cb..f1ad2aad927b936754db7b3707e2bb9b03b6054d 100644 --- a/cpu/ezr32wg/include/periph_cpu.h +++ b/cpu/ezr32wg/include/periph_cpu.h @@ -38,6 +38,10 @@ extern "C" { typedef uint32_t tim_t; /** @} */ +/** + * @brief Starting offset of CPU_ID + */ +#define CPUID_ADDR (&DEVINFO->UNIQUEL) /** * @brief Length of the CPU_ID in octets */ diff --git a/cpu/ezr32wg/periph/cpuid.c b/cpu/ezr32wg/periph/cpuid.c deleted file mode 100644 index 25c17a669cf2c50458629840e42d7f4012448ae7..0000000000000000000000000000000000000000 --- a/cpu/ezr32wg/periph/cpuid.c +++ /dev/null @@ -1,35 +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_ezr32wg - * @{ - * - * @file - * @brief Low-level CPUID driver implementation - * - * @author Hauke Petersen <hauke.petersen@fu-berlin.de> - * - * @} - */ - -#include <stdint.h> -#include <string.h> - -#include "periph/cpuid.h" - -void cpuid_get(void *id) -{ - uint32_t tmp; - uint8_t *res = (uint8_t *)id; - - tmp = DEVINFO->UNIQUEL; - memcpy((res + 4), &tmp, sizeof(uint32_t)); - tmp = DEVINFO->UNIQUEH; - memcpy(res, &tmp, sizeof(uint32_t)); -} diff --git a/cpu/kinetis_common/include/periph_cpu.h b/cpu/kinetis_common/include/periph_cpu.h index e79b51ef479e885ac140cf162c330ef145b90a64..76c51309829cb6bcdf3d562eb8287cb00fd8b1c7 100644 --- a/cpu/kinetis_common/include/periph_cpu.h +++ b/cpu/kinetis_common/include/periph_cpu.h @@ -45,6 +45,10 @@ typedef uint16_t gpio_t; */ #define GPIO_PIN(x, y) (((x + 1) << 12) | (x << 6) | y) +/** + * @brief Starting offset of CPU_ID + */ +#define CPUID_ADDR (&SIM->UIDH) /** * @brief Length of the CPU_ID in octets */ diff --git a/cpu/kinetis_common/periph/cpuid.c b/cpu/kinetis_common/periph/cpuid.c deleted file mode 100644 index f34fd9e62d37e7bb07c1725520d6f100f6f3b732..0000000000000000000000000000000000000000 --- a/cpu/kinetis_common/periph/cpuid.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2014 PHYTEC Messtechnik GmbH - * - * 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_kinetis_common_cpuid - * - * @{ - * - * @file - * @brief Low-level CPUID driver implementation - * - * @author Johann Fischer <j.fischer@phytec.de> - * - * @} - */ - -#include <string.h> - -#include "cpu.h" -#include "periph/cpuid.h" - -void cpuid_get(void *id) -{ - memcpy(id, (void *)&(SIM_UIDH), CPUID_LEN); -} diff --git a/cpu/lm4f120/periph/cpuid.c b/cpu/lm4f120/periph/cpuid.c deleted file mode 100644 index b00bca0403c430f1fb298af552500bfb995b5ef2..0000000000000000000000000000000000000000 --- a/cpu/lm4f120/periph/cpuid.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2015 Rakendra Thapa <rakendrathapa@gmail.com> - * - * 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_lm4f120 - * @{ - * - * @file - * @brief Low-level CPUID driver implementation - * - * @author Rakendra Thapa <rakendrathapa@gmail.com> - * - * @} - */ - -#include <string.h> - -#include "cpu.h" -#include "periph/cpuid.h" - -void cpuid_get(void *id) -{ - memcpy(id, (void *)(NVIC_CPUID), CPUID_LEN); -} diff --git a/cpu/nrf5x_common/include/periph_cpu_common.h b/cpu/nrf5x_common/include/periph_cpu_common.h index dbb681aa8fc6b0ff507ea53de48783ee67042afe..fb9f3cc285724ebea79ffd0aabd5066a48618ef9 100644 --- a/cpu/nrf5x_common/include/periph_cpu_common.h +++ b/cpu/nrf5x_common/include/periph_cpu_common.h @@ -25,6 +25,10 @@ extern "C" { #endif +/** + * @brief Starting offset of CPU_ID + */ +#define CPUID_ADDR (&NRF_FICR->DEVICEID[0]) /** * @brief Length of the CPU_ID in octets */ diff --git a/cpu/nrf5x_common/periph/cpuid.c b/cpu/nrf5x_common/periph/cpuid.c deleted file mode 100644 index 8e51e2c370a88c1c3f967b49abecbc4f8f45a41a..0000000000000000000000000000000000000000 --- a/cpu/nrf5x_common/periph/cpuid.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2014-2016 Freie Universität Berlin - * 2015 Jan Wagner <mail@jwagner.eu> - * - * 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_nrf5x_common - * @{ - * - * @file - * @brief CPUID interface implementation - * - * The NRF52832 provides a 64-bit unique identifier that is unique for each - * shipped unit. - * - * @author Hauke Petersen <hauke.petersen@fu-berlin.de> - * @author Jan Wagner <mail@jwagner.eu> - * - * @} - */ - -#include <string.h> - -#include "cpu.h" -#include "periph/cpuid.h" - -void cpuid_get(void *id) -{ - memcpy(id, (void *)NRF_FICR->DEVICEID, CPUID_LEN); -} diff --git a/cpu/sam0_common/periph/cpuid.c b/cpu/sam0_common/periph/cpuid.c index a124d6f64706b30152f96d3a945bbcf35f4dfe17..8359fe1cc0b31faed467791f47a8e8dd0ebba553 100644 --- a/cpu/sam0_common/periph/cpuid.c +++ b/cpu/sam0_common/periph/cpuid.c @@ -33,5 +33,5 @@ void cpuid_get(void *id) { uint32_t addr[] = { WORD0, WORD1, WORD2, WORD3 }; - memcpy(id, (void *)addr, CPUID_LEN); + memcpy(id, &addr[0], CPUID_LEN); } diff --git a/cpu/stm32_common/include/periph_cpu_common.h b/cpu/stm32_common/include/periph_cpu_common.h index 659f4d4c72453685fa5c4ff2e3a0cd88f578dc68..9a884e942d4f42d192686448f25a1b8704c3043f 100644 --- a/cpu/stm32_common/include/periph_cpu_common.h +++ b/cpu/stm32_common/include/periph_cpu_common.h @@ -27,6 +27,14 @@ extern "C" { #endif +/** + * @brief Linker script provided symbol for CPUID location + */ +extern uint32_t _cpuid_address; +/** + * @brief Starting offset of CPU_ID + */ +#define CPUID_ADDR (&_cpuid_address) /** * @brief Length of the CPU_ID in octets */ diff --git a/cpu/stm32_common/periph/cpuid.c b/drivers/periph_common/cpuid.c similarity index 69% rename from cpu/stm32_common/periph/cpuid.c rename to drivers/periph_common/cpuid.c index 46500cd0c47a219af38987a3b92cae8b07045ab3..5f3dbf8fd3ec2127a65289bf7ef8b105b46c32b1 100644 --- a/cpu/stm32_common/periph/cpuid.c +++ b/drivers/periph_common/cpuid.c @@ -1,4 +1,5 @@ /* + * Copyright (C) 2017 Eistec AB * Copyright (C) 2014-2016 Freie Universität Berlin * Copyright (C) 2015 James Hollister * @@ -8,15 +9,16 @@ */ /** - * @addtogroup cpu_stm32_common + * @addtogroup drivers * @{ * * @file - * @brief Implementation of the CPUID driver interface + * @brief Generic implementation of the CPUID driver interface * * @author Thomas Eichinger <thomas.eichinger@fu-berlin.de> * @author James Hollister <jhollisterjr@gmail.com> * @author Hauke Petersen <hauke.petersen@fu-berlin.de> + * @author Joakim Nohlgård <joakim.nohlgard@eistec.se> * * @} */ @@ -26,9 +28,9 @@ #include "periph/cpuid.h" -extern uint32_t _cpuid_address; - +#ifdef CPUID_ADDR void cpuid_get(void *id) { - memcpy(id, &_cpuid_address, CPUID_LEN); + memcpy(id, (void *)CPUID_ADDR, CPUID_LEN); } +#endif