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

Double check handling of pins used by drivers #1544

Closed
bjoernQ opened this issue May 8, 2024 · 1 comment · Fixed by #1592
Closed

Double check handling of pins used by drivers #1544

bjoernQ opened this issue May 8, 2024 · 1 comment · Fixed by #1592
Assignees
Labels
status:needs-attention This should be prioritized
Milestone

Comments

@bjoernQ
Copy link
Contributor

bjoernQ commented May 8, 2024

This currently compiles while it shouldn't

#[entry]
fn main() -> ! {
    let peripherals = Peripherals::take();
    let system = SystemControl::new(peripherals.SYSTEM);
    let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

    let mut io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
    let pins = TxRxPins::new_tx_rx(
        &mut io.pins.gpio4,
        &mut io.pins.gpio5,
    );

    let mut serial1 = Uart::new_with_config(
        peripherals.UART1,
        Config::default(),
        Some(pins),
        &clocks,
        None,
    );

    io.pins.gpio4.into_push_pull_output(); // this shouldn't compile since the pin is used by the UART driver

    let delay = Delay::new(&clocks);

    println!("Start");
    loop {
        serial1.write_byte(0x42).ok();
        let read = block!(serial1.read_byte());

        match read {
            Ok(read) => println!("Read 0x{:02x}", read),
            Err(err) => println!("Error {:?}", err),
        }

        delay.delay_millis(250);
    }
}

Easiest here probably is to align the API and have it similar to SPI master (i.e. with_tx / with_rx etc.)?

@Dominaezzz
Copy link
Contributor

When using the I2S peripheral in camera mode, most people will need to give the vsync pin to the peripheral but also separately listen for interrupts on the pin.

So I guess this depends on whether the peripheral is reading the pin or writing to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:needs-attention This should be prioritized
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants