STM32G070的CPUID地址:- /*!< Device Electronic Signature */: r7 m" q( E8 D- n$ ~' D) e
- #define PACKAGE_BASE (0x1FFF7500UL) /*!< Package data register base address */" y4 r$ B% [. S
- #define UID_BASE (0x1FFF7590UL) /*!< Unique device ID register base address */6 x( A) v. K( `$ _" d
- #define FLASHSIZE_BASE (0x1FFF75E0UL) /*!< Flash size data register base address *// t* V7 W0 F8 V) `/ e: O) A
- /**3 ^5 _7 J/ U% s, @( C6 ]4 d
复制代码 % z$ Q( N( R, P- u9 H% ?
$ m% Q1 v, l; ]0 ~- D% f4 _' Q
HAL库已经预留了API可以直接读取:- /**
" [: Z0 b& P- g1 Y9 h9 w - * @brief Returns first word of the unique device identifier (UID based on 96 bits)
) n; ]+ D& D, W; Y - * @retval Device identifier) ?( M( u( K( A# G& h+ V# w
- */
3 {1 S! i( G% O7 \7 u: d - uint32_t HAL_GetUIDw0(void), B! ?- t6 \# O0 U$ g1 g
- {6 w; j! p8 @: I, p& F& v8 A* M
- return (READ_REG(*((uint32_t *)UID_BASE)));0 `6 Y$ D) {' ~, D! B
- }
; ?) C$ R7 {: ]3 e B4 M! v' d
7 G8 _2 c" ?. k3 I$ f# a- /**
/ M# S- [# H; J5 x, g - * @brief Returns second word of the unique device identifier (UID based on 96 bits)& ]( c2 G, a1 Q O% A
- * @retval Device identifier- }3 F1 ^0 p3 l! A; u
- */' H' i4 F. f" W, ]
- uint32_t HAL_GetUIDw1(void)7 ?% G# t4 T$ @6 H1 m: h8 n
- {, u1 s1 z; k+ f+ |: n4 h( D
- return (READ_REG(*((uint32_t *)(UID_BASE + 4U))));) @2 J* j: L9 l& f* i; T
- }- H: C# K0 d1 o- u5 N2 _; n0 ]
; V, b$ ]9 \3 N+ t0 g9 u- /**
$ Q! w7 l* P7 s: y, x1 x1 M - * @brief Returns third word of the unique device identifier (UID based on 96 bits)' e |, r0 x4 k* }3 u
- * @retval Device identifier, t+ @4 R* E. @. ^; x1 J$ l
- */
+ L I: ^ J2 v4 E' ]! L; {" _ - uint32_t HAL_GetUIDw2(void)4 S K, s8 {" W* ^8 G P5 `6 E
- {
( _3 ^2 l/ B7 j9 k6 w - return (READ_REG(*((uint32_t *)(UID_BASE + 8U))));
% i/ t2 n5 L |* ^" G - }/ l, m6 r7 W" v- U/ ?- U
" V; p6 l' b V7 O. D1 p
复制代码 ! u- D. C6 u/ t3 a4 A
: e; i! `, l% `+ l; E: @- n: u: s6 T9 q* W
|