Read UNIQUE ID and flash size method for stm32

/*
  读取stm32的unique id 与 flash size
*/
/*
 func: unsigned int Read_UniqueID_Byte(unsigned char offset)  
 desc: This function is used to read the unique ID in flash.
        parameter offset is the byte offset ,the max is 96/8= 12.
 return: the return value is indicated part of the unique ID.
*/
unsigned char Read_UniqueID_Byte(unsigned char offset)  
{  
    unsigned char id_byte;

        id_byte = *(unsigned char*)(0x1FFFF7E8+offset);           //ID基地址是0x1FFFF7E8

        return id_byte; 
}

/*
 func: unsigned short Read_Flash_Byte(void)  
 desc: This function is used to read flash size .This field value indicates 
    the Flash memory size of the device in Kbytes.
    example:0x100 means this flash size is 256 Kbytes.
        0x080 means this flash size is 128 Kbytes.
 return: the return value is flash size.
*/
unsigned short Read_Flash_Byte(void)  
{  
    unsigned short id_byte;

        id_byte = *(unsigned int*)(0x1FFFF7E0);           //flash size基地址是0x1FFFF7E0 

        return id_byte; 
}
原文地址:https://www.cnblogs.com/shangdawei/p/3386777.html