Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rp2040 task queue support for Core #1 #2634

Merged
merged 4 commits into from
Apr 24, 2023

Conversation

mikee47
Copy link
Contributor

@mikee47 mikee47 commented Apr 23, 2023

This PR re-implements the task queue using SDK-provided queue API. This allows code running on Core #1 to queue tasks for execution by Sming (which runs on Core #0).

Some care is required running both cores together so some notes have been added to the documentation.

Note: I had a need to run some simple background analogue processing for which core 1 was an ideal solution.
I put all the code in RAM, both for performance reasons and because XIP is suspended during flash erase/write operations (such as file writes). I avoided using floating-point code for the same reasons - FP routines are large so compile to flash.

The Cortex M0+ has hardware support for integer division but these routines compile to flash by default. They're small so have set the SDK PICO_DIVIDER_IN_RAM flag. It seems reasonable that integer arithmetic shouldn't require flash accesses.

Note: There is also PICO_INT64_OPS_IN_RAM and PICO_MEM_IN_RAM which probably warrant further investigation/consideration.

@what-the-diff
Copy link

what-the-diff bot commented Apr 23, 2023

PR Summary

  • Added new pin A0
    A new pin A0 has been introduced for further functionality.

  • Moved queue_add_internal function to RAM
    The queue_add_internal function has been relocated to RAM, which resolves issues related to interrupts and function calls.

  • Ensured system tasks run properly after boot
    Fixed an issue where system tasks wouldn't run if queued before user task queues were created. A static TaskQueue object now handles system tasks, guaranteeing the functionality even when no user-defined task queues exist yet.

@slaff slaff added this to the 4.8.0 milestone Apr 24, 2023
@slaff slaff merged commit 850c6a7 into SmingHub:develop Apr 24, 2023
@mikee47 mikee47 deleted the feature/rp2040-coresafe-queue branch April 24, 2023 20:40
slaff pushed a commit that referenced this pull request Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants