Merge pull request #4087 from DavePutz/cpu_temp_doc
Fixing microcontroller.cpu on multi-core cpus and adding microcontroller.cpus
This commit is contained in:
commit
459f323247
@ -80,6 +80,7 @@ void common_hal_mcu_reset(void) {
|
|||||||
|
|
||||||
// The singleton microcontroller.Processor object, bound to microcontroller.cpu
|
// The singleton microcontroller.Processor object, bound to microcontroller.cpu
|
||||||
// It currently only has properties, and no state.
|
// It currently only has properties, and no state.
|
||||||
|
#if CIRCUITPY_PROCESSOR_COUNT > 1
|
||||||
static const mcu_processor_obj_t processor0 = {
|
static const mcu_processor_obj_t processor0 = {
|
||||||
.base = {
|
.base = {
|
||||||
.type = &mcu_processor_type,
|
.type = &mcu_processor_type,
|
||||||
@ -92,7 +93,7 @@ static const mcu_processor_obj_t processor1 = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const mp_rom_obj_tuple_t common_hal_mcu_processor_obj = {
|
const mp_rom_obj_tuple_t common_hal_multi_processor_obj = {
|
||||||
{&mp_type_tuple},
|
{&mp_type_tuple},
|
||||||
CIRCUITPY_PROCESSOR_COUNT,
|
CIRCUITPY_PROCESSOR_COUNT,
|
||||||
{
|
{
|
||||||
@ -100,6 +101,13 @@ const mp_rom_obj_tuple_t common_hal_mcu_processor_obj = {
|
|||||||
MP_ROM_PTR(&processor1)
|
MP_ROM_PTR(&processor1)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const mcu_processor_obj_t common_hal_mcu_processor_obj = {
|
||||||
|
.base = {
|
||||||
|
.type = &mcu_processor_type,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
#if CIRCUITPY_NVM && CIRCUITPY_INTERNAL_NVM_SIZE > 0
|
#if CIRCUITPY_NVM && CIRCUITPY_INTERNAL_NVM_SIZE > 0
|
||||||
// The singleton nvm.ByteArray object.
|
// The singleton nvm.ByteArray object.
|
||||||
|
@ -41,7 +41,15 @@
|
|||||||
//|
|
//|
|
||||||
//| import microcontroller
|
//| import microcontroller
|
||||||
//| print(microcontroller.cpu.frequency)
|
//| 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:
|
//| def __init__(self) -> None:
|
||||||
|
@ -53,7 +53,13 @@
|
|||||||
//| cpu: Processor
|
//| cpu: Processor
|
||||||
//| """CPU information and control, such as ``cpu.temperature`` and ``cpu.frequency``
|
//| """CPU information and control, such as ``cpu.temperature`` and ``cpu.frequency``
|
||||||
//| (clock 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:
|
//| 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[] = {
|
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___name__), MP_ROM_QSTR(MP_QSTR_microcontroller) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_cpu), MP_ROM_PTR(&common_hal_mcu_processor_obj) },
|
{ 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_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_disable_interrupts), MP_ROM_PTR(&mcu_disable_interrupts_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_enable_interrupts), MP_ROM_PTR(&mcu_enable_interrupts_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_enable_interrupts), MP_ROM_PTR(&mcu_enable_interrupts_obj) },
|
||||||
|
@ -48,7 +48,8 @@ extern const mp_obj_dict_t mcu_pin_globals;
|
|||||||
#if CIRCUITPY_PROCESSOR_COUNT == 1
|
#if CIRCUITPY_PROCESSOR_COUNT == 1
|
||||||
extern const mcu_processor_obj_t common_hal_mcu_processor_obj;
|
extern const mcu_processor_obj_t common_hal_mcu_processor_obj;
|
||||||
#elif CIRCUITPY_PROCESSOR_COUNT > 1
|
#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
|
#else
|
||||||
#error "Invalid processor count"
|
#error "Invalid processor count"
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user