diff options
author | hauptmech <hauptmech@gmail.com> | 2015-01-19 16:50:52 +1300 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2015-01-28 10:20:19 +0100 |
commit | 5444972347606333dd61206011263e4a2e5d83e8 (patch) | |
tree | d309fda7ba918708f5dfbff285cb29bd5ee1d08e /src/modules | |
parent | 4dd06c4c7368e14ae0c5119321095236f7d13fd4 (diff) | |
download | px4-firmware-5444972347606333dd61206011263e4a2e5d83e8.tar.gz px4-firmware-5444972347606333dd61206011263e4a2e5d83e8.tar.bz2 px4-firmware-5444972347606333dd61206011263e4a2e5d83e8.zip |
Add call to access the mcu unique id. Expose via the 'ver' command.
This is prep for verifying calibration parameters against the hardware they were gathered on.
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/systemlib/mcu_version.c | 11 | ||||
-rw-r--r-- | src/modules/systemlib/mcu_version.h | 11 |
2 files changed, 20 insertions, 2 deletions
diff --git a/src/modules/systemlib/mcu_version.c b/src/modules/systemlib/mcu_version.c index 4bcf95784..24f4e4207 100644 --- a/src/modules/systemlib/mcu_version.c +++ b/src/modules/systemlib/mcu_version.c @@ -47,7 +47,8 @@ #ifdef CONFIG_ARCH_CHIP_STM32 #include <up_arch.h> -#define DBGMCU_IDCODE 0xE0042000 +#define DBGMCU_IDCODE 0xE0042000 //STM DocID018909 Rev 8 Sect 38.18 (MCU device ID code) +#define UNIQUE_ID 0x1FFF7A10 //STM DocID018909 Rev 8 Sect 39.1 (Unique device ID Register) #define STM32F40x_41x 0x413 #define STM32F42x_43x 0x419 @@ -57,7 +58,13 @@ #endif - +/** Copy the 96bit MCU Unique ID into the provided pointer */ +void mcu_unique_id(uint32_t *uid_96_bit) +{ + uid_96_bit[0] = getreg32(UNIQUE_ID); + uid_96_bit[1] = getreg32(UNIQUE_ID+4); + uid_96_bit[2] = getreg32(UNIQUE_ID+8); +} int mcu_version(char* rev, char** revstr) { diff --git a/src/modules/systemlib/mcu_version.h b/src/modules/systemlib/mcu_version.h index 1b3d0aba9..c8a0bf5cd 100644 --- a/src/modules/systemlib/mcu_version.h +++ b/src/modules/systemlib/mcu_version.h @@ -33,6 +33,8 @@ #pragma once +#include <stdint.h> + /* magic numbers from reference manual */ enum MCU_REV { MCU_REV_STM32F4_REV_A = 0x1000, @@ -42,6 +44,15 @@ enum MCU_REV { MCU_REV_STM32F4_REV_3 = 0x2001 }; + +/** + * Reports the microcontroller unique id. + * + * This ID is guaranteed to be unique for every mcu. + * @param uid_96_bit A uint32_t[3] array to copy the data to. + */ +__EXPORT void mcu_unique_id(uint32_t *uid_96_bit); + /** * Reports the microcontroller version of the main CPU. * |