Skip to content

Abstract boards#2

Closed
conorpp wants to merge 0 commit into
solokeys:devfrom
conorpp:abstract-boards
Closed

Abstract boards#2
conorpp wants to merge 0 commit into
solokeys:devfrom
conorpp:abstract-boards

Conversation

@conorpp
Copy link
Copy Markdown
Member

@conorpp conorpp commented Jun 3, 2020

Added traits and abstractions for LED and buttons for both Xpresso and Bee boards. Haven't committed to lib.rs or app_rtfm.rs yet, but locally I'm using them like so.

    #[cfg(feature = "board-lpcxpresso")]
    let rgb = board::led::Rgb::new(
        board::led::RedLedPin::take().unwrap().into_match_output(&mut iocon),
        board::led::GreenLedPin::take().unwrap().into_match_output(&mut iocon),
        board::led::BlueLedPin::take().unwrap().into_match_output(&mut iocon),
        Pwm::new(hal.ctimer.2.enabled(&mut syscon)),
    );

    #[cfg(feature = "board-prototype")]
    let rgb = board::led::Rgb::new(
        board::led::RedLedPin::take().unwrap().into_match_output(&mut iocon),
        board::led::GreenLedPin::take().unwrap().into_match_output(&mut iocon),
        board::led::BlueLedPin::take().unwrap().into_match_output(&mut iocon),
        Pwm::new(hal.ctimer.3.enabled(&mut syscon)),
    );

    #[cfg(feature = "board-lpcxpresso")]
    let three_buttons = board::button::ThreeButtons::new(
        Timer::new(hal.ctimer.1.enabled(&mut syscon)),
        board::button::UserButtonPin::take().unwrap().into_gpio_pin(&mut iocon, &mut gpio).into_input(),
        board::button::WakeupButtonPin::take().unwrap().into_gpio_pin(&mut iocon, &mut gpio).into_input(),
    );


    #[cfg(feature = "board-prototype")]
    let three_buttons =
    {
        let mut dma = hal::Dma::from(hal.dma).enabled(&mut syscon);

        board::button::ThreeButtons::new (
            hal::Adc::from(hal.adc).enabled(&mut pmc, &mut syscon),
            hal.ctimer.1.enabled(&mut syscon),
            hal.ctimer.2.enabled(&mut syscon),
            board::button::ChargeMatchPin::take().unwrap().into_match_output(&mut iocon),
            board::button::ButtonTopPin::take().unwrap().into_analog_input(&mut iocon, &mut gpio),
            board::button::ButtonBotPin::take().unwrap().into_analog_input(&mut iocon, &mut gpio),
            board::button::ButtonMidPin::take().unwrap().into_analog_input(&mut iocon, &mut gpio),
            &mut dma,
            clocks.support_touch_token().unwrap(),
        )
    };

I've had to make minor changes to the HAL, so this will depend on another HAL release.

@conorpp conorpp closed this Jun 3, 2020
0x0ece pushed a commit that referenced this pull request Apr 19, 2026
Enable oath feature in default features
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