From 3d6ab85bb32757eb216b33f1a50422c68f965660 Mon Sep 17 00:00:00 2001 From: James Hollister Date: Sat, 7 Mar 2015 12:27:30 -0800 Subject: [PATCH 1/3] cpu/stm32f0: added cpuid_get for stm32f0 --- boards/stm32f0discovery/Makefile.features | 2 +- cpu/stm32f0/include/cpu-conf.h | 5 ++++ cpu/stm32f0/periph/cpuid.c | 31 +++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 cpu/stm32f0/periph/cpuid.c diff --git a/boards/stm32f0discovery/Makefile.features b/boards/stm32f0discovery/Makefile.features index 172ca8e8be..84d6e3a57f 100644 --- a/boards/stm32f0discovery/Makefile.features +++ b/boards/stm32f0discovery/Makefile.features @@ -1,2 +1,2 @@ -FEATURES_PROVIDED += periph_adc periph_gpio periph_spi periph_uart cpp +FEATURES_PROVIDED += periph_adc periph_gpio periph_spi periph_uart cpp periph_cpuid FEATURES_MCU_GROUP = cortex_m0 diff --git a/cpu/stm32f0/include/cpu-conf.h b/cpu/stm32f0/include/cpu-conf.h index cafe961872..a0d7a4cde1 100644 --- a/cpu/stm32f0/include/cpu-conf.h +++ b/cpu/stm32f0/include/cpu-conf.h @@ -58,6 +58,11 @@ extern "C" { #endif /** @} */ +/** + * @brief Length for reading CPU_ID + */ +#define CPUID_ID_LEN (12) + #ifdef __cplusplus } #endif diff --git a/cpu/stm32f0/periph/cpuid.c b/cpu/stm32f0/periph/cpuid.c new file mode 100644 index 0000000000..b958fa3ffa --- /dev/null +++ b/cpu/stm32f0/periph/cpuid.c @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2015 James Hollister + * + * 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 driver_periph + * @{ + * + * @file + * @brief Low-level CPUID driver implementation + * + * @author James Hollister + */ + +#include +#include "cpu-conf.h" + +#include "periph/cpuid.h" + +#define STM32F0_CPUID_ADDR (0x1ffff7ac) + +void cpuid_get(void *id) +{ + memcpy(id, (void *)(STM32F0_CPUID_ADDR), CPUID_ID_LEN); +} + +/** @} */ From 10f4aacf6c058ec675b64400381d25e6d9c690d9 Mon Sep 17 00:00:00 2001 From: James Hollister Date: Sat, 7 Mar 2015 12:28:28 -0800 Subject: [PATCH 2/3] cpu/stm32f3: added cpui_get for stm32f3 --- boards/stm32f3discovery/Makefile.features | 2 +- cpu/stm32f3/include/cpu-conf.h | 5 ++++ cpu/stm32f3/periph/cpuid.c | 31 +++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 cpu/stm32f3/periph/cpuid.c diff --git a/boards/stm32f3discovery/Makefile.features b/boards/stm32f3discovery/Makefile.features index d81085ab26..47b268d36d 100644 --- a/boards/stm32f3discovery/Makefile.features +++ b/boards/stm32f3discovery/Makefile.features @@ -1,3 +1,3 @@ FEATURES_PROVIDED += cpp -FEATURES_PROVIDED += periph_uart periph_gpio periph_pwm periph_spi +FEATURES_PROVIDED += periph_uart periph_gpio periph_pwm periph_spi periph_cpuid FEATURES_MCU_GROUP = cortex_m3_2 diff --git a/cpu/stm32f3/include/cpu-conf.h b/cpu/stm32f3/include/cpu-conf.h index f3a55f3138..1b22573140 100644 --- a/cpu/stm32f3/include/cpu-conf.h +++ b/cpu/stm32f3/include/cpu-conf.h @@ -54,6 +54,11 @@ #endif /** @} */ +/** + * @brief Length for reading CPU_ID + */ +#define CPUID_ID_LEN (12) + #ifdef __cplusplus extern "C" { #endif diff --git a/cpu/stm32f3/periph/cpuid.c b/cpu/stm32f3/periph/cpuid.c new file mode 100644 index 0000000000..b7fb431281 --- /dev/null +++ b/cpu/stm32f3/periph/cpuid.c @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2015 James Hollister + * + * 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 driver_periph + * @{ + * + * @file + * @brief Low-level CPUID driver implementation + * + * @author James Hollister + */ + +#include +#include "cpu-conf.h" + +#include "periph/cpuid.h" + +#define STM32F3_CPUID_ADDR (0x1ffff7ac) + +void cpuid_get(void *id) +{ + memcpy(id, (void *)(STM32F3_CPUID_ADDR), CPUID_ID_LEN); +} + +/** @} */ From 722835989dd1bbc8b28f8ba41caea10ad9a2a61b Mon Sep 17 00:00:00 2001 From: James Hollister Date: Sun, 8 Mar 2015 12:18:37 -0700 Subject: [PATCH 3/3] cpu/stm32f4: added cpuid_get to stm32f4 --- boards/stm32f4discovery/Makefile.features | 2 +- cpu/stm32f4/include/cpu-conf.h | 5 ++++ cpu/stm32f4/periph/cpuid.c | 31 +++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 cpu/stm32f4/periph/cpuid.c diff --git a/boards/stm32f4discovery/Makefile.features b/boards/stm32f4discovery/Makefile.features index 488ed7842b..5585854cbc 100644 --- a/boards/stm32f4discovery/Makefile.features +++ b/boards/stm32f4discovery/Makefile.features @@ -1,4 +1,4 @@ FEATURES_PROVIDED += cpp FEATURES_PROVIDED += periph_uart periph_gpio periph_spi periph_i2c periph_pwm periph_random \ - periph_adc periph_dac + periph_adc periph_dac periph_cpuid FEATURES_MCU_GROUP = cortex_m4 diff --git a/cpu/stm32f4/include/cpu-conf.h b/cpu/stm32f4/include/cpu-conf.h index a3bdeb3324..c77ccf1411 100644 --- a/cpu/stm32f4/include/cpu-conf.h +++ b/cpu/stm32f4/include/cpu-conf.h @@ -53,6 +53,11 @@ #endif /** @} */ +/** + * @brief Length for reading CPU_ID + */ +#define CPUID_ID_LEN (12) + /** * @name CC110X buffer size definitions for the stm32f4 * @{ diff --git a/cpu/stm32f4/periph/cpuid.c b/cpu/stm32f4/periph/cpuid.c new file mode 100644 index 0000000000..61f760cb00 --- /dev/null +++ b/cpu/stm32f4/periph/cpuid.c @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2015 James Hollister + * + * 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 driver_periph + * @{ + * + * @file + * @brief Low-level CPUID driver implementation + * + * @author James Hollister + */ + +#include +#include "cpu-conf.h" + +#include "periph/cpuid.h" + +#define STM32F4_CPUID_ADDR (0x1fff7a10) + +void cpuid_get(void *id) +{ + memcpy(id, (void *)(STM32F4_CPUID_ADDR), CPUID_ID_LEN); +} + +/** @} */