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

Define at compile time in pico_asm! #63

Open
dthelegend opened this issue Aug 28, 2024 · 2 comments
Open

Define at compile time in pico_asm! #63

dthelegend opened this issue Aug 28, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@dthelegend
Copy link

Is there any way of doing the following:

fn some_function<const N : u8> -> ! {
    let led_program = pio_proc::pio_asm!(
        ".define T1 42",
        ".wrap_target",
            "mov pins , 0 [T0]",
            "mov pins , 1 [T1]",
        ".wrap",
        define(T0 = N) // Add T0 defined to the value of compile constant N
    );
    ...
}

Essentially where you can add a define to a pio_asm at compile time? If not I would like to propose this addition.

@jannic jannic added the enhancement New feature or request label Aug 28, 2024
@jannic
Copy link
Member

jannic commented Aug 28, 2024

It's not currently possible, but it sounds like a nice enhancement.

However, I'm not sure if it's possible to actually evaluate N inside the macro at compile time.

@dthelegend
Copy link
Author

I checked and you cannot evaluate constants at macro time, so this is DOA :(

I also noticed that since you can't get the type out from the public defines, you can't declare a pio_asm! as a constant variable. It might be worth adding a way to forward declare the ExpandedDefines type with a new option(public_defines_type) or something.

I can see a world where if you can at least declare it constant at compile time one could modify the program at compile with a custom define they needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants