mpconfigport.h module definitions

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
hippy
Posts: 130
Joined: Sat Feb 20, 2021 2:46 pm
Location: UK

mpconfigport.h module definitions

Post by hippy » Tue Sep 21, 2021 3:11 pm

Code: Select all

#define MICROPY_PORT_BUILTIN_MODULES \
    { MP_OBJ_NEW_QSTR(MP_QSTR_machine), (mp_obj_t)&mp_module_machine }, \
    { MP_OBJ_NEW_QSTR(MP_QSTR__onewire), (mp_obj_t)&mp_module_onewire }, \
    { MP_OBJ_NEW_QSTR(MP_QSTR__rp2), (mp_obj_t)&mp_module_rp2 }, \
    { MP_ROM_QSTR(MP_QSTR_uos), MP_ROM_PTR(&mp_module_uos) }, \
    { MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&mp_module_utime) }, \
Can anyone explain why there are two different styles for defining built-in modules or point me to the explanatory documentation ?

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: mpconfigport.h module definitions

Post by stijn » Wed Sep 22, 2021 7:38 am

Should probably be MP_ROM_QSTR everywhere. I think MP_ROM_QSTR is the same as MP_OBJ_NEW_QSTR everywhere, but it exists for consistency with MP_ROM_PTR and MP_ROM_INT. See https://github.com/micropython/micropython/pull/1655

hippy
Posts: 130
Joined: Sat Feb 20, 2021 2:46 pm
Location: UK

Re: mpconfigport.h module definitions

Post by hippy » Wed Sep 22, 2021 9:58 am

Thanks I discovered that in adding new modules to my own build I had used a mix of both depending on which I had copied and pasted. It seemed to work regardless but I wasn't sure if I had created some hidden problem which would come back and bite me.

Post Reply