2019-08-19 17:16:08 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* boards/arm/stm32/shenzhou/src/stm32_chipid.c
|
2012-11-27 17:26:54 +01:00
|
|
|
*
|
2021-03-19 12:39:00 +01:00
|
|
|
* 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
|
2012-11-27 17:26:54 +01:00
|
|
|
*
|
2021-03-19 12:39:00 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2012-11-27 17:26:54 +01:00
|
|
|
*
|
2021-03-19 12:39:00 +01:00
|
|
|
* 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.
|
2012-11-27 17:26:54 +01:00
|
|
|
*
|
2019-08-19 17:16:08 +02:00
|
|
|
****************************************************************************/
|
2012-11-27 17:26:54 +01:00
|
|
|
|
2019-08-19 17:16:08 +02:00
|
|
|
/****************************************************************************
|
2012-11-27 17:26:54 +01:00
|
|
|
* Included Files
|
2019-08-19 17:16:08 +02:00
|
|
|
****************************************************************************/
|
2012-11-27 17:26:54 +01:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <arch/board/board.h>
|
|
|
|
|
2020-05-01 03:20:29 +02:00
|
|
|
#include "arm_arch.h"
|
2012-11-27 17:26:54 +01:00
|
|
|
|
2019-08-19 17:16:08 +02:00
|
|
|
/****************************************************************************
|
2015-03-21 16:10:42 +01:00
|
|
|
* Pre-processor Definitions
|
2019-08-19 17:16:08 +02:00
|
|
|
****************************************************************************/
|
2012-11-27 17:26:54 +01:00
|
|
|
|
2019-08-19 17:16:08 +02:00
|
|
|
/****************************************************************************
|
2012-11-27 17:26:54 +01:00
|
|
|
* Private Functions
|
2019-08-19 17:16:08 +02:00
|
|
|
****************************************************************************/
|
2012-11-27 17:26:54 +01:00
|
|
|
|
2019-08-19 17:16:08 +02:00
|
|
|
/****************************************************************************
|
2012-11-27 17:26:54 +01:00
|
|
|
* Public Functions
|
2019-08-19 17:16:08 +02:00
|
|
|
****************************************************************************/
|
2012-11-27 17:26:54 +01:00
|
|
|
|
|
|
|
const char *stm32_getchipid(void)
|
|
|
|
{
|
|
|
|
static char cpuid[12];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 12; i++)
|
|
|
|
{
|
2021-03-20 13:01:22 +01:00
|
|
|
cpuid[i] = getreg8(0x1ffff7e8 + i);
|
2012-11-27 17:26:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return cpuid;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *stm32_getchipid_string(void)
|
|
|
|
{
|
|
|
|
static char cpuid[27];
|
|
|
|
int c;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0, c = 0; i < 12; i++)
|
|
|
|
{
|
2021-03-20 13:01:22 +01:00
|
|
|
sprintf(&cpuid[c], "%02X", getreg8(0x1ffff7e8 + 11 - i));
|
2012-11-27 17:26:54 +01:00
|
|
|
c += 2;
|
|
|
|
if (i % 4 == 3)
|
|
|
|
{
|
|
|
|
cpuid[c++] = '-';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cpuid[26] = '\0';
|
|
|
|
return cpuid;
|
|
|
|
}
|