Skip to content

Hooks for external modules #18500

@sfe-SparkFro

Description

@sfe-SparkFro

Description

From #18446 (comment):

Side note - is there a way for user C/C++ modules to detect and respond to soft resets?

No, but that would be a good thing to add. Maybe something like MP_REGISTER_SOFT_RESET_HOOK? That would add to an array of soft reset callbacks.

Would also be great to have hooks for initialization, similar to MICROPY_BOARD_STARTUP and MICROPY_BOARD_EARLY_INIT. Example for motivation, I have this module implementation that needs to know when the GC has been initialized so memory can be allocated in the C heap before, or in the GC pool after.

Code Size

Would have zero code side increase for builds that do not need this feature, can be optionally enabled.

Implementation

I hope the MicroPython maintainers or community will implement this feature

Code of Conduct

Yes, I agree

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature requests, new feature implementations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions