云途芯片UID压缩指南
-
UID 介绍
UID是芯片唯一编码,这个编码主要是依据芯片生产的信息产生的,每个芯片都有唯一的ID,部分芯片的UID信息可以从CIM模块获取,后面新的芯片则直接通过Flash区域读取。
在生产阶段UID都是在芯片测试阶段写入的,因为规则不用,UID长度基本都是128比特,这个长度对于很多应用来讲长度太长,所以这里提供了对UID进行压缩的方法,可以实现将128比特压缩到64比特。
YTM32B1LE0x
包含LE05x和LE04x系列芯片,可以通过如下函数获取64比特长度的UID信息:
void SystemGetUid(uint32_t *uidh, uint32_t *uidl) { /* UID store in FLASH */ *uidh = ((*(uint8_t*)0x10000FE0) & 0xFU) << 0U | ((*(uint8_t*)0x10000FE1) & 0xFU) << 4U | ((*(uint8_t*)0x10000FE2) & 0xFU) << 8U | ((*(uint8_t*)0x10000FE3) & 0xFU) << 12U | ((*(uint8_t*)0x10000FE4) & 0xFU) << 16U | ((*(uint8_t*)0x10000FE5) & 0xFU) << 20U; *uidl = ((*(uint8_t*)0x10000FED) & 0xFFU) << 0U | ((*(uint8_t*)0x10000FEC) & 0xFFU) << 8U | ((*(uint8_t*)0x10000FE8) & 0xFFU) << 16U | ((*(uint8_t*)0x10000F40) & 0xFFU) << 24U; }
YTM32B1MC0x
void SystemGetUid(uint32_t *uidh, uint32_t *uidl) { /* UID store in FLASH */ *uidh = ((*(uint8_t*)0x10013F28) & 0xFU) << 0U | ((*(uint8_t*)0x10013F29) & 0xFU) << 4U | ((*(uint8_t*)0x10013F2A) & 0xFU) << 8U | ((*(uint8_t*)0x10013F2B) & 0xFU) << 12U | ((*(uint8_t*)0x10013F2C) & 0xFU) << 16U | ((*(uint8_t*)0x10013F2D) & 0xFU) << 20U; *uidl = ((*(uint8_t*)0x10013F40) & 0xFFU) << 0U | ((*(uint8_t*)0x10013F38) & 0xFFU) << 8U | ((*(uint8_t*)0x10013F30) & 0xFFU) << 16U | ((*(uint8_t*)0x10013F58) & 0xFFU) << 24U; }
YTM32B1HA0x
UID通过CIM读取,读取前需要开启CIM的时钟。
void SystemGetUid(uint32_t *uidh, uint32_t *uidl) { /* UID store in CIM */ *uidh = (CIM->UID0 >> 0U & 0xFU) << 0U | (CIM->UID0 >> 8U & 0xFU) << 4U | (CIM->UID0 >> 16U & 0xFU) << 8U | (CIM->UID0 >> 24U & 0xFU) << 12U | (CIM->UID1 >> 0U & 0xFU) << 16U | (CIM->UID1 >> 8U & 0xFFU) << 20U; *uidl = (CIM->UID2 >> 0U & 0xFFFFU) << 0U | (CIM->UID3 >> 0U & 0xFFFFU) << 16U; }
YTM32B1MD1x
UID通过CIM读取,读取前需要开启CIM的时钟。
void SystemGetUid(uint32_t *uidh, uint32_t *uidl) { /* UID store in CIM */ *uidh = (CIM->UID0 >> 0U & 0xFU) << 0U | (CIM->UID0 >> 8U & 0xFU) << 4U | (CIM->UID0 >> 16U & 0xFU) << 8U | (CIM->UID0 >> 24U & 0xFU) << 12U | (CIM->UID1 >> 0U & 0xFU) << 16U | (CIM->UID1 >> 8U & 0xFFU) << 20U; *uidl = (CIM->UID2 >> 0U & 0xFFFFU) << 0U | (CIM->UID3 >> 0U & 0xFFFFU) << 16U; }
YTM32B1ME0x
UID通过CIM读取,读取前需要开启CIM的时钟。
void SystemGetUid(uint32_t *uidh, uint32_t *uidl) { /* UID store in CIM */ *uidh = (CIM->UID0 >> 0U & 0xFU) << 0U | (CIM->UID0 >> 8U & 0xFU) << 4U | (CIM->UID0 >> 16U & 0xFU) << 8U | (CIM->UID0 >> 24U & 0xFU) << 12U | (CIM->UID1 >> 0U & 0xFU) << 16U | (CIM->UID1 >> 8U & 0xFFU) << 20U; *uidl = (CIM->UID2 >> 0U & 0xFFFFU) << 0U | (CIM->UID3 >> 0U & 0xFFFFU) << 16U; }
-
M major 被引用 于这个主题
快速上手云途开发生态
发帖前请查看
帮助改进和优化YT CONFIG TOOL,有机会抽取YTM32B1ME0 EVB哦...