diff options
| author | Damien George <damien.p.george@gmail.com> | 2014-04-19 01:28:18 +0100 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2014-04-19 01:28:18 +0100 |
| commit | ed5117f6a8d0659b8a9a3a985d8b7e36644e39d5 (patch) | |
| tree | dd559b37fd5f741257367c6b5b983783116d9288 /stmhal/modpyb.c | |
| parent | 44ee42de50776210293ef7edea9089e5327142e2 (diff) | |
stmhal: Add pyb.unique_id, to get unique id of MCU.
Diffstat (limited to 'stmhal/modpyb.c')
| -rw-r--r-- | stmhal/modpyb.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/stmhal/modpyb.c b/stmhal/modpyb.c index ccf9fa53c..6424fc4df 100644 --- a/stmhal/modpyb.c +++ b/stmhal/modpyb.c @@ -30,6 +30,13 @@ #include "modpyb.h" #include "ff.h" +STATIC mp_obj_t pyb_unique_id(void) { + // get unique id; 96 bits + byte *id = (byte*)0x1fff7a10; + return mp_obj_new_bytes(id, 12); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(pyb_unique_id_obj, pyb_unique_id); + // get lots of info about the board STATIC mp_obj_t pyb_info(uint n_args, const mp_obj_t *args) { // get and print unique id; 96 bits @@ -233,6 +240,7 @@ MP_DECLARE_CONST_FUN_OBJ(pyb_usb_mode_obj); // defined in main.c STATIC const mp_map_elem_t pyb_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_pyb) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_unique_id), (mp_obj_t)&pyb_unique_id_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_info), (mp_obj_t)&pyb_info_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_gc), (mp_obj_t)&pyb_gc_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_repl_info), (mp_obj_t)&pyb_set_repl_info_obj }, |
