STM32G070的CPUID地址:- /*!< Device Electronic Signature */
0 i* V! o0 b+ T' I v* i - #define PACKAGE_BASE (0x1FFF7500UL) /*!< Package data register base address */( n( K* S" C/ g( p' P3 \" x1 \
- #define UID_BASE (0x1FFF7590UL) /*!< Unique device ID register base address */% k* r$ ]; s+ D/ B
- #define FLASHSIZE_BASE (0x1FFF75E0UL) /*!< Flash size data register base address */4 B& |+ w; k. `0 e- d: X& \8 S
- /**1 Q3 g1 D; {9 X' x
复制代码 0 M. V" V5 \9 n* e: {
9 Y& K% S* H Z+ g, tHAL库已经预留了API可以直接读取:- /**, J2 r8 s' K9 i% [" m4 f/ [* b( _
- * @brief Returns first word of the unique device identifier (UID based on 96 bits)
" n' e; m9 n& V0 x( c& c - * @retval Device identifier0 s6 u& w$ l/ k- F$ L
- */! l6 _, j# M. Y; F2 n; N
- uint32_t HAL_GetUIDw0(void)
* s7 @2 ?2 ?7 _ - {
# ]& u; o9 G6 ~' p% H' w - return (READ_REG(*((uint32_t *)UID_BASE)));
3 B; J/ {8 E+ Y6 W$ c+ p& Z - }
) n2 P. t) h8 j) x$ F3 |; `3 K) @# [ - - x" ?+ P! }* W
- /**
. i0 K) |8 S8 o: `; j - * @brief Returns second word of the unique device identifier (UID based on 96 bits)- s5 j! L2 D/ r7 S# G. l
- * @retval Device identifier
, O- ]) S9 d9 M5 S - */7 _0 x+ s( u# f `
- uint32_t HAL_GetUIDw1(void)
0 {6 t0 }+ C/ z1 j) c5 I - {
' o' S( p! U& q$ G/ E - return (READ_REG(*((uint32_t *)(UID_BASE + 4U))));
+ T# d; Z) g! O' X# ] - }
5 x. q- O0 J. N! {) ~ P t
6 L: ~9 t1 B( J: k/ }! r( t L' a- /**9 j& a1 \( s; n- L8 y) B" v
- * @brief Returns third word of the unique device identifier (UID based on 96 bits), W, E5 q9 r; C$ e2 k! b
- * @retval Device identifier8 e6 p# T @0 v1 K1 o
- */4 n' ~" r1 K, q2 v: k
- uint32_t HAL_GetUIDw2(void)
4 S4 f% r9 Q9 |$ E8 P$ o9 k" s - {( |( a$ s' w* t4 C
- return (READ_REG(*((uint32_t *)(UID_BASE + 8U))));$ O1 ^6 h" \2 I( U# x( F! v
- }& R) m4 c2 `% t$ h ]4 a
- 6 y1 \, e' z/ |4 z
复制代码 9 L- x" @, @% S* v: i
( V# }! ]/ K9 O, X1 m9 F9 V0 t8 _
; ^2 o$ @3 q+ |% Q |