70 lines
1.6 KiB
C
70 lines
1.6 KiB
C
/*************************************
|
||
* 文件名 :xxx.c
|
||
* 描述 :获取CPU的ID函数,每个芯片都有唯一的 96_bit unique ID
|
||
* 实验平台:MINI STM32开发板 基于STM32F103C8T6
|
||
* 硬件连接:无
|
||
* 库版本 :ST3.0.0
|
||
|
||
**********************************************************************************/
|
||
|
||
|
||
#include "chipid.h"
|
||
|
||
#include "led.h"
|
||
|
||
|
||
u32 ChipUniqueID[3];
|
||
#define UID_BASE 0x1FF80050
|
||
/* 获取芯片ID */
|
||
void Get_ChipID(void)
|
||
{
|
||
ChipUniqueID[0] = *(__IO u32 *)(0X1FFFF7F0); // 高字节
|
||
ChipUniqueID[1] = *(__IO u32 *)(0X1FFFF7EC); //
|
||
ChipUniqueID[2] = *(__IO u32 *)(0X1FFFF7E8); // 低字节
|
||
|
||
if(ChipUniqueID[0]==0xFFFFFFFF)
|
||
{
|
||
|
||
ChipUniqueID[0] = (uint32_t)(*((uint32_t *)UID_BASE));
|
||
ChipUniqueID[1] = (uint32_t)(*((uint32_t *)(UID_BASE + 0x04)));
|
||
ChipUniqueID[2] = (uint32_t)(*((uint32_t *)(UID_BASE + 0x14)));
|
||
}
|
||
|
||
|
||
|
||
}
|
||
u32 ChipUniqueIDdecodeflag;
|
||
uint8_t ChipUniqueIDCompare(void)
|
||
{
|
||
if((SysParaPileD.ChipUniqueID[0] == ChipUniqueID[0])&&(SysParaPileD.ChipUniqueID[1] == ChipUniqueID[1])
|
||
&& (SysParaPileD.ChipUniqueID[2] == ChipUniqueID[2]))
|
||
{
|
||
return 1;
|
||
}
|
||
else
|
||
{
|
||
MCU_LED(1);
|
||
while (1)
|
||
{
|
||
MCU_LED(1);
|
||
IWDG_Feed();
|
||
ChipUniqueIDdecodeflag =1;
|
||
if(ChipUniqueIDdecodeflag==1)
|
||
{
|
||
ChipUniqueIDdecodeflag =0;
|
||
SysParaPileD.ChipUniqueID[0] = ChipUniqueID[0];
|
||
SysParaPileD.ChipUniqueID[1] = ChipUniqueID[1];
|
||
SysParaPileD.ChipUniqueID[2] = ChipUniqueID[2];
|
||
Delay_MS(5);
|
||
SysParaPileD.bluetooth_passward[4]=0x35;
|
||
SysParaPileD.bluetooth_passward[5]=0x36;
|
||
SysWriteSysParm();
|
||
Delay_MS(5);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|