cpu/stm32: use common CPUID implementation

This commit is contained in:
Hauke Petersen 2016-02-08 21:54:37 +01:00
parent 7c5bab6ac0
commit ea8db10524
26 changed files with 50 additions and 178 deletions

View File

@ -25,6 +25,11 @@
extern "C" { extern "C" {
#endif #endif
/**
* @brief Length of the CPU_ID in octets
*/
#define CPUID_LEN (12U)
/** /**
* @brief Use the shared SPI functions * @brief Use the shared SPI functions
* @{ * @{

View File

@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2014-2016 Freie Universität Berlin * Copyright (C) 2014-2016 Freie Universität Berlin
* Copyright (C) 2015 James Hollister
* *
* This file is subject to the terms and conditions of the GNU Lesser * 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 * General Public License v2.1. See the file LICENSE in the top level
@ -7,24 +8,27 @@
*/ */
/** /**
* @addtogroup cpu_stm32l1 * @addtogroup cpu_stm32_common
* @{ * @{
* *
* @file * @file
* @brief Low-level CPUID driver implementation * @brief Implementation of the CPUID driver interface
* *
* @author Thomas Eichinger <thomas.eichinger@fu-berlin.de> * @author Thomas Eichinger <thomas.eichinger@fu-berlin.de>
* @author James Hollister <jhollisterjr@gmail.com>
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* *
* @} * @}
*/ */
#include <stdint.h>
#include <string.h> #include <string.h>
#include "periph/cpuid.h" #include "periph/cpuid.h"
extern volatile uint32_t _cpuid_address[3]; extern uint32_t *_cpuid_address;
void cpuid_get(void *id) void cpuid_get(void *id)
{ {
memcpy(id, (void *)(&_cpuid_address), CPUID_LEN); memcpy(id, _cpuid_address, CPUID_LEN);
} }

View File

@ -19,26 +19,13 @@
#ifndef PERIPH_CPU_H #ifndef PERIPH_CPU_H
#define PERIPH_CPU_H #define PERIPH_CPU_H
#include "cpu.h"
#include "periph_cpu_common.h" #include "periph_cpu_common.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/** /* to be filled */
* @brief Length of the CPU_ID in octets
*/
#define CPUID_LEN (12U)
/**
* @brief declare needed generic SPI functions
* @{
*/
#define PERIPH_SPI_NEEDS_TRANSFER_BYTES
#define PERIPH_SPI_NEEDS_TRANSFER_REG
#define PERIPH_SPI_NEEDS_TRANSFER_REGS
/** @} */
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -22,6 +22,9 @@ MEMORY
{ {
rom (rx) : ORIGIN = 0x08000000, LENGTH = 64K rom (rx) : ORIGIN = 0x08000000, LENGTH = 64K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 8K ram (rwx) : ORIGIN = 0x20000000, LENGTH = 8K
cpuid (r) : ORIGIN = 0x1ffff7ac, LENGTH = 12
} }
_cpuid_address = ORIGIN(cpuid);
INCLUDE cortexm_base.ld INCLUDE cortexm_base.ld

View File

@ -22,6 +22,9 @@ MEMORY
{ {
rom (rx) : ORIGIN = 0x08000000, LENGTH = 256K rom (rx) : ORIGIN = 0x08000000, LENGTH = 256K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 32K ram (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
cpuid (r) : ORIGIN = 0x1ffff7ac, LENGTH = 12
} }
_cpuid_address = ORIGIN(cpuid);
INCLUDE cortexm_base.ld INCLUDE cortexm_base.ld

View File

@ -1,30 +0,0 @@
/*
* 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 cpu_stm32f0
* @{
*
* @file
* @brief Low-level CPUID driver implementation
*
* @author James Hollister <jhollisterjr@gmail.com>
*
* @}
*/
#include <string.h>
#include "periph/cpuid.h"
#define STM32F0_CPUID_ADDR (0x1ffff7ac)
void cpuid_get(void *id)
{
memcpy(id, (void *)(STM32F0_CPUID_ADDR), CPUID_LEN);
}

View File

@ -19,7 +19,6 @@
#ifndef PERIPH_CPU_H #ifndef PERIPH_CPU_H
#define PERIPH_CPU_H #define PERIPH_CPU_H
#include "cpu.h"
#include "periph_cpu_common.h" #include "periph_cpu_common.h"
#ifdef __cplusplus #ifdef __cplusplus
@ -44,11 +43,6 @@ typedef uint32_t gpio_t;
*/ */
#define GPIO_PIN(x, y) ((GPIOA_BASE + (x << 10)) | y) #define GPIO_PIN(x, y) ((GPIOA_BASE + (x << 10)) | y)
/**
* @brief Length of the CPU_ID in octets
*/
#define CPUID_LEN (12U)
/** /**
* @brief Override values for pull register configuration * @brief Override values for pull register configuration
* @{ * @{

View File

@ -22,6 +22,9 @@ MEMORY
{ {
rom (rx) : ORIGIN = 0x08000000, LENGTH = 64K rom (rx) : ORIGIN = 0x08000000, LENGTH = 64K
ram (xrw) : ORIGIN = 0x20000000, LENGTH = 20K ram (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
cpuid (r) : ORIGIN = 0x1ffff7e8, LENGTH = 12
} }
_cpuid_address = ORIGIN(cpuid);
INCLUDE cortexm_base.ld INCLUDE cortexm_base.ld

View File

@ -22,6 +22,9 @@ MEMORY
{ {
rom (rx) : ORIGIN = 0x08005000, LENGTH = 128K-0x5000 rom (rx) : ORIGIN = 0x08005000, LENGTH = 128K-0x5000
ram (xrw) : ORIGIN = 0x20000000, LENGTH = 20K ram (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
cpuid (r) : ORIGIN = 0x1ffff7e8, LENGTH = 12
} }
_cpuid_address = ORIGIN(cpuid);
INCLUDE cortexm_base.ld INCLUDE cortexm_base.ld

View File

@ -22,6 +22,9 @@ MEMORY
{ {
rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
ram (xrw) : ORIGIN = 0x20000000, LENGTH = 20K ram (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
cpuid (r) : ORIGIN = 0x1ffff7e8, LENGTH = 12
} }
_cpuid_address = ORIGIN(cpuid);
INCLUDE cortexm_base.ld INCLUDE cortexm_base.ld

View File

@ -22,6 +22,9 @@ MEMORY
{ {
rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K
ram (xrw) : ORIGIN = 0x20000000, LENGTH = 64K ram (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
cpuid (r) : ORIGIN = 0x1ffff7e8, LENGTH = 12
} }
_cpuid_address = ORIGIN(cpuid);
INCLUDE cortexm_base.ld INCLUDE cortexm_base.ld

View File

@ -1,28 +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_stm32f1
* @{
*
* @file
* @brief Low-level CPUID driver implementation
*
* @author Thomas Eichinger <thomas.eichinger@fu-berlin.de>
*
* @}
*/
#include <string.h>
#include "periph/cpuid.h"
void cpuid_get(void *id)
{
memcpy(id, (void *)(0x1ffff7e8), CPUID_LEN);
}

View File

@ -19,7 +19,6 @@
#ifndef PERIPH_CPU_H #ifndef PERIPH_CPU_H
#define PERIPH_CPU_H #define PERIPH_CPU_H
#include "cpu.h"
#include "periph_cpu_common.h" #include "periph_cpu_common.h"
#ifdef __cplusplus #ifdef __cplusplus
@ -44,11 +43,6 @@ typedef uint32_t gpio_t;
*/ */
#define GPIO_PIN(x, y) ((GPIOA_BASE + (x << 10)) | y) #define GPIO_PIN(x, y) ((GPIOA_BASE + (x << 10)) | y)
/**
* @brief Length of the CPU_ID in octets
*/
#define CPUID_LEN (12U)
/** /**
* @brief Available ports on the STM32F3 family * @brief Available ports on the STM32F3 family
*/ */

View File

@ -25,6 +25,9 @@ MEMORY
rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
ccmram (rwx): ORIGIN = 0x10000000, LENGTH = 16K ccmram (rwx): ORIGIN = 0x10000000, LENGTH = 16K
cpuid (r) : ORIGIN = 0x1ffff7ac, LENGTH = 12
} }
_cpuid_address = ORIGIN(cpuid);
INCLUDE cortexm_base.ld INCLUDE cortexm_base.ld

View File

@ -23,6 +23,9 @@ MEMORY
rom (rx) : ORIGIN = 0x08000000, LENGTH = 256K rom (rx) : ORIGIN = 0x08000000, LENGTH = 256K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 40K ram (rwx) : ORIGIN = 0x20000000, LENGTH = 40K
ccmram (rwx): ORIGIN = 0x10000000, LENGTH = 8K ccmram (rwx): ORIGIN = 0x10000000, LENGTH = 8K
cpuid (r) : ORIGIN = 0x1ffff7ac, LENGTH = 12
} }
_cpuid_address = ORIGIN(cpuid);
INCLUDE cortexm_base.ld INCLUDE cortexm_base.ld

