diff options
Diffstat (limited to 'shared-bindings')
| -rw-r--r-- | shared-bindings/index.rst | 59 | ||||
| -rw-r--r-- | shared-bindings/microcontroller/Processor.c | 23 | ||||
| -rw-r--r-- | shared-bindings/microcontroller/Processor.h | 1 |
3 files changed, 55 insertions, 28 deletions
diff --git a/shared-bindings/index.rst b/shared-bindings/index.rst index 7541f8ccf..d1261dcd2 100644 --- a/shared-bindings/index.rst +++ b/shared-bindings/index.rst @@ -11,34 +11,39 @@ limited. For example, a microcontroller without analog features will not have Support Matrix --------------- +NOTE 1: **All Supported** means the following ports are supported: SAMD21, SAMD21 Express, +SAMD51, SAMD51 Express, and ESP8266. -================= ======= ============== ======= -Module / Port SAMD21 SAMD21 Express ESP8266 -================= ======= ============== ======= -`analogio` **Yes** **Yes** **Yes** -`audiobusio` **Yes** **Yes** No -`audioio` No **Yes** No -`bitbangio` No **Yes** **Yes** -`board` **Yes** **Yes** **Yes** -`busio` **Yes** **Yes** **Yes** -`digitalio` **Yes** **Yes** **Yes** -`gamepad` No **Yes** No -`math` **Yes** **Yes** **Yes** -`microcontroller` **Yes** **Yes** **Yes** -`multiterminal` No No **Yes** -`neopixel_write` **Yes** **Yes** **Yes** -`nvm` No **Yes** No -`os` **Yes** **Yes** **Yes** -`pulseio` **Yes** **Yes** No -`random` **Yes** **Yes** **Yes** -`storage` **Yes** **Yes** **Yes** -`struct` **Yes** **Yes** **Yes** -`supervisor` **Yes** **Yes** No -`time` **Yes** **Yes** **Yes** -`touchio` **Yes** **Yes** No -`uheap` Debug Debug Debug -`usb_hid` **Yes** **Yes** No -================= ======= ============== ======= +NOTE 2: **SAMD** and/or **SAMD Express** without additional numbers, means both SAMD21 & SAMD51 versions +are supported. + +================= =============== +Module Supported Ports +================= =============== +`analogio` **All Supported** +`audiobusio` **SAMD/SAMD Express** +`audioio` **SAMD Express** +`bitbangio` **SAMD Express, ESP8266** +`board` **All Supported** +`busio` **All Supported** +`digitalio` **All Supported** +`gamepad` **SAMD Express** +`math` **All Supported** +`microcontroller` **All Supported** +`multiterminal` **ESP8266** +`neopixel_write` **All Supported** +`nvm` **SAMD Express** +`os` **All Supported** +`pulseio` **SAMD/SAMD Express** +`random` **All Supported** +`storage` **All Supported** +`struct` **All Supported** +`supervisor` **SAMD/SAMD Express** +`time` **All Supported** +`touchio` **SAMD/SAMD Express** +`uheap` **Debug (All)** +`usb_hid` **SAMD/SAMD Express** +================= =============== Modules --------- diff --git a/shared-bindings/microcontroller/Processor.c b/shared-bindings/microcontroller/Processor.c index 0e843bd31..7cc0d6016 100644 --- a/shared-bindings/microcontroller/Processor.c +++ b/shared-bindings/microcontroller/Processor.c @@ -32,7 +32,6 @@ #include "py/objproperty.h" -#include "py/objproperty.h" #include "py/runtime.h" //| .. currentmodule:: microcontroller @@ -93,9 +92,31 @@ const mp_obj_property_t mcu_processor_temperature_obj = { }, }; +//| .. attribute:: uid +//| +//| Return the unique id (aka serial number) of the chip. +//| Returns a bytearray object. +//| +STATIC mp_obj_t mcu_processor_get_uid(mp_obj_t self) { + uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH]; + common_hal_mcu_processor_get_uid(raw_id); + return mp_obj_new_bytearray(sizeof(raw_id), raw_id); +} + +MP_DEFINE_CONST_FUN_OBJ_1(mcu_processor_get_uid_obj, mcu_processor_get_uid); + +const mp_obj_property_t mcu_processor_uid_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&mcu_processor_get_uid_obj, // getter + (mp_obj_t)&mp_const_none_obj, // no setter + (mp_obj_t)&mp_const_none_obj, // no deleter + }, +}; + STATIC const mp_rom_map_elem_t mcu_processor_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_frequency), MP_ROM_PTR(&mcu_processor_frequency_obj) }, { MP_ROM_QSTR(MP_QSTR_temperature), MP_ROM_PTR(&mcu_processor_temperature_obj) }, + { MP_ROM_QSTR(MP_QSTR_uid), MP_ROM_PTR(&mcu_processor_uid_obj) }, }; STATIC MP_DEFINE_CONST_DICT(mcu_processor_locals_dict, mcu_processor_locals_dict_table); diff --git a/shared-bindings/microcontroller/Processor.h b/shared-bindings/microcontroller/Processor.h index a79dea478..28f054420 100644 --- a/shared-bindings/microcontroller/Processor.h +++ b/shared-bindings/microcontroller/Processor.h @@ -35,5 +35,6 @@ const mp_obj_type_t mcu_processor_type; uint32_t common_hal_mcu_processor_get_frequency(void); float common_hal_mcu_processor_get_temperature(void); +void common_hal_mcu_processor_get_uid(uint8_t raw_id[]); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_MICROCONTROLLER_PROCESSOR_H |
