diff options
| author | Dan Halbert <halbert@adafruit.com> | 2021-02-01 12:50:37 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-01 12:50:37 -0500 |
| commit | 459f3232477877b6dbc011f93ebc9d3544d918c3 (patch) | |
| tree | cc9d1e43b91725bdb2fea8ddde5e0330f6acffc4 /shared-bindings/microcontroller | |
| parent | 0c0b517112100c1ec90ed66fba8bc315bc5440d0 (diff) | |
| parent | e1838ff335f2daef9ad2389b7231b73da43057eb (diff) | |
Merge pull request #4087 from DavePutz/cpu_temp_doc
Fixing microcontroller.cpu on multi-core cpus and adding microcontroller.cpus
Diffstat (limited to 'shared-bindings/microcontroller')
| -rw-r--r-- | shared-bindings/microcontroller/Processor.c | 10 | ||||
| -rw-r--r-- | shared-bindings/microcontroller/__init__.c | 11 | ||||
| -rw-r--r-- | shared-bindings/microcontroller/__init__.h | 3 |
3 files changed, 21 insertions, 3 deletions
diff --git a/shared-bindings/microcontroller/Processor.c b/shared-bindings/microcontroller/Processor.c index 90cc02fe3..67001c831 100644 --- a/shared-bindings/microcontroller/Processor.c +++ b/shared-bindings/microcontroller/Processor.c @@ -41,7 +41,15 @@ //| //| import microcontroller //| print(microcontroller.cpu.frequency) -//| print(microcontroller.cpu.temperature)""" +//| print(microcontroller.cpu.temperature) +//| +//| Note that on chips with more than one cpu (such as the RP2040) +//| microcontroller.cpu will return the value for CPU 0. +//| To get values from other CPUs use microcontroller.cpus indexed by +//| the number of the desired cpu. i.e. +//| +//| print(microcontroller.cpus[0].temperature) +//| print(microcontroller.cpus[1].frequency)""" //| //| def __init__(self) -> None: diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index 035587c30..dba66fa4f 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -53,7 +53,13 @@ //| cpu: Processor //| """CPU information and control, such as ``cpu.temperature`` and ``cpu.frequency`` //| (clock frequency). -//| This object is the sole instance of `microcontroller.Processor`.""" +//| This object is an instance of `microcontroller.Processor`.""" +//| + +//| cpus: Processor +//| """CPU information and control, such as ``cpus[0].temperature`` and ``cpus[1].frequency`` +//| (clock frequency) on chips with more than 1 cpu. The index selects which cpu. +//| This object is an instance of `microcontroller.Processor`.""" //| //| def delay_us(delay: int) -> None: @@ -155,6 +161,9 @@ const mp_obj_module_t mcu_pin_module = { STATIC const mp_rom_map_elem_t mcu_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_microcontroller) }, { MP_ROM_QSTR(MP_QSTR_cpu), MP_ROM_PTR(&common_hal_mcu_processor_obj) }, +#if CIRCUITPY_PROCESSOR_COUNT > 1 + { MP_ROM_QSTR(MP_QSTR_cpus), MP_ROM_PTR(&common_hal_multi_processor_obj) }, +#endif { MP_ROM_QSTR(MP_QSTR_delay_us), MP_ROM_PTR(&mcu_delay_us_obj) }, { MP_ROM_QSTR(MP_QSTR_disable_interrupts), MP_ROM_PTR(&mcu_disable_interrupts_obj) }, { MP_ROM_QSTR(MP_QSTR_enable_interrupts), MP_ROM_PTR(&mcu_enable_interrupts_obj) }, diff --git a/shared-bindings/microcontroller/__init__.h b/shared-bindings/microcontroller/__init__.h index 39d3e718b..733127d56 100644 --- a/shared-bindings/microcontroller/__init__.h +++ b/shared-bindings/microcontroller/__init__.h @@ -48,7 +48,8 @@ extern const mp_obj_dict_t mcu_pin_globals; #if CIRCUITPY_PROCESSOR_COUNT == 1 extern const mcu_processor_obj_t common_hal_mcu_processor_obj; #elif CIRCUITPY_PROCESSOR_COUNT > 1 -extern const mp_rom_obj_tuple_t common_hal_mcu_processor_obj; +extern const mcu_processor_obj_t common_hal_mcu_processor_obj; +extern const mp_rom_obj_tuple_t common_hal_multi_processor_obj; #else #error "Invalid processor count" #endif |
