STM32G070的CPUID地址:- /*!< Device Electronic Signature */. z' u2 I; |2 w! z3 K2 m7 p" o% k C
- #define PACKAGE_BASE (0x1FFF7500UL) /*!< Package data register base address */8 Q+ U: t+ O( ?/ B2 ]9 p
- #define UID_BASE (0x1FFF7590UL) /*!< Unique device ID register base address */
, ~4 O$ I" |; m5 a6 ` - #define FLASHSIZE_BASE (0x1FFF75E0UL) /*!< Flash size data register base address */
4 `) h ^% b* ~6 o - /**
( J5 m4 l. Q0 ^# B% U' n
复制代码
% a9 E- i. A; ]) P; L2 p* _3 p! W, N7 u! H% B% b7 T
HAL库已经预留了API可以直接读取:- /**
0 z3 r7 [* t( X H6 L4 K - * @brief Returns first word of the unique device identifier (UID based on 96 bits)
" t+ M2 `; T1 W" K" c. x - * @retval Device identifier
0 S; i0 \/ C8 g- c - */! a" o3 d4 a& G' A' y
- uint32_t HAL_GetUIDw0(void)
, q! t4 f1 j& a6 T2 S - {
1 ?! B7 H9 P4 h) o0 m) B - return (READ_REG(*((uint32_t *)UID_BASE)));8 k& Q$ o; F1 a7 D% z
- }
0 g, M4 \9 i9 @% Z) U' w - 5 _9 M" K% w! R" ?( \: Z
- /**; z/ f8 o2 q2 Y6 @: [! w n
- * @brief Returns second word of the unique device identifier (UID based on 96 bits). x1 C9 R! q9 E2 e1 O" [
- * @retval Device identifier1 y* u3 d$ ]2 w2 A; T' T A
- */
' P! P5 \6 X4 T - uint32_t HAL_GetUIDw1(void)2 J3 f' s" I2 S6 s
- {
5 R/ j% n3 x! w& N( S, ] - return (READ_REG(*((uint32_t *)(UID_BASE + 4U))));
# r2 v ~4 a) y5 |# i - }
0 L' C# Z3 i- X" q \8 C. ` - + @0 q+ l+ B# n( [2 F3 _5 n
- /**& H: O2 h o, ]2 I0 ~- n
- * @brief Returns third word of the unique device identifier (UID based on 96 bits)
; K1 V% E9 w- Y1 A: }1 r+ | - * @retval Device identifier
8 M4 t9 X& ]" `. }4 w% s: } - */
2 l$ K" @2 t E - uint32_t HAL_GetUIDw2(void)
) S$ i& r/ H6 |# g - {
( l G% U3 A& y8 S% T/ G - return (READ_REG(*((uint32_t *)(UID_BASE + 8U))));
( }* w6 @ x6 E2 O6 i' P' D* U. W' z - }
' B( E5 U8 `1 i; p
$ R5 a: l( Y8 s' X3 ^1 x
复制代码 7 ^/ \8 j* y4 c+ S1 x9 F( g: Z$ I$ |
. f5 `7 z% }( i+ g
( P) g1 S! l1 B1 E/ d
|