From 4b9b174c7f646afff74287968da0c06f745e6796 Mon Sep 17 00:00:00 2001 From: Boting Ren Date: Wed, 23 Aug 2017 11:06:44 +0900 Subject: [PATCH] Add function to read 12byte HW RoT over STM32L4xx. --- .../TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal.c | 12 ++++++++++++ .../TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal.h | 1 + 2 files changed, 13 insertions(+) diff --git a/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal.c b/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal.c index 285da086c5..c405cd0028 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal.c +++ b/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal.c @@ -403,6 +403,18 @@ uint32_t HAL_GetDEVID(void) return(DBGMCU->IDCODE & DBGMCU_IDCODE_DEV_ID); } +/** + * @brief Return the unique device identifier (UID based on 96 bits) + * @param UID: pointer to 3 words array. + * @retval Device identifier + */ +void HAL_GetUID_12Byte(uint32_t *UID) +{ + UID[0] = (uint32_t)(READ_REG(*((uint32_t *)UID_BASE))); + UID[1] = (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE + 4U)))); + UID[2] = (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE + 8U)))); +} + /** * @brief Return the first word of the unique device identifier (UID based on 96 bits) * @retval Device identifier diff --git a/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal.h b/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal.h index 7e98496f8f..deba9f507c 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal.h +++ b/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal.h @@ -582,6 +582,7 @@ void HAL_ResumeTick(void); uint32_t HAL_GetHalVersion(void); uint32_t HAL_GetREVID(void); uint32_t HAL_GetDEVID(void); +void HAL_GetUID_12Byte(uint32_t *UID); uint32_t HAL_GetUIDw0(void); uint32_t HAL_GetUIDw1(void); uint32_t HAL_GetUIDw2(void);