STM32G070的CPUID地址:- /*!< Device Electronic Signature */. A+ w2 P4 _+ N+ s% E& x* ?
- #define PACKAGE_BASE (0x1FFF7500UL) /*!< Package data register base address */+ g! ]# i4 i/ L7 R6 I5 ?
- #define UID_BASE (0x1FFF7590UL) /*!< Unique device ID register base address */
( M/ ~1 w% `$ J( | - #define FLASHSIZE_BASE (0x1FFF75E0UL) /*!< Flash size data register base address */
- @: L8 |/ s! \: B, W - /**
@% P$ v a) A$ r
复制代码
( }' f, t6 G$ ~6 G3 F* E$ e" ?% Y$ r1 l5 K( k/ s
HAL库已经预留了API可以直接读取:- /**! ~# b4 G! r1 Z4 `2 K5 L
- * @brief Returns first word of the unique device identifier (UID based on 96 bits)! U) d, W- P8 B, `6 `7 y8 D
- * @retval Device identifier
) X1 ^0 `" [9 w: m3 v- t7 W+ f - */7 Y% ^9 k6 `3 ~( V( P4 |/ ], h
- uint32_t HAL_GetUIDw0(void)
9 o# G4 P, ^% ~4 t: U3 h - {
" G9 U' i" T. C' t) L, G( [6 L - return (READ_REG(*((uint32_t *)UID_BASE)));
. Z* G( M' M' x4 X: y0 L5 U - }
Z% J( ~/ k6 g& k# H* L( O - / l. Y q' ]! c6 j+ a
- /**
( T6 }& c- c' `! [ - * @brief Returns second word of the unique device identifier (UID based on 96 bits)% t# s0 \& c( [& S
- * @retval Device identifier
4 g8 J, o" \4 H( E e - */
+ J. W3 ]- S# ~9 J5 N: X; j/ D - uint32_t HAL_GetUIDw1(void)
% P& Z/ U" t B- j1 W - {
1 E9 n# Z* v( o# g4 z# Q4 b - return (READ_REG(*((uint32_t *)(UID_BASE + 4U))));
. l1 c2 s1 X/ F$ f - }) O- U$ e) ]1 f, \6 h0 G
9 g6 {" Y7 s: d: H1 K; q- /**, F; j. Z. b" S0 b1 {: V; U
- * @brief Returns third word of the unique device identifier (UID based on 96 bits)
6 k7 ~# K) J* P) \- K5 i4 d& _9 H - * @retval Device identifier
" q/ h1 f( y+ j2 W! v7 \ - */. a; f, Q2 R! c5 R! b7 h
- uint32_t HAL_GetUIDw2(void)
* C! `; j; i1 b# U; R$ f$ O - {; ]0 S& N1 N3 L" E' b/ _# y
- return (READ_REG(*((uint32_t *)(UID_BASE + 8U))));
a9 ^0 p; B. G- ~' f( Z. q! A* ` - }
) C2 a, X4 |! \6 s. D5 V$ H - 6 G' ~ i, P1 X* y3 \: J# p' l2 h$ F
复制代码
3 Y f5 j& q: P# x; p* u) W3 r
& V S5 l# S* G) n6 ]. D) b% P5 C3 K K4 x% ?( k6 y
|