File tree Expand file tree Collapse file tree 4 files changed +30
-4
lines changed
ports/raspberrypi/common-hal/microcontroller
shared-bindings/microcontroller Expand file tree Collapse file tree 4 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ void common_hal_mcu_reset(void) {
80
80
81
81
// The singleton microcontroller.Processor object, bound to microcontroller.cpu
82
82
// It currently only has properties, and no state.
83
+ #if CIRCUITPY_PROCESSOR_COUNT > 1
83
84
static const mcu_processor_obj_t processor0 = {
84
85
.base = {
85
86
.type = & mcu_processor_type ,
@@ -92,14 +93,21 @@ static const mcu_processor_obj_t processor1 = {
92
93
},
93
94
};
94
95
95
- const mp_rom_obj_tuple_t common_hal_mcu_processor_obj = {
96
+ const mp_rom_obj_tuple_t common_hal_multi_processor_obj = {
96
97
{& mp_type_tuple },
97
98
CIRCUITPY_PROCESSOR_COUNT ,
98
99
{
99
100
MP_ROM_PTR (& processor0 ),
100
101
MP_ROM_PTR (& processor1 )
101
102
}
102
103
};
104
+ #endif
105
+
106
+ const mcu_processor_obj_t common_hal_mcu_processor_obj = {
107
+ .base = {
108
+ .type = & mcu_processor_type ,
109
+ },
110
+ };
103
111
104
112
#if CIRCUITPY_NVM && CIRCUITPY_INTERNAL_NVM_SIZE > 0
105
113
// The singleton nvm.ByteArray object.
Original file line number Diff line number Diff line change 41
41
//|
42
42
//| import microcontroller
43
43
//| print(microcontroller.cpu.frequency)
44
- //| print(microcontroller.cpu.temperature)"""
44
+ //| print(microcontroller.cpu.temperature)
45
+ //|
46
+ //| Note that on chips with more than one cpu (such as the RP2040)
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.
50
+ //|
51
+ //| print(microcontroller.cpus[0].temperature)
52
+ //| print(microcontroller.cpus[1].frequency)"""
45
53
//|
46
54
47
55
//| def __init__(self) -> None:
Original file line number Diff line number Diff line change 53
53
//| cpu: Processor
54
54
//| """CPU information and control, such as ``cpu.temperature`` and ``cpu.frequency``
55
55
//| (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`."""
57
63
//|
58
64
59
65
//| def delay_us(delay: int) -> None:
@@ -155,6 +161,9 @@ const mp_obj_module_t mcu_pin_module = {
155
161
STATIC const mp_rom_map_elem_t mcu_module_globals_table [] = {
156
162
{ MP_ROM_QSTR (MP_QSTR___name__ ), MP_ROM_QSTR (MP_QSTR_microcontroller ) },
157
163
{ 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
158
167
{ MP_ROM_QSTR (MP_QSTR_delay_us ), MP_ROM_PTR (& mcu_delay_us_obj ) },
159
168
{ MP_ROM_QSTR (MP_QSTR_disable_interrupts ), MP_ROM_PTR (& mcu_disable_interrupts_obj ) },
160
169
{ MP_ROM_QSTR (MP_QSTR_enable_interrupts ), MP_ROM_PTR (& mcu_enable_interrupts_obj ) },
Original file line number Diff line number Diff line change @@ -48,7 +48,8 @@ extern const mp_obj_dict_t mcu_pin_globals;
48
48
#if CIRCUITPY_PROCESSOR_COUNT == 1
49
49
extern const mcu_processor_obj_t common_hal_mcu_processor_obj ;
50
50
#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 ;
52
53
#else
53
54
#error "Invalid processor count"
54
55
#endif
You can’t perform that action at this time.
0 commit comments