Skip to content

Make bits pub? #41

@astro

Description

@astro

I've got 4 LEDs that I can manipulate individually. My first try looks like this:

fn toggle_led(led: u8) {
    match led {
        1 => 
            gpio_port().not[2].write(|notw| notw.notp1(true)),
        2 => 
            gpio_port().not[2].write(|notw| notw.notp2(true)),
        3 => 
            gpio_port().not[2].write(|notw| notw.notp8(true)),
        4 => 
            gpio_port().not[5].write(|notw| notw.notp26(true)),
        _ => (),
    }
}

It's hard to parameterize over notp1, notp2, etc. In this case I'd like to sacrifice the pretty abstraction and manipulate any bit of self.bits.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions