Skip to content

Commit cfd6ffc

Browse files
committed
Adding files for cpu temperature fix
1 parent 67f128c commit cfd6ffc

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

shared-bindings/microcontroller/Processor.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@
4444
//| print(microcontroller.cpu.temperature)
4545
//|
4646
//| Note that on chips with more than one cpu (such as the RP2040)
47-
//| you will need to index the cpu to select which one to get the
48-
//| readings from. i.e.
47+
//| microcontroller.cpu will return the value for CPU 0.
48+
//| To get values from other CPUs use microcontroller.cpus indexed by
49+
//| the number of the desired cpu. i.e.
4950
//|
50-
//| print(microcontroller.cpu[0].temperature)
51-
//| print(microcontroller.cpu[1].frequency)"""
51+
//| print(microcontroller.cpus[0].temperature)
52+
//| print(microcontroller.cpus[1].frequency)"""
5253
//|
5354

5455
//| def __init__(self) -> None:

shared-bindings/microcontroller/__init__.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@
5353
//| cpu: Processor
5454
//| """CPU information and control, such as ``cpu.temperature`` and ``cpu.frequency``
5555
//| (clock frequency).
56-
//| This object is the sole instance of `microcontroller.Processor`."""
56+
//| This object is an instance of `microcontroller.Processor`."""
57+
//|
58+
59+
//| cpus: Processor
60+
//| """CPU information and control, such as ``cpus[0].temperature`` and ``cpus[1].frequency``
61+
//| (clock frequency) on chips with more than 1 cpu. the index selects which cpu.
62+
//| This object is an instance of `microcontroller.Processor`."""
5763
//|
5864

5965
//| def delay_us(delay: int) -> None:
@@ -155,6 +161,9 @@ const mp_obj_module_t mcu_pin_module = {
155161
STATIC const mp_rom_map_elem_t mcu_module_globals_table[] = {
156162
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_microcontroller) },
157163
{ MP_ROM_QSTR(MP_QSTR_cpu), MP_ROM_PTR(&common_hal_mcu_processor_obj) },
164+
#if CIRCUITPY_PROCESSOR_COUNT > 1
165+
{ MP_ROM_QSTR(MP_QSTR_cpus), MP_ROM_PTR(&common_hal_multi_processor_obj) },
166+
#endif
158167
{ MP_ROM_QSTR(MP_QSTR_delay_us), MP_ROM_PTR(&mcu_delay_us_obj) },
159168
{ MP_ROM_QSTR(MP_QSTR_disable_interrupts), MP_ROM_PTR(&mcu_disable_interrupts_obj) },
160169
{ MP_ROM_QSTR(MP_QSTR_enable_interrupts), MP_ROM_PTR(&mcu_enable_interrupts_obj) },

shared-bindings/microcontroller/__init__.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ extern const mp_obj_dict_t mcu_pin_globals;
4848
#if CIRCUITPY_PROCESSOR_COUNT == 1
4949
extern const mcu_processor_obj_t common_hal_mcu_processor_obj;
5050
#elif CIRCUITPY_PROCESSOR_COUNT > 1
51-
extern const mp_rom_obj_tuple_t common_hal_mcu_processor_obj;
51+
extern const mcu_processor_obj_t common_hal_mcu_processor_obj;
52+
extern const mp_rom_obj_tuple_t common_hal_multi_processor_obj;
5253
#else
5354
#error "Invalid processor count"
5455
#endif

0 commit comments

Comments
 (0)