diff options
author | Thomas Gubler <thomasgubler@gmail.com> | 2015-01-28 16:29:14 +0100 |
---|---|---|
committer | Thomas Gubler <thomasgubler@gmail.com> | 2015-01-28 16:29:14 +0100 |
commit | 2728889f7886e3ab2fea16941d29e60ece0d4449 (patch) | |
tree | ca9994d71205731ee4bb404175c2cf8f13fcc539 /src/modules/systemlib | |
parent | f23e603d02ba416ae250770cdaad6a859d6bae69 (diff) | |
parent | 1dcc5c49cc75778bcdde770f2d6c2700dd2bec2e (diff) | |
download | px4-firmware-2728889f7886e3ab2fea16941d29e60ece0d4449.tar.gz px4-firmware-2728889f7886e3ab2fea16941d29e60ece0d4449.tar.bz2 px4-firmware-2728889f7886e3ab2fea16941d29e60ece0d4449.zip |
Merge remote-tracking branch 'upstream/master' into ros_messagelayer_merge_attctlposctl
Diffstat (limited to 'src/modules/systemlib')
-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. * |