View File

@ -23,6 +23,9 @@ MEMORY
rom (rx) : ORIGIN = 0x08000000, LENGTH = 64K rom (rx) : ORIGIN = 0x08000000, LENGTH = 64K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 12K ram (rwx) : ORIGIN = 0x20000000, LENGTH = 12K
ccmram (rwx): ORIGIN = 0x10000000, LENGTH = 4K ccmram (rwx): ORIGIN = 0x10000000, LENGTH = 4K
cpuid (r) : ORIGIN = 0x1ffff7ac, LENGTH = 12
} }
_cpuid_address = ORIGIN(cpuid);
INCLUDE cortexm_base.ld INCLUDE cortexm_base.ld

View File

@ -1,30 +0,0 @@
/*
* 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 cpu_stm32f3
* @{
*
* @file
* @brief Low-level CPUID driver implementation
*
* @author James Hollister <jhollisterjr@gmail.com>
*
* @}
*/
#include <string.h>
#include "periph/cpuid.h"
#define STM32F3_CPUID_ADDR (0x1ffff7ac)
void cpuid_get(void *id)
{
memcpy(id, (void *)(STM32F3_CPUID_ADDR), CPUID_LEN);
}

View File

@ -19,7 +19,6 @@
#ifndef PERIPH_CPU_H #ifndef PERIPH_CPU_H
#define PERIPH_CPU_H #define PERIPH_CPU_H
#include "cpu.h"
#include "periph_cpu_common.h" #include "periph_cpu_common.h"
#ifdef __cplusplus #ifdef __cplusplus
@ -44,11 +43,6 @@ typedef uint32_t gpio_t;
*/ */
#define GPIO_PIN(x, y) ((GPIOA_BASE + (x << 10)) | y) #define GPIO_PIN(x, y) ((GPIOA_BASE + (x << 10)) | y)
/**
* @brief Length of the CPU_ID in octets
*/
#define CPUID_LEN (12U)
/** /**
* @brief Available ports on the STM32F4 family * @brief Available ports on the STM32F4 family
*/ */

