1.5wuling_zhuanjietou/SYSTEM/chipid.c

70 lines
1.6 KiB
C
Raw Normal View History

2024-10-17 01:06:51 +00:00
/*************************************
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>xxx.c
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡCPU<EFBFBD><EFBFBD>ID<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD>оƬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ψһ<EFBFBD><EFBFBD> 96_bit unique ID
* ʵ<EFBFBD><EFBFBD>ƽ̨<EFBFBD><EFBFBD>MINI STM32<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>STM32F103C8T6
* Ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ST3.0.0
**********************************************************************************/
#include "chipid.h"
#include "led.h"
u32 ChipUniqueID[3];
#define UID_BASE 0x1FF80050
/* <20><>ȡоƬID */
void Get_ChipID(void)
{
ChipUniqueID[0] = *(__IO u32 *)(0X1FFFF7F0); // <20><><EFBFBD>ֽ<EFBFBD>
ChipUniqueID[1] = *(__IO u32 *)(0X1FFFF7EC); //
ChipUniqueID[2] = *(__IO u32 *)(0X1FFFF7E8); // <20><><EFBFBD>ֽ<EFBFBD>
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;
}
}
}
}