Added support obtaining the unique id for the stm32g0x1.

Changed copyright to apache copyright. Altered stm32_uid function to take uint32_t pointer instead of a twelve byte uint8_t array. Refined code in stm32_uid.c.

Fixed style and indentation.

Signed-off-by: kywwilson11 <kwilson@2g-eng.com>
This commit is contained in:
kywwilson11 2025-06-05 13:21:19 -05:00 committed by Mateusz Szafoni
parent e9b7dee55a
commit 60c9c66839
5 changed files with 89 additions and 2 deletions

View file

@ -32,7 +32,8 @@ list(
stm32_lowputc.c
stm32_serial.c
stm32_lsi.c
stm32_rcc.c)
stm32_rcc.c
stm32_uid.c)
if(CONFIG_STM32F0L0G0_RTC_LSECLOCK OR CONFIG_LCD_LSECLOCK)
list(APPEND SRCS stm32_lse.c)

View file

@ -23,7 +23,7 @@
include armv6-m/Make.defs
CHIP_CSRCS = stm32_start.c stm32_gpio.c stm32_exti_gpio.c stm32_irq.c
CHIP_CSRCS += stm32_lowputc.c stm32_serial.c stm32_rcc.c stm32_lsi.c
CHIP_CSRCS += stm32_lowputc.c stm32_serial.c stm32_rcc.c stm32_lsi.c stm32_uid.c
ifneq ($(CONFIG_STM32F0L0G0_RTC_LSECLOCK)$(CONFIG_STM32F0L0G0_LCD_LSECLOCK),)
CHIP_CSRCS += stm32_lse.c

View file

@ -123,6 +123,7 @@
* this address range
*/
#define STM32_SYSMEM_UID 0x1fff7590 /* The 96-bit unique device identifier */
#define STM32_SCS_BASE 0xe000e000
#define STM32_DEBUGMCU_BASE 0xe0042000

View file

@ -0,0 +1,47 @@
/****************************************************************************
* arch/arm/src/stm32f0l0g0/stm32_uid.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "hardware/stm32_memorymap.h"
#include "stm32_uid.h"
#ifdef STM32_SYSMEM_UID
/****************************************************************************
* Public Functions
****************************************************************************/
void stm32_get_uniqueid(uint32_t *uid)
{
int i;
for (i = 0; i < 3; i++)
{
*(uid + i) = *((uint32_t *)(STM32_SYSMEM_UID) + i);
}
}
#endif /* STM32_SYSMEM_UID */

View file

@ -0,0 +1,38 @@
/****************************************************************************
* arch/arm/src/stm32f0l0g0/stm32_uid.h
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __ARCH_ARM_SRC_STM32F0L0G0_STM32_UID_H
#define __ARCH_ARM_SRC_STM32F0L0G0_STM32_UID_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdint.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
void stm32_get_uniqueid(uint32_t *uid);
#endif /* __ARCH_ARM_SRC_STM32F0L0G0_STM32_UID_H */