View File

@ -22,6 +22,9 @@ MEMORY
{ {
rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 96K ram (rwx) : ORIGIN = 0x20000000, LENGTH = 96K
cpuid (r) : ORIGIN = 0x1fff7a10, LENGTH = 12
} }
_cpuid_address = ORIGIN(cpuid);
INCLUDE cortexm_base.ld INCLUDE cortexm_base.ld

View File

@ -23,6 +23,9 @@ MEMORY
rom (rx) : ORIGIN = 0x08000000, LENGTH = 1024K rom (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 128K ram (rwx) : ORIGIN = 0x20000000, LENGTH = 128K
ccmram (rwx): ORIGIN = 0x10000000, LENGTH = 64K ccmram (rwx): ORIGIN = 0x10000000, LENGTH = 64K
cpuid (r) : ORIGIN = 0x1fff7a10, LENGTH = 12
} }
_cpuid_address = ORIGIN(cpuid);
INCLUDE cortexm_base.ld INCLUDE cortexm_base.ld

View File

@ -23,6 +23,9 @@ MEMORY
rom (rx) : ORIGIN = 0x08000000, LENGTH = 1024K rom (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 128K ram (rwx) : ORIGIN = 0x20000000, LENGTH = 128K
ccmram (rwx): ORIGIN = 0x10000000, LENGTH = 64K ccmram (rwx): ORIGIN = 0x10000000, LENGTH = 64K
cpuid (r) : ORIGIN = 0x1fff7a10, LENGTH = 12
} }
_cpuid_address = ORIGIN(cpuid);
INCLUDE cortexm_base.ld INCLUDE cortexm_base.ld

