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 MBX support, mailbox for communication across multicore or RTOS tasks #7

Merged
merged 6 commits into from
Jun 26, 2024

Conversation

andelf
Copy link
Collaborator

@andelf andelf commented Jun 25, 2024

  • message word(u32) API: send/recv interface
  • message queue(FIFO) API: send_fifo/recv_fifo/Stream interface
  • Demo code
  • Design consideration: eliminate peripheral generic parameter? - DONE

Demo usage:

bind_interrupts!(struct Irqs {
    MBX0A => hal::mbx::InterruptHandler<peripherals::MBX0A>;
    MBX0B => hal::mbx::InterruptHandler<peripherals::MBX0B>;
});


#[embassy_executor::task]
async fn mailbox(mbox: Mbx<'static>) {
    let mut mbox = mbox;
    let mut i = 345;
    loop {
        defmt::info!("[task0] sending {}", i);
        mbox.send_fifo(i).await; // will block until fifo has space
        i += 1;

        Timer::after_millis(100).await; // faster
    }
}

let mut outbox = Mbx::new(p.MBX0B, Irqs);
while let Some(val) = outbox.next().await {
            defmt::info!("[main] Received: {}", val);
            Timer::after_millis(1000).await; // slower
}

@andelf andelf merged commit 8b1e29f into master Jun 26, 2024
1 check passed
@andelf andelf deleted the feat/mbx branch June 26, 2024 00:10
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.

1 participant