From 9845930b2e0d2b47350d03cff4d40f6ba03a58d1 Mon Sep 17 00:00:00 2001 From: Michael Kamprath Date: Sat, 28 Sep 2024 22:59:06 -0700 Subject: [PATCH] changed pin type --- src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 989b7b0..27c1604 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,7 +17,7 @@ use panic_probe as _; use rp2040_hal::{ gpio::{ bank0::{Gpio0, Gpio2, Gpio3}, - FunctionSpi, PullDown, + FunctionI2C, FunctionSpi, Pin, PullDown, PullUp, }, pac::SPI0, }; @@ -100,11 +100,14 @@ fn main() -> ! { channel_a.output_to(pins.gpio8); channel_b.output_to(pins.gpio9); + // Configure two pins as being I²C, not GPIO + let sda_pin: Pin<_, FunctionI2C, PullUp> = pins.gpio4.reconfigure(); + let scl_pin: Pin<_, FunctionI2C, PullUp> = pins.gpio5.reconfigure(); // set up I2C let i2c = bsp::hal::I2C::new_controller( pac.I2C0, - pins.gpio4.into_function::(), - pins.gpio5.into_function::(), + sda_pin, + scl_pin, HertzU32::from_raw(400_000), &mut pac.RESETS, clocks.system_clock.freq(),