View File

@ -1,30 +0,0 @@
/*
* 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 cpu_stm32f4
* @{
*
* @file
* @brief Low-level CPUID driver implementation
*
* @author James Hollister <jhollisterjr@gmail.com>
*
* @}
*/
#include <string.h>
#include "periph/cpuid.h"
#define STM32F4_CPUID_ADDR (0x1fff7a10)
void cpuid_get(void *id)
{
memcpy(id, (void *)(STM32F4_CPUID_ADDR), CPUID_LEN);
}

View File

@ -21,7 +21,6 @@
#ifndef PERIPH_CPU_H #ifndef PERIPH_CPU_H
#define PERIPH_CPU_H #define PERIPH_CPU_H
#include "cpu.h"
#include "periph_cpu_common.h" #include "periph_cpu_common.h"
#ifdef __cplusplus #ifdef __cplusplus
@ -46,11 +45,6 @@ typedef uint32_t gpio_t;
*/ */
#define GPIO_PIN(x, y) ((GPIOA_BASE + (x << 10)) | y) #define GPIO_PIN(x, y) ((GPIOA_BASE + (x << 10)) | y)
/**
* @brief Length of the CPU_ID in octets
*/
#define CPUID_LEN (12U)
/** /**
* @brief Available ports on the STM32L1 family * @brief Available ports on the STM32L1 family
*/ */

View File

@ -22,12 +22,6 @@ MEMORY
{ {
rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
ram (rw) : ORIGIN = 0x20000000, LENGTH = 32K ram (rw) : ORIGIN = 0x20000000, LENGTH = 32K
/* see STM32L1 Reference Manual (31.2 Unique device ID registers (96 bits))
* Base address:
* - 0x1FF80050 for Cat.1 and Cat.2 devices
* - 0x1FF800D0 for Cat.3, Cat.4, Cat.5 and Cat.6 devices
*/
cpuid (r) : ORIGIN = 0x1ff80050, LENGTH = 12 cpuid (r) : ORIGIN = 0x1ff80050, LENGTH = 12
} }

View File

@ -22,12 +22,6 @@ MEMORY
{ {
rom (rx) : ORIGIN = 0x08000000, LENGTH = 256K rom (rx) : ORIGIN = 0x08000000, LENGTH = 256K
ram (xrw) : ORIGIN = 0x20000000, LENGTH = 32K ram (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
/* see STM32L1 Reference Manual (31.2 Unique device ID registers (96 bits))
* Base address:
* - 0x1FF80050 for Cat.1 and Cat.2 devices
* - 0x1FF800D0 for Cat.3, Cat.4, Cat.5 and Cat.6 devices
*/
cpuid (r) : ORIGIN = 0x1ff800d0, LENGTH = 12 cpuid (r) : ORIGIN = 0x1ff800d0, LENGTH = 12
} }

View File

@ -22,12 +22,6 @@ MEMORY
{ {
rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K
ram (xrw) : ORIGIN = 0x20000000, LENGTH = 80K ram (xrw) : ORIGIN = 0x20000000, LENGTH = 80K
/* see STM32L1 Reference Manual (31.2 Unique device ID registers (96 bits))
* Base address:
* - 0x1FF80050 for Cat.1 and Cat.2 devices
* - 0x1FF800D0 for Cat.3, Cat.4, Cat.5 and Cat.6 devices
*/
cpuid (r) : ORIGIN = 0x1ff800d0, LENGTH = 12 cpuid (r) : ORIGIN = 0x1ff800d0, LENGTH = 12
} }