mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #6861 from gebart/pr/cpuid-generic
cpuid: Unify implementations for the simplest cases
This commit is contained in:
commit
bca6190e3c
@ -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
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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));
|
||||
}
|
@ -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
|
||||
*/
|
||||
|
@ -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);
|
||||
}
|
@ -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
|
||||
*/
|
||||
|
@ -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));
|
||||
}
|
@ -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
|
||||
*/
|
||||
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
@ -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
|
||||
*/
|
||||
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user