8000 stmhal: Add pyb.unique_id, to get unique id of MCU. · errordeveloper/micropython@ed5117f · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit ed5117f

Browse files
committed
stmhal: Add pyb.unique_id, to get unique id of MCU.
1 parent 44ee42d commit ed5117f

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

stmhal/modpyb.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030
#include "modpyb.h"
3131
#include "ff.h"
3232

33+
STATIC mp_obj_t pyb_unique_id(void) {
34+
// get unique id; 96 bits
35+
byte *id = (byte*)0x1fff7a10;
36+
return mp_obj_new_bytes(id, 12);
37+
}
38+
STATIC MP_DEFINE_CONST_FUN_OBJ_0(pyb_unique_id_obj, pyb_unique_id);
39+
3340
// get lots of info about the board
3441
STATIC mp_obj_t pyb_info(uint n_args, const mp_obj_t *args) {
3542
// get and print unique id; 96 bits
@@ -233,6 +240,7 @@ MP_DECLARE_CONST_FUN_OBJ(pyb_usb_mode_obj); // defined in main.c
233240
STATIC const mp_map_elem_t pyb_module_globals_table[] = {
234241
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_pyb) },
235242

243+
{ MP_OBJ_NEW_QSTR(MP_QSTR_unique_id), (mp_obj_t)&pyb_unique_id_obj },
236244
{ MP_OBJ_NEW_QSTR(MP_QSTR_info), (mp_obj_t)&pyb_info_obj },
237245
{ MP_OBJ_NEW_QSTR(MP_QSTR_gc), (mp_obj_t)&pyb_gc_obj },
238246
{ MP_OBJ_NEW_QSTR(MP_QSTR_repl_info), (mp_obj_t)&pyb_set_repl_info_obj },

stmhal/qstrdefsport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
Q(help)
44
Q(pyb)
5+
Q(unique_id)
56
Q(info)
67
Q(sd_test)
78
Q(present)

0 commit comments

Comments
 (0